Google Map API free

This guide shows how to create, restrict, and use your API Key for your Cloud project.

Before you begin

Before you start using the Maps Embed API, you need a project with a billing account and the Maps Embed API enabled. To learn more, see Set up in Cloud Console.

Creating API keys

The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.

To create an API key:

Console

  1. Go to the Google Maps Platform > Credentials page.

    Go to the Credentials page

  2. On the Credentials page, click Create credentials > API key.
    The API key created dialog displays your newly created API key.
  3. 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.)

Cloud SDK

gcloud alpha services api-keys create \ --project "PROJECT" \ --display-name "DISPLAY_NAME"

Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:

  • gcloud alpha services api-keys create

Restricting 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 security best practices.

To restrict an API key:

Console

  1. Go to the Google Maps Platform > Credentials page.

    Go to the Credentials page

  2. Select the API key that you want to set a restriction on. The API key property page appears.
  3. Under Key restrictions, set the following restrictions:
    • Application restrictions:
      1. To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.
      2. 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.

    • API restrictions:
      1. Click Restrict key.
      2. Select Maps Embed API from Select APIs dropdown. If the Maps Embed API is not listed, you need to enable it.
  4. To finalize your changes, click Save.

Cloud SDK

List existing keys.

gcloud services api-keys list --project="PROJECT"

Clear existing restrictions on existing key.

gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \ --clear-restrictions

Set new restrictions on existing key.

gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \ --api_target="maps-embed-backend.googleapis.com" --allowed-referrers="REFERRER

Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:

  • gcloud alpha services api-keys update
  • gcloud alpha services api-keys lookup
  • gcloud services api-keys list

Adding the API key to your request

You must include an API key with every Maps Embed API request. In the following example, replace YOUR_API_KEY with your API key.

https://www.google.com/maps/embed/v1/MAP_MODE?key=YOUR_API_KEY¶meters

For more information about MAP_MODE and parameters options in the code above, see Embedding a map.

Others also read:

  • API key best practices
  • Billing account credits
  • Embed a static street view