Search By Radius to get locations around a set of coordinates. We are using R to pass the following query, but when we do, we get a 400 error. When we run the same query in the GUI it works

Hello, we are trying to use Search By Radius to get locations around a set of coordinates. We are using R to pass the following query, but when we do, we get a 400 error. When we run the same query in the GUI here, it works. Anyone can help us figure out what’s going wrong? Thank you!

query radius { search( filter: { by_radius: { latitude: 37.78247 longitude: -122.407752  distanceInMeters: 100} } ) { places { results(first: 10) { edges { node { placekey safegraph_core {location_name } } } } } } }

To further explain this.
We have zero issue sending queries of the types

lookup
batch_lookup

exactly as they appear in the API docs. The only difference is when we try to use the

search

queries

Here’s an example of the strange behavior I’m seeing.

When I hit the API endpoint with the example query from the SEARCH page of the API docs. Search

query {
  search(first: 5 filter: { 
    address: {
      city:"San Francisco"
      region: "CA"
    } 
  }) {
    placekey
    safegraph_core {
      location_name
      street_address
      city
      region
      top_category
    }
  }
}

That works fine when I send that query through the API in R. I get a valid response. But when I send that exact same query through the GraphiQL GUI at the bottom of the page, I get this error

{
  "error": "Query does not pass validation. Violations:\n\nUnknown argument 'first' on field 'search' of type 'Query'. (line 2, column 10):\n  search(first: 5 filter: { \n         ^\n\nCannot query field 'placekey' on type 'SearchResult'. Did you mean 'places'? (line 8, column 5):\n    placekey\n    ^\n\nCannot query field 'safegraph_core' on type 'SearchResult'. (line 9, column 5):\n    safegraph_core {\n    ^"
}

I’m super confused, hoping someone can help

Looping in @vchen on this.

Thanks! We were trying to implement the same code in Python (Search By Radius) and were wondering how we could pass in multiple attributes — latitude, longitude and distanceInMeters.
We tried using the Python structure that’s on this page, but we get an error

typeError: search() got an unexpected keyword argument 'latitude'

When we run

sgql_client.search(product = 'weekly_patterns', latitude = 37.78247,longitude = -122.407752, distanceInMeters = 100, columns = cols, max_results = 5)

hi aadit, the python library sgql is on v1 on the api and is going to be deprecated since we’ve been making a lot of improvements to v2 of the api. you can make that request directly in python with requests , here is an example: Find all stores | SafeGraph API

that seems to have solved it for us

We were querying V1, and when we queried v2 directly it worsk!