Reputation: 2208
Is it possible to retrieve place details for multiple places?
https://maps.googleapis.com/maps/api/place/details/json?placeid=[ArrayInsteadOfJustOnePlaceId]
The documentation does not mention anything regarding the resolving of multiple places.
Upvotes: 19
Views: 4676
Reputation: 91
You can't do it in a single request. You have to iterate over a list of place id and make a call for each.
Here is a sample code to do it using this python wrapper: /slimkrazy/python-google-places
pip install python-google-places
from googleplaces import GooglePlaces, GooglePlacesAttributeError, GooglePlacesError
GOOGLE_API_KEY = 'AIzaSyDRcaVMH1F_H3pIbm1T-XXXXXXXXXXX'
GOOGLE_PLACE_IDS = [
"ChIJC4Wu9QmvthIRDmojjnJB6rA",
"ChIJuRFUv33Ew0cRk0JQb2xQOfs",
"ChIJ9yGYrIwd9kcRlV-tE8ixHpw"
]
def main():
google_places = GooglePlaces(GOOGLE_API_KEY)
for place_id in GOOGLE_PLACE_IDS:
try:
place = google_places.get_place(place_id)
print('{0} place_id has name {1}'.format(place_id, place.name))
except (GooglePlacesError, GooglePlacesAttributeError) as error_detail:
print('Google Returned an Error : {0} for Place ID : {1}'.format(error_detail, place_id))
pass
Upvotes: 2