January 5, 2020

Google Maps Platform - API Keys


To access any API that is available in Google Maps Platform you would need to follow the steps as mentioned below:

  1. Register with Google to access Google Cloud Console
  2. Create a Project in Google Cloud Console
  3. Enable Billing for the Project
  4. Enable the API that you want to work upon (For ex: Directions, Geocoding etc.)
  5. An API Key to access the API
  6. Restrict API (Optional)

Account with Google

To get access to Google Cloud Platform you can use your existing Gmail account. If you do not have a Gmail account you can visit Google Cloud Platform and sign up. If you are a part of an organisation you should ask your project manager or a person assigned to provide access to users using IAM (Identity and Access Management).

Project in Google Cloud

Login to Google Cloud Console and create a project which will be used for accessing the Google Maps Platform APIs. If this is your first time on Google Cloud Platform you will be prompted to provide your basic details on a screen like below:

Google Maps Platform - API Keys

Google Maps Platform - API Keys

However, if you already have a project and want to create a new one, choose the dropdown as highlighted in the below picture:

Google Maps Platform - API Keys

and then click on New Project.

Google Maps Platform - API Keys

You should fill out all the details about your New Project here:

Google Maps Platform - API Keys

Enable Billing

It is mandatory to have the billing enabled for the project to access any of the APIs available in Google Maps Platform. To enable billing you will have to provide your basic information and card details. However, you will be only billed once you upgrade to a paid plan.

Google Maps Platform - API Keys

Google Maps Platform - API Keys

Enable API

To enable an API, go to Google Maps under Menu and select Overview.


Google Maps Platform - API Keys

You will see a list of available APIs.


Google Maps Platform - API Keys

Choose any one of them which you would want to enable. Click on Enable. This page holds very useful links regarding Price/request, how to access the API and limitations applicable. It would be worth checking out the links provided on this page.


Google Maps Platform - API Keys

You are now one step away to access the API. All you need is an API Key.


Get API Key

To create an API Key, go to API & Services -> Credentials.


Google Maps Platform - API Keys

Click on Create Credentials to generate a new API Key.


Google Maps Platform - API Keys

This is how an API Key looks like.


Google Maps Platform - API Keys

Restrict API Key

It is recommended to restrict your API key to what you actually need it for. There are two types of restrictions you can apply here:

  1. Application restrictions
    • HTTP referrers (web sites) - To restrict the Key to a particular URL. http and https are considered separately. Make sure you add 2 URLs, one for http and another for https. It also supports wildcards. For eg.,
      • http://www.example.com/path
      • https://www.example.com/path
      • https://*.example.com/*
    • IP addresses (web servers, cron jobs, etc.) - Accepts requests from mentioned IP addresses only
    • Android apps - Restrict only to Android apps. You will have to provide
      • Package Name
      • SHA1 certificate fingerprint
    • iOS apps- Restrict only to IOS apps. You will have to provide the Bundle Identifier
  2. API restrictions - Choose the specific API you want this key to work for