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)
- 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
The following table summarizes the resources available through the Directions API along with the data it returns.
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.
How to use the Directions API
|Get set up.
|Start with Set up your Google Cloud project and complete the setup instructions that follow.
|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.
|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.
|Understand response basics
|Explore the data responses to prepare to use directions data for your app. See Directions responses for details.
|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:
- Java Client for Google Maps Services
- Python Client for Google Maps Services
- Go Client for Google Maps Services
- Node.js Client for Google Maps Services
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.