Nikhil Mishra
Nikhil Mishra

Reputation: 1250

Google maps python API error on calling nearby_places function

I am geting an API error following error while trying to call places_nearby function in the python api for google maps https://github.com/googlemaps/google-maps-services-python/blob/master/googlemaps/places.py

gmaps = googlemaps.Client(key = maps_api_key)

places_result=gmaps.places_nearby(location=(40.714224, -73.961452))

Maybe I am calling it the wrong way. Could anyone please show the proper way to do it. Or Something else I need to fix The image of the error is attatched below: Api Error

Upvotes: 0

Views: 2521

Answers (1)

xomena
xomena

Reputation: 32178

As I can see in your screenshot you are getting the INVALID_REQUEST status code.

According to the Places API documentation:

INVALID_REQUEST generally indicates that a required query parameter (location or radius) is missing.

source: https://developers.google.com/places/web-service/search#PlaceSearchStatusCodes

Indeed, in your code you specify the location parameter, but you don't provide a radius parameter. You can omit a radius parameter only if you specify rankby=distance in your request.

Have a look at nearby search documentation, it reads:

radius — Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50 000 meters. Note that radius must not be included if rankby=distance (described under Optional parameters below) is specified.

I hope this helps!

Upvotes: 2

Related Questions