Distance Matrix API overview

Stay organized with collections Save and categorize content based on your preferences.

The Distance Matrix API provides travel distance and time for a matrix of origins and destinations, and consists of rows containing duration and distance values for each pair. Distance Matrix is available in several forms:

What can you do with the Distance Matrix API?

The API returns information based on the recommended route between start and end points. You can request distance data for different travel modes, request distance data in different units such kilometers or miles, and estimate travel time in traffic.

For more examples, see the Distance Matrix API developer guide, which provides an introduction to using the API and reference material on the available parameters.

Why use Distance Matrix?

Use the Distance Matrix API when your solution requires distance and travel time between a large list of origin-destination points.

If you want to use Distance Matrix functionality and get serialization of requests and deserialization of responses, automatic retries, and some client validation of requests, try one of our client libraries. If you're already using the Maps JavaScript API, use the Distance Matrix service to get the Distance Matrix API's functionality.

How to use Distance Matrix

Access the Distance Matrix API through an HTTP interface, with requests constructed as a URL string, passing origins and destinations, along with your API key.

  1. If you want to use one of our client libraries instead of the standalone Distance Matrix API or the client-side web service, download and install it. Learn about our client libraries.
  2. Choose or create a project, enable billing, and enable the Distance Matrix API. See Set up in the Cloud Console.
  3. Create and restrict an API key, and add it to your code. See Use an API Key.
  4. View a Distance Matrix request and response and try a sample request.

Recommended content

From our Terms of Service

Innovate, but don't
duplicate

Don't make a substitute for Google Maps. If your app's primary purpose is navigation, a business directory, or a general purpose "maps app", it's a substitute for Google Maps.

Learn more