Directions API overview

The Directions API is a service that accepts an HTTP request and returns JSON or XML-formatted directions between locations.

Why use the Directions API

With the Directions API, you can get directions for several modes of transportation, such as transit, driving, walking, or bicycling.

What you can do with the Directions API?

With the Directions API, you can calculate directions between locations, including the following details:

  • Directions for several modes of transportation, including transit, driving, walking or bicycling.
  • Multipart directions using a series of waypoints.
  • Specify origins, destinations, and waypoints in multiple ways, including as text strings (for example, "Chicago, IL" or "Darwin, NT, Australia"), place IDs, or latitude/longitude coordinates.

How the Directions API works

The Directions API returns the most efficient routes when calculating directions. The product factors in the following travel elements when determining the most efficient route:

  • Travel time (primary)
  • Distance
  • Number of turns

The following example request returns driving directions from Toronto, Ontario to Montreal, Quebec in JSON format:

https://maps.googleapis.com/maps/api/directions/json
  ?destination=Montreal
  &origin=Toronto
  &key=YOUR_API_KEY

Resources

The following table summarizes the resources available through the Directions API along with the data it returns.

Data resources Data returned Return format
Directions

Supply origins and destinations in the form of place IDs, addresses, or latitude/longitude coordinates. See required parameters for details.

Detailed directions, broken into routes, legs, and steps. See Directions responses for details.
  • JSON
  • XML

How to use the Directions API

1 Get set up. Start with Set up your Google Cloud project and complete the setup instructions that follow.
2 Try the demo Once you have an API key and a cloud project you try out the directions demo at no charge. See The Directions API demo.
3 Build a request See the example requests and learn about the available options you can supply, such as travel modes, waypoints, and route restrictions. See Directions examples.
4 Understand response basics Explore the data responses to prepare to use directions data for your app. See Directions responses for details.
5 Incorporate direction data into your own app! You can use this data to calculate travel distance and time.

Available client libraries

Call this API in the language of your choice through one of the following client libraries:

The Java Client, Python Client, Go Client and Node.js Client for Google Maps Services are community-supported client libraries, open sourced under the Apache 2.0 License. Download them from GitHub, where you can also find installation instructions and sample code.

What's next