The Directions API is a web service that uses an HTTP request to return JSON or XML-formatted directions between locations. Directions is available in several forms:
- as a standalone API
- as part of the client-side Maps JavaScript API
- for server-side use as part of the Client Libraries for Google Maps Web Services
What can you do with Directions?
Directions lets you calculate directions between locations.
Why use Directions?
With Directions, you can retrieve more than simple driving directions. You can get directions for several modes of transportation, such as transit, driving, walking, or cycling.
To use Directions 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 want direction calculations that respond in real time to user input (for example, within a user interface element), then use the Directions API. If you're already using the Maps JavaScript API, then use the Directions service to get the Directions API's functionality.
How to use Directions
You can access the Directions API through an HTTP interface, with requests constructed as a URL string. The string contains an origin and a destination. You must also provide your API key with each Directions request.
https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood&key=YOUR_API_KEY
Follow this procedure to use the Directions API.
- If you want to use one of our client libraries instead of the standalone Directions API or the client-side web service, download and install it. Learn about our client libraries.
- Choose or create a project, enable billing, and enable the Directions API. See Set up in the Cloud Console.
- Create and restrict an API key, and add it to your code. See Use an API Key.
- View a Directions request and response and try a sample request.
Recommended content
- Client libraries - use one of our client libraries, which include the functionality of several APIs including the Directions.
- Web service best practices - learn several best practices for using and working with the Directions.
- Release notes - see the release notes for the Directions.
- Quota and billing information - find the billing units and costs for the Directions.
- Policies and restrictions - understand the restrictions on using the Directions.