In the Google Places database and on Google Maps, Place ID is a unique identifier that Google assigns to each and every place. Place IDs play an important role in the GMP ecosystem. They can be used as an input parameter in many of the GMP APIs, including Geocoding API and Directions API (as source or destination), to eliminate ambiguity and improve response time. Read more about place IDs in the Place ID overview. In order to encourage using place IDs, Google offers a few different ways to work with them at no cost.
Place ID lookup
You can find a place ID for free using the Find Place service. This is a great way to programmatically retrieve place IDs for all your stores, restaurants, offices, etc. And, since the Service Specific Terms allow place IDs to be cached indefinitely, you can store place IDs in your database alongside your own place information.
The Find Place API accepts either an address or a place name in the query. By specifying only place_id in the fields parameter or by eliminating the fields parameter altogether, the request is free.
Request
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Lundgren Enterprises Seattle WA&inputtype=textquery&fields=place_id&key=YOUR_API_KEY
Response
{
"candidates": [ { "place_id": "ChIJtbJ_asQVkFQRkx6cDbZge70" } ],
"status": "OK"
}
If you want to do a simple lookup of a handful of places, try out the JavaScript API Place ID finder.
Place ID refresh
It's a best practice to refresh place IDs every 12 months because they can become stale. To refresh the place ID, make a free request to Place Details by specifying only the place_id in the fields parameter.
Request
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJtbJ_asQVkFQRkx6cDbZge70&fields=place_id&key=YOUR_API_KEY
Response
{
"html_attributions": [],
"result": {
"place_id": "ChIJtbJ_asQVkFQRkx6cDbZge70"
},
"status": "OK"
}
You can also refresh the Place ID during an Autocomplete session (at no cost) by specifying place_id as the only field in the fields parameter of the Place Details request.
Take advantage of these free APIs and start leveraging place IDs today.
Comments
0 comments
Please sign in to leave a comment.