Black Friday Sale
Language:

How to use Google Places API and get an API key

If you were looking for a way to start working with Google Places API, here’s a complete guide for you. Today we’re going to find out what exactly this tool does, see some examples, learn how to get an API key and check out the limits and pricing.
Explore Free Widget
Share:
Share on Facebook
Share on X
Share on LinkedIn
Share on WhatsApp
Copy Link
How to use Google Places API and get an API key

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.
Tip: you are to have at least one API key associated with your project.

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. 
Tip: Remember that the Places API does not work with an Android or iOS restricted API key.

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.

Place Search

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”:

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=YOUR_API_KEY

Place Details

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: 

https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJN1t_tDeuEmsRUsoyG83frY4&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY

Place Photos

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:

https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU&key=YOUR_API_KEY

Place Autocomplete

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:

https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=Amoeba&types=establishment&location=37.76999,-122.44696&radius=500&key=YOUR_API_KEY

Query Autocomplete

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:

https://maps.googleapis.com/maps/api/place/queryautocomplete/json?key=YOUR_API_KEY&input=pizza+near%20par
Tip: In order to make all the examples mentioned above work for you, you need to replace the API key with the one you’ve got.

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,000100,001–500,000500,000+
Autocomplete0.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 Autocomplete0.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 Details0.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 Photo0.007 USD per each (7.00 USD per 1000)0.0056 USD per each (5.60 USD per 1000)Contact Sales for volume pricing
Search0.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. 

FAQ

Is Google Places API free service?

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.

How can I use Google Places API?

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.

How can I add or edit places?

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.

How can I start using APIs for my website?

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.

Conclusion

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.

Black Friday Sale
50% OFF
The Biggest Sale of the Year. Don't Miss Out!
Grab The Deal