Next Previous

Directions API – HTTP Interface

Directions API is a web service that calculates directions between locations.

Let’s see how to make an HTTP request to Directions API via HTTP Interface.

Directions API Base URL

Directions API Required Request Params

It takes one required route and THREE query parameters.

Required Route Parameter

JSON or XMLOutput format (json recommended)

Required Query Parameters

originThe value of the origin parameter can be one of 3 formats which are plain street address, geographic coordinates (latitude and longitude separated by a comma with no space in between) or the place_id.

This will be the starting point for calculating the directions between locations.

For Example:
destinationThe value of the destination parameter can be one of the three formats similar to origin.
This will be the ending point for calculating directions between locations.
keyYour API Key from Google Cloud Console.

Unlike DirectionsService Request, the travelMode query param is not required and by default it is set to DRIVING mode.

Sample Request URL[YOUR_API_KEY]

Response Object

Once the request is complete and everything goes well, you’ll get an output object in JSON format like this:

Next Previous