To use the Google Maps Roads API, you must register your app project on the Google API Console and get a Google API key which you can add to your app or website.
Quick guide to getting a key
Step 1: Get an API Key from the Google API Console
Click the button below, which guides you through the process of registering a project in the Google API Console, activates the Google Maps Roads API automatically, and generates a generic, unrestricted API key.
Get a KeyNotes:
- Tip: During development and testing, you can register a project for testing purposes in the Google API Console and use a generic, unrestricted API key. When you are ready to move your app or website into production, register a separate project for production, create a server-restricted API key, and add the key to your application.
- Premium Plan customers: For production-ready apps, you must use a server-restricted API key that is set up in the Google Maps APIs Premium Plan project created for you when you purchased the Premium Plan.
- For more information, see the detailed guides below for Standard Plan and Premium Plan customers.
Step 2: Add the API key to your application
When loading the Google Maps Roads API, substitute YOUR_API_KEY in the code below with the
API key you got from the previous step.
https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907|-35.28099,149.12929|-35.28144,149.12984|-35.28194,149.13003|-35.28282,149.12956|-35.28302,149.12881|-35.28473,149.12836
&interpolate=true
&key=YOUR_API_KEY
More about API keys
- The API key allows you to monitor your application's API usage in the Google API Console. See Google API Console help for more information.
- If you are a Standard Plan customer, with an API key you have access to generous free daily quota, as well as the option to increase your daily quota by enabling pay-as-you-go billing.
- If you are a Premium Plan customer, you must use an API key to access all the custom features and benefits of your Premium Plan.
- Registering for an API key ensures that Google can contact you about your application if necessary.
Detailed guide for users of the standard Google Maps Roads API
Follow these steps to get an API key:
- Go to the Google API Console.
- Create or select a project.
- Click Continue to enable the API.
-
On the Credentials page, get an API key.
Note: If you have an existing unrestricted API key, or a key with server restrictions, you may use that key. - From the dialog displaying the API key, select Restrict key to set a server restriction on the API key.
- In the Key restriction section, select IP addresses (web servers, cron jobs, etc.), follow the on-screen instructions to add server IP addresses, then click Save. Read more about restricting API keys.
- (Optional) Enable billing. See Usage Limits for more information.
In the Google API Console, you can also
look up an existing key or
view a list of enabled APIs.
For more information on using the Google API Console, see API Console Help.
Detailed guide for users of the Google Maps APIs Premium Plan license
When using the Google Maps Roads 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:
- Manage all of your APIs in the Google API Console.
- Access real-time usage data and 30 days of historical usage data for your application in the Google API Console.
- View usage reports with more than 30 days of data in the Google Cloud Support Portal.
Get more information on reports available to Premium Plan customers.
Follow these steps to get an API key:
- Go to the Google API Console.
- 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.
- Click Continue.
-
On the Credentials page, get an API key.
Note: If you have an existing unrestricted API key, or a key with server restrictions, you may use that key. - From the dialog displaying the API key, select Restrict key to set a server restriction on the API key.
- In the Key restriction section, select IP addresses (web servers, cron jobs, etc.), follow the on-screen instructions to add server IP addresses, then click Save. Read more about restricting API keys.
You can also look up an existing key in the Google API Console.
For more information on using the Google API Console, see API Console Help.
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 a generic (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 Google Maps Roads API use the IP addresses (web servers, cron jobs, etc.) key restriction. Learn more about keys and credentials.
To add server restrictions to an existing, generic API key, do the following:
- Go to the Credentials page of the Google API Console.
- Select the project that contains the API key you want to edit.
- On the Credentials page, from the list of API keys, select the name of the API key to edit the details of the key.
- In the Key restriction section of the page, select IP addresses (web servers, cron jobs, etc.), follow the on-screen instructions to add server IP addresses, then click Save.
