How to get Google Maps API key

You have to get a Google Maps API key to use maps on your site. This process will take a little of your time, just follow the instructions below.

If you are a beginner and have never worked Google Cloud before, you will read and accept the Google Cloud Platform Terms of Service and any applicable services and APIs

STEP 1

Everything is ready to begin the process of getting the Google Maps API key. Go to the APIs & Services > Credentials page.

STEP 2

Click + Create Project button to create a new Google Cloud Project. Go to Step 4, if you have already created a project.

Create a New Project
Create a New Project

Set a unique name for your project, or use default project name. And click the Create button. Please note that the name of the project cannot be changed later.

Create a new project
Create a new project
STEP 3

After creating the project visit Project Dashboard page.

Select your project
Select your project
step 4
  1. Go to the Credentials page, click Create credentials > API key.
Credentials settings
step 5

The API key created dialog displays your newly created API key.

The window with API key created
step 6

Click Close.

The new API key is listed on the Credentials page under API keys.
(Remember to restrict the API key before using it in production.)

Restricting your API keys

Restricting API Keys adds security to your application by ensuring only authorized requests are made with your API Key. We strongly recommend that you follow the instructions to set restrictions for your API Keys. For more information, see API Key best practices.

To restrict an API key:

step 1

Go to the APIs & Services > Credentials page.

step 2

Select the API key that you want to set a restriction on. The API key property page appears.

step 3

Under Key restrictions, set the following restrictions for Application restrictions:

  • To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.
  • Specify one or more referrer web sites. For example, *.google.com accepts all sites ending in google.com, such as https://developers.google.com

Note: file:// referers need a special representation to be added to the key restriction. The “file://” part should be replaced with “__file_url__” before being added to the key restriction. For example, “file:///path/to/” should be formatted as “__file_url__//path/to/*”. After enabling file:// referers, it is recommended you regularly check your usage, to make sure it matches your expectations.

Application restrictions settings
step 4

Under Key restrictions, set the following restrictions for API restrictions:

  • Click Restrict key
  • Select Maps JavaScript API from Select APIs dropdown. If the Maps JavaScript API is not listed, you need to enable it.
API restrictions selection
step 5

Click Save for the changes to take effect.

Was this article helpful to you?