As we continue our explanation of the ever so useful Google Maps APIs, we will be further looking at its immense features. In this article, we will look at the Google Place Details API, which is used in the most vast and complex use cases.
The Place Details API will be used once you have acquired a “place ID” from any Google API. This can return a vast quantity of information regarding any existing place, such as an address, phone, user reviews, etc.
In this article, we will emphasize the properties and results of the Place Details API, and its commonly used features. To complete documentation and exploit all the Place Details API provides, navigate to the URL below.
They might have made their services public, but these companies certainly aren’t nice enough to give them out for free. In order avail any services from the Google Maps Platform follow the instructions here Set up Cloud Console and API Keys. These instructions will help you in setting up your project on the Google Cloud Console and your API keys for usage and billing purposes.
Google Places API
Previously, in part 3 of this series, we discussed the Place Search API and all its three various forms or sub-APIs. Today, we will talk about the Place Details API.
Place Details API
As you can pretty much tell by the name, the Place Detail API gives us more detailed information regarding the area or abode we are searching for. Once we have the Place Id by using the previously discussed Search API, we can use that as a parameter to be used in the Place Details API.
The Details API request takes a single required text parameter, which would be the ID of the area you will be searching for, and will return relevant details about that place in response, such as the address components, name, rating, reviews, etc. An invalid Place ID would return an error in response.
The Place Details API is mainly used in the following format:
Find Place API Required Parameters
The Place API only requires one necessary query parameter: the Place ID of the establishment you are searching for. The below image shows the required and a useful optional parameter for this API request along with its syntax.
The ‘place_id‘ parameter is the only required value for this API request. As discussed above, this can be acquired by using the Place Search API. This would be in String format, and the API would return an error in case of an invalid Place ID.
Find Place API Optional Parameters
The ‘fields‘ parameter is also useful as you could limit the size of your JSON response by specifying only the fields you require. These fields include formatted_address, rating, name, opening_hours, photos, etc.
Other optional parameters are also available for this request such as ‘language’, ‘region’, ‘sessiontoken’ etc. For the whole list of supported parameters and other detailed information regarding the Place Details API such as attributes description, response statuses, etc. visit the official link below.
The Response to the above API request would return a list of all attributes mentioned in the field parameter about the place you searched for in JSON format, as stated in the above request. The entire JSON response for the above request is displayed below.
Explore Google Maps APIs: Start Developing Now!
Thus, we conclude another chapter of our deep dive into the vast and resourceful Google Maps APIs. But still, there is plenty more to go. We hope, however, that up till now, you have an ample understanding of the realm we have chosen and have thought of many applications You can devise with the help of our tutorials. We hope today’s tutorial regarding Place Details API was clear and informative for our readers.
In the future, we will focus more on the last major topic of the Google Places API and breeze through the remaining API requests this domain offers. Until next time… .