New pricing changes went into effect on July 16, 2018. For more information, check out the Guide for Existing Users.

Get API Key

To use the Geolocation API, you must get an API key which you can then add to your app or website. The API key is used to track API requests associated with your project for quota, usage, and billing. To learn more about API keys, see the API Key Best Practices and the FAQs.

Billing

To use the Geolocation API, you must enable billing. You can enable billing separately (see Usage and Billing) or when you get your API key (see the Quick guide).

Console

You will use the Google Cloud Platform Console to manage projects, get API keys, and set up API key restrictions. For more information about the console, see Google Cloud Platform Console Help.

Quick guide

Step 1: Get an API key

Click the button below, to get an API key using the Google Cloud Platform Console. You will be asked to (1) pick one or more products, (2) select or create a project, and (3) set up a billing account. Once your API key is created you will be prompted to restrict the key's usage. For more information, see Restricting an API key.

Get Started

Step 2: Add the API key to your app

When loading the Geolocation API, substitute YOUR_API_KEY in the code below with the API key you got from the previous step.

https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY

Detailed guide

Follow these steps to get an API key and set up restrictions:

  1. Go to the Google Cloud Platform Console.
  2. Select the project for which you want to add an API key.
  3. Go to the Credentials page.
    (From the Navigation menu click APIs & Services > Credentials.)
  4. Click Create credentials > API key.
  5. The API key created dialog displays your newly created API key.
    • Click Restrict Key. (If you click Close, you can still set up restrictions later.)
  6. On the API key page, under Key restrictions, set the Application restrictions.
    • Select IP addresses (web servers, cron jobs, etc.).
    • Add the server IP addresses (see the examples).
    • Click Save. For more information, see Restricting an API key

Detailed guide for Premium Plan customers

When using the Geolocation API with a Google Maps APIs Premium Plan license, you must authenticate your application with an API key.

By using an API key to authenticate your applications, you can:

Get more information on reports available to Premium Plan customers.

Follow these steps to get an API key and set up restrictions:

  1. Go to the Google Cloud Platform Console.
  2. From the Project drop-down menu, select the project created for you when you purchased the Premium Plan. The project name starts with Google Maps APIs for Business or Google Maps for Work or Google Maps.
  3. Click Continue.
  4. Go to the Credentials page.
    (From the Navigation menu click APIs & Services > Credentials.)
  5. Click Create credentials > API key.
  6. The API key created dialog displays your newly created API key.
    • Click Restrict Key. (If you click Close, you can still set up restrictions later.)
  7. On the API key page, under Key restrictions, set the Application restrictions.
    • Select IP addresses (web servers, cron jobs, etc.).
    • Add the server IP addresses (see the examples).
    • Click Save. For more information, see Restricting an API key

Restricting an API key

Google Maps APIs are available via HTTP web services, for web browsers, and Android or iOS apps. APIs in any platform can use an unrestricted API key. You can optionally add a restriction (for example, IP addresses) to the API key. Once restricted, a key will only work on platforms that support that type of restriction.

Tip: Before moving your app or website to production, you should secure your API key. Keys for the Geolocation API use the IP addresses (web servers, cron jobs, etc.) key restriction. Learn more about keys and credentials.

To set up restrictions for an existing API key, do the following:

  1. Go to the Google Cloud Platform Console.
  2. Select the project that contains the API key you want to edit.
  3. Go to the Credentials page.
    (From the Navigation menu click APIs & Services > Credentials.)
  4. Under API keys, click the name of the API key you want to edit.
  5. On the API key page, under Key restrictions, set the Application restrictions.
    • Select IP addresses (web servers, cron jobs, etc.).
    • Add the server IP addresses (see the examples).
    • Click Save.

Send feedback about...

Geolocation API
Need help? Visit our support page.