Get place from Google Places API using ID
Solution 1
It is now possible to fetch place data by placeId:
https://developers.google.com/maps/documentation/javascript/examples/place-details
Solution 2
You can search Place data by PlaceID
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJF7QkuDsDLz4R0rJ4SsxFl9w&key=YOUR_KEY
Solution 3
It is not possible to get a place details with id, you do need to use the reference. as specifically mentioned in the bottom of this link - http://goo.gl/KFDbl
Solution 4
Apparently both the id and reference are deprecated anyway.
From the Google Places Autocomplete Docs (Aug 2014):
"Note: The id and reference fields are deprecated as of June 24, 2014. They are replaced by the new place ID, a unique identifier that can be used to compare places and to retrieve information about a place. The Places API currently returns a place_id in all responses, and accepts a placeid in the Place Details and Place Delete requests. Soon after June 24, 2015, the API will stop returning the id and reference fields in responses. Some time later, the API will no longer accept the reference in requests. We recommend that you update your code to use the new place ID instead of id and reference as soon as possible. "
https://developers.google.com/places/documentation/autocomplete
iltdev
Updated on January 26, 2020Comments
-
iltdev over 4 years
I can get place details from Google places API when I know the reference by using:
However, I want to get the same information by using the ID instead. So the same place in the query above would be something like:
Is such a thing possible?
This will be part of a search filter I'm building, part of which is location. My search parameters are passed to the url, so I plan to do the same with the selected location from the places autocomplete. Using id is much shorter than reference, so more suitable for the querystring. Unless there is a better way to do it?
-
Luca about 8 yearsid and reference are now deprecated, use placeID: developers.google.com/places/web-service/details
-
Alok about 7 yearsAPI is working fine but still not getting zip code in detail.