Use API Keys  |  Maps Embed API  |  Google for Developers (2024)

New map styling is coming soon to Google Maps Platform. This update to map styling includes a new default color palette and improvements to map experiences and usability. All map styles will be automatically updated in March 2025. For more information on availability and how to opt in earlier, see New map style for Google Maps Platform.

  • Home
  • Products
  • Google Maps Platform
  • Documentation
  • Web
  • Maps Embed API
  • Guides
Stay organized with collections Save and categorize content based on your preferences.

Google Maps Platform products are secured from unauthorized use by restricting API calls to those that provide proper authentication credentials. These credentials are in the form of an API key - a unique alphanumeric string that associates your Google billing account with your project, and with the specific API or SDK.

This guide shows how to create, restrict, and use your API Key for Google Maps Platform.

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.

Create 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

Restrict API keys

Google strongly recommends that you restrict your API keys by limiting their usage to those onlyAPIs needed for your application. Restricting API keys adds security to your application byprotecting it from unwarranted requests. For more information, seeAPI 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 websites that you supply, select HTTP referers (web sites) from the list of Application restrictions.
  2. Specify one or more referrer websites. You can use wildcard characters to authorize all subdomains (for example, https://*.google.com accepts all sites ending in .google.com when accessed over HTTPS). Note that if you specify www.domain.com, it acts as a wildcard www.domain.com/*, and authorizes any subpath on that hostname. Only the https:// and http:// referrer schemes are supported.
  • 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.
    3. If your project uses Places Library, also select Places API. Similarly, if your project uses other services in the JavaScript API (Directions Service, Distance Matrix Service, Elevation Service, and/or Geocoding Service), you must also enable and select the corresponding API in this list.
  • 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="referer"

    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

    Add 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 yourAPI key.

     https://www.google.com/maps/embed/v1/MAP_MODE?key=YOUR_API_KEY&parameters

    Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

    Last updated 2024-06-12 UTC.

    Use API Keys  |  Maps Embed API  |  Google for Developers (2024)

    FAQs

    How do I use API key in Google API? ›

    In the Google Cloud console, go to the APIs & Services > Credentials page. Select the name of the API key you wish to use for your API. In the API restrictions section of the API key detail page, click Restrict key. Select the API that your API key will be used to access from the dropdown list of available APIs.

    Is it OK to expose Google API key? ›

    When you use API keys in your Google Cloud Platform (GCP) applications, take care to keep them secure. Publicly exposing your credentials can result in your account being compromised, which could lead to unexpected charges on your account.

    Do you need API key to embed Google Maps? ›

    You must include an API key with every Maps Embed API request.

    How to get Google Map API key for developer? ›

    Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.

    What is an example of an API key? ›

    String. The API key string is an encrypted string, for example, AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe . When you use an API key to authenticate, you always use the key's string.

    What is the risk of API keys? ›

    They are deemed secret because their exposure to unauthorized individuals or the public could lead to security breaches. If a malicious entity gains access to your secret API key, they could potentially impersonate you, gaining the ability to access or alter your data, functionality, and resources.

    What can people do with your API key? ›

    API keys can identify a project to an API and specify which resources a project may access. However, experts do not consider API keys to be secure enough on their own. This is for a few reasons: API keys can't authenticate the individual user making the request, only the project or application sending the request.

    Is Google API key free or paid? ›

    API Keys is free of charge. If you use Cloud Endpoints to manage your API, you might incur charges at high traffic volumes. For more information, see Endpoints pricing.

    Is Google Embed API free? ›

    All Maps Embed API requests are available at no charge with unlimited usage. However, all requests still require a valid Google Cloud API key.

    Can I use ChatGPT API for free? ›

    When you first sign up for the API, you are on the “free tier.” You can think of this as tier zero as each tier after this one is numbered from one through five. The most important number right now is the usage limits. You cannot spend more than $100 a month when you start out with ChatGPT.

    Is Google map API free for developers? ›

    Pricing for the Maps Embed API

    All Maps Embed API requests are available at no charge with unlimited usage.

    What is the Google API key used for? ›

    API keys are useful for accessing public data anonymously, and are used to associate API requests with the consumer Google Cloud project for quota and billing. API Keys provides you a programmatic interface to create and manage API keys for your project.

    What do I do with my API key? ›

    API keys provide project authorization

    They are generated on the project making the call, and you can restrict their use to an environment such as an IP address range, or an Android or iOS app. By identifying the calling project, you can use API keys to associate usage information with that project.

    Top Articles
    Latest Posts
    Article information

    Author: Fr. Dewey Fisher

    Last Updated:

    Views: 6609

    Rating: 4.1 / 5 (62 voted)

    Reviews: 85% of readers found this page helpful

    Author information

    Name: Fr. Dewey Fisher

    Birthday: 1993-03-26

    Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

    Phone: +5938540192553

    Job: Administration Developer

    Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

    Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.