Use API Keys with Roads API 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 theRoads API, you need a project with a billing account and theRoads API enabled. To learn more, seeSet 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
Go to theGoogle Maps Platform > Credentials page.
- On theCredentials page, clickCreate credentials > API key.
TheAPI key created dialog displays your newly created API key. - ClickClose.
The new API key is listed on theCredentials page underAPI keys.
(Remember torestrict the API key before using it in production.)
Cloud SDK
gcloudservicesapi-keyscreate\--project"PROJECT"\--display-name"DISPLAY_NAME"
Read more about theGoogle Cloud SDK ,Cloud SDK installation , and the following commands:
Restricting 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.You are financially responsible for charges caused by abuse of unrestricted API keys. For more information, seeAPI security best practices.When restricting an API key in the Cloud console,Application restrictions override any APIs enabled underAPI restrictions.Follow best practices by creating a separate API key for each app, and for each platformon which that app is available. To restrict an API key: Go to theGoogle Maps Platform > Credentials page. List existing keys. Clear existing restrictions on existing key. Set new restrictions on existing key. Read more about theGoogle Cloud SDK ,Cloud SDK installation , and the following commands: You must include an API key with everyRoads API request. In the following example, replace HTTPS is required for requests that use an API key.Console
Cloud SDK
gcloudservicesapi-keyslist--project="PROJECT"
gcloudservicesapi-keysupdate"projects/PROJECT/keys/KEY_ID"\--clear-restrictions
gcloudservicesapi-keysupdateprojects/PROJECT/locations/global/keys/KEY_ID\--api-target=service=roads.googleapis.com--allowed-ips="IP_ADDRESS"
Adding the API key to your request
YOUR_API_KEY
with your API key.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
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-02 UTC.