int(15)
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

https://maps.googleapis.com/maps/api/directions

Directions API Required Request Params

It takes one required route and THREE query parameters.

Required Route Parameter

namedescription
JSON or XMLOutput format (json recommended)

Required Query Parameters

namedescription
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:
origins=123+Slater+Street+ON
origins=41.43206,-81.38992
origin=place_id:r345UTjjf(&*(*ljh*&
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

https://maps.googleapis.com/maps/api/directions/json?origin=place_id:ChIJgUbEo8cfqokR5lP9_Wh_DaM&key=[YOUR_API_KEY]
&destination=place_id:ChIJgUbEo8cfqokR5lP9_Wh_DaM

Response Object

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

Next Previous