How to get place info from place id in google places api for python

I am using the Google Places API with Python to create a collective smart food app. for example, which restaurants are around, what are their ratings, what are their timings, etc.

I am doing the following in Python:

from googleplaces import GooglePlaces, types, lang

API_KEY = ''

google_places = GooglePlaces(API_KEY)

query_result = google_places.nearby_search(
    location='Mumbai', keyword='Restaurants',
    radius=1000, types=[types.TYPE_RESTAURANT])

if query_result.has_attributions:
   print query_result.html_attributions


for place in query_result.places:
    print place.name
    print place.geo_location
    print place.place_id  

And he returns me something like this:

Subway
{u'lat': Decimal('19.1156005'), u'lng': Decimal('72.9090715')}
ChIJV2JWaObH5zsRt-FrEb8lrtM
Aroma Cafe
{u'lat': Decimal('19.116867'), u'lng': Decimal('72.90982199999999')}
ChIJSWijB-bH5zsRVLE5ipsxvHU
Chili's
{u'lat': Decimal('19.1161942'), u'lng': Decimal('72.90909789999999')}
ChIJ4_2UcubH5zsRWMemt2WTsLc
Mainland China
{u'lat': Decimal('19.1154358'), u'lng': Decimal('72.90858159999999')}
ChIJ88dcaObH5zsRWLT4KyCLkI8
The Yellow Chilli

Now I want to have information about each restaurant (for example, their ratings, reviews, timings). How to get information using place_id?

+4
source share
1 answer

Refer to this section (scroll down for documentation):

https://github.com/slimkrazy/python-google-places

He received all the calls you need. For example:

for place in query_result.places:
    place.get_details()
    print place.rating

. github :)

+2

Source: https://habr.com/ru/post/1620046/


All Articles