It's the 15th anniversary of Google Maps Platform - Check out the latest news and announcements

Get an API Key

Before you begin

Before you start using the Geocoding API, you need a project with a billing account and the Geocoding API enabled. To learn more, see Get Started with Google Maps Platform.

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:

  1. In the GCP Console, on the project selector page, select or create a Google Cloud project for which you want to add an API Key.

    Go to the project selector page

  2. Go to the APIs & Services > Credentials page.

    Go to the Credentials page

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

Adding the API key to your request

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

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

Restricting API keys

We strongly recommend that you restrict your API key. Restrictions provide added security and help ensure only authorized requests are made with your API key. There are two restrictions. You should set both:

  • Application restriction: Limits usage of the API key to either websites (HTTP referrers), web servers (IP addresses), or mobile apps (Android apps or iOS apps). You can select only one restriction from this category, based on the platform of the API or SDK (see GMP APIs by Platform).

    Note: If you need to call web, web service, and/or mobile APIs from the same (client-side) app, create and restrict multiple keys.

  • API restriction: Limits usage of the API key to one or more APIs or SDKs. Requests to an API or SDK associated with the API key will be processed. Requests to an API or SDK not associated with the API key will fail. (The API or SDK must be enabled and must support the application restriction.)

To restrict an API key:

  1. Go to the Google Cloud Platform Console.
  2. Click the project drop-down and select the project that contains the API key you want to secure.
  3. Click the menu button and select APIs & Services > Credentials.
  4. On the Credentials page, click the name of the API key that you want to secure.
  5. On the Restrict and rename API key page, set the restrictions:
    • Application restrictions
      • Select IP addresses (web servers, cron jobs, etc.).
      • Add the server IP addresses.
    • API restrictions
      • Select Restrict key.
      • Click Select APIs and select Geocoding API.
        (If the Geocoding API is not listed, you need to enable it.)
    • Click SAVE.

Troubleshooting authentication issues

If your request is malformed or supplies an invalid signature, the Geocoding API returns an HTTP 403 (Forbidden) error.

To troubleshoot individual URLs, you can use the URL Signing Debugger. It allows you to quickly validate a URL and signature generated by your application.

Premium Plan Customers and Migrated Customers

Premium Plan customers and customers who have migrated from the Premium Plan to the Google Maps Platform pay-as-you-go pricing model have the option to use an API key or a client ID to authenticate requests. For more information see Get API Keys Overview in the Premium Plan documentation.