A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/distancematrix/get-api-key below:

Use API Keys with Distance Matrix API | Distance Matrix API (Legacy)

Use API Keys with Distance Matrix 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 the Distance Matrix API, you need a project with a billing account and the Distance Matrix API enabled. To learn more, see Set 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
  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 services api-keys create \
    --project "PROJECT" \
    --display-name "DISPLAY_NAME"

Read more about the Google 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 only APIs needed for your application. Restricting API keys adds security to your application by protecting it from unwarranted requests. You are financially responsible for charges caused by abuse of unrestricted API keys. For more information, see API security best practices.

When restricting an API key in the Cloud console, Application restrictions override any APIs enabled under API restrictions. Follow best practices by creating a separate API key for each app, and for each platform on which that app is available.

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:
  4. 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 services api-keys update "projects/PROJECT/keys/KEY_ID" \
    --clear-restrictions

Set new restrictions on existing key.

gcloud services api-keys update projects/PROJECT/locations/global/keys/KEY_ID \
    --api-target=service=distance-matrix-backend.googleapis.com
    --allowed-ips="IP_ADDRESS"

Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:

Adding the API key to your request

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

https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&key=YOUR_API_KEY

HTTPS is required for requests that use an API key.

Note: When using Web Services, all special characters inside the parameters must be URL encoded. URLs must be properly encoded to be valid and are limited to 2048 characters for all web services. Be aware of this limit when constructing your URLs. Different browsers, proxies, and servers may have different URL character limits as well.

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 2025-07-09 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-09 UTC."],[[["Google Maps Platform secures its products by requiring API keys for authentication and billing purposes."],["You can create and restrict API keys through the Google Cloud Console or the Cloud SDK."],["Restricting API keys enhances security by limiting their usage to specific applications and IP addresses."],["API keys must be included in every Distance Matrix API request using HTTPS."],["When constructing URLs for web services, special characters need to be URL encoded and the total length should not exceed 2048 characters."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4