iltdev
iltdev

Reputation: 1835

Get place from Google Places API using ID

I can get place details from Google places API when I know the reference by using:

https://maps.googleapis.com/maps/api/place/details/json?reference=CmRYAAAAciqGsTRX1mXRvuXSH2ErwW-jCINE1aLiwP64MCWDN5vkXvXoQGPKldMfmdGyqWSpm7BEYCgDm-iv7Kc2PF7QA7brMAwBbAcqMr5i1f4PwTpaovIZjysCEZTry8Ez30wpEhCNCXpynextCld2EBsDkRKsGhSLayuRyFsex6JA6NPh9dyupoTH3g&sensor=true&key=API_KEY_HERE

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:

https://maps.googleapis.com/maps/api/place/details/json?id=4f89212bf76dde31f092cfc14d7506555d85b5c7&sensor=true&key=API_KEY_HERE

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?

Upvotes: 10

Views: 41308

Answers (4)

Azhar
Azhar

Reputation: 20670

You can search Place data by PlaceID

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJF7QkuDsDLz4R0rJ4SsxFl9w&key=YOUR_KEY

Upvotes: 14

Jeremy Eaton
Jeremy Eaton

Reputation: 148

It is now possible to fetch place data by placeId:

https://developers.google.com/maps/documentation/javascript/examples/place-details

Upvotes: 11

shmuckjones
shmuckjones

Reputation: 41

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

Upvotes: 3

Ajar
Ajar

Reputation: 1051

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

Upvotes: 7

Related Questions