What is Google Places API
Places API is a service that returns information about places using HTTP requests. Places here are usually defined within this API as establishments, geographic locations, or prominent points of interest.
There are five types of requests available within the API. They are:
- Place Search which returns a list of places based on a user’s location or search string.
- Place details that gives a detailed info about a specific place, with user reviews included.
- Place photos grants access to the millions of place-related photos kept in Google’s Place database.
- Place reviews lets reach and embed Google reviews from the platform.
- Place Autocomplete is there to automatically fill in the name or address of a place as users type.
- Query Autocomplete gives a query prediction service for text-based geographic searches, returning suggested queries as users type.
To work with places API you need a key that should be included with every Places API request. Let’s find out what it is exactly and how to get the API key for Google Places API.
How to create a Google Places API key
The API key is a unique identifier that is there to authenticate requests which are associated with your project for usage and billing purposes. By using an API key to authenticate requests, you can:
- Manage your APIs in Google Cloud Console.
- Access real-time usage data and 30 days of 30 days of historical usage data in the Google Cloud Platform Console.
- Observe usage reports with more than 30 days of info in the Google Cloud Support Portal.
You can find more information on reports available to Premium Plan customers here. Now you can proceed to getting the key.
You are always free to try an alternative way of adding customer reviews to your website. For example, there’s Google Reviews widget by Elfsight – you don’t need to bother about getting API keys or learn coding.
Get your Places API key and add it to your request
To get your API key, you need to perform following actions:
- Open Google Cloud Platform Console.
- Click on the project drop-down list and pick the project created for you. Its name should start with Google Maps APIs for Business or Google Maps for Work or Google Maps.
- Then click the menu button and choose APIs & Services > Credentials.
- On the Credentials page, pick Create credentials > API key. There you’ll see an API key created dialog demonstrating your newly created key.
- Close the tab. Your new API key is listed on the credentials page under the API keys section.
Then you have to add the API key to every Places API request. Using the following example, simply replace YOUR_API_KEY with your API key:
https://maps.googleapis.com/maps/api/place/nearbysearch/json ?location=-33.8670522,151.1957362 &radius=500 &types=food &name=harbour &key=YOUR_API_KEY
Keep in mind that Google strongly recommends that you are to restrict your API key. The restrictions grant added security and help ensure only authorized requests are made with your API key.
How to restrict your Google Places API key
There are two restrictions and you have to set up both. They are:
- Application restriction. This feature allows you to limit the usage of the API key to either websites, web servers, or mobile apps. There’s only one restriction from this category that can be chosen.
- API restriction. This type of restriction limits usage of the API key to one of more APIs or SDKs.
To restrict your API key you need to:
- Open the Google Cloud Console.
- Click the project drop-down list and pick the project containing the API key you want to secure.
- Click the menu button and choose the APIs & Services > Credentials.
- Click the name of the API key you need to secure on the Credentials page.
- Set the restrictions on the Restrict and rename API key page.
After the restrictions are set, all is left is simply click the Save button.
Using Google Places API: examples
There are several ways to use Google Places API. Let’s see some of them.
As it was mentioned above, Places API lets you search for place information using a huge number of categories. The following Google Places API example demonstrates a Find Place request for “Museum of Contemporary Art Australia”:
Once you get a place_id from a Google Places Search, you are free to more information about a particular establishment or point of interest by initiating a Place Details request. Here we can see a request of details of a place by place_id:
This service allows you to add photo content to you applications.It gives access to millions of photos that are stored in the Places database. Here’s an example request:
It’s a web service that returns place predictions as a response for an HTTP request. It can be used to provide autocomplete functionality for text-based geographic searches. Here’s an example of a request for establishments:
This type of service is used for providing a query prediction for text-based geographic searches, by returning suggested queries as a user types. An example request looks like this:
Google Places API pricing and limits
Here Google uses a pay-as-you-go pricing model. This means The Google Maps Platform APIs are billed by SKU. The usage is tracked for each Product SKU, and an API may have more than one Product SKU.
There are 1,000 free Places API lookups per 24 hours but you can increase them to 150,000 free lookups for 24 hours by Enabling Billing in Google Cloud Console.
|Monthly volume range (Price per CALL)||0–100,000||100,001–500,000||500,000+|
|Autocomplete||0.00283 USD per each (2.83 USD per 1000)||0.00227 USD per each (2.27 USD per 1000)||Contact Sales for volume pricing|
|Query Autocomplete||0.00283 USD per each (2.83 USD per 1000)||0.00227 USD per each (2.27 USD per 1000)||Contact Sales for volume pricing|
|Places Details||0.017 USD per each (17.00 USD per 1000)||0.0136 USD per each (13.60 USD per 1000)||Contact Sales for volume pricing|
|Places Photo||0.007 USD per each (7.00 USD per 1000)||0.0056 USD per each (5.60 USD per 1000)||Contact Sales for volume pricing|
|Search||0.032 USD per each (32.00 USD per 1000)||0.0256 USD per each (25.60 USD per 1000)||Contact Sales for volume pricing|
You can check up Google Place API documentation to find more details on all the prices and limits.
Places API uses a pay-as-you-go pricing model. To get more details on the prices see the table above or check the documentation.
To make it possible, you need to get an API key. You can do it via your Cloud Console by clicking on the project drop-down list and picking the project created for you.
If you’re an owner of the business, you are free to do it on Google Maps using Google My Business. If you do not own the place you want to edit, you can still suggest changes.
First, you need to come up with the understanding of which API exactly you need. Look through the Overview, Developer, and Get Started guides for the specific API or SDK you are interested in.
Now you have an understanding of the getting Google Maps Places API key process. As you may have noticed it’s very simple and actually requires not more than 5 minutes. The only thing you should now before the beginning is the the type of API you are planning to work with.