Ad

Discrepancy Between Python Googlemaps Library And Google Places API Call With Postman

When I retrieve JSON code from Google Places API with Postman with this GET call:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?types=movie_theater&location=-36.8485,174.763336&radius=10000&key=PutYourAPIKeyHere

I see that after "types" there is "vicinity"; then the brackets close and open again for the next business:

enter image description here

But if I use the official Google Maps Python library in order to retrieve the same call:

import googlemaps
gmaps = googlemaps.Client(key='PutYourAPIKeyHere')
search_loction = gmaps.places("nearby",location='-36.8485, 174.763336', type="movie_theater")
print (search_loction)

I see that after "types" there is no "vicinity" and brackets are closing like it was the last element for that business?

enter image description here

In the Postman API call I'm passing nearbysearch while with Python I'm passing nearby.

So is nearbysearch the same as nearby?

If not what is the nearbysearch for googlemaps library?

Ad

Answer

I found the solution by myself, I will post the answer for those who struggles like me:

import googlemaps

gmaps = googlemaps.Client(key='PutYourAPIKeyHere')

search_loction = gmaps.places_nearby(location='-36.8485, 174.763336', type="movie_theater",radius="10000")
#print (search_loction)
Total_Places_Found = 0


if search_loction['status'] == 'OK':
    Total_Places_Found += len(search_loction['results'])

    for element in search_loction['results']:
        Place_ID = element['place_id']
        ID = element['id']
        Name = element['name']
        Latitude = element['geometry']['location']['lat']
        Longitude = element['geometry']['location']['lng']
        Rating = element['rating']
        Types = element['types']
        vicinity = element['vicinity']
        print (vicinity)
Ad
source: stackoverflow.com
Ad