JustSERPDocs
Google

Google Maps Directions

The routes between two places, with the time each travel mode takes, answered as the document: `search_metadata`, `search_parameters` (the request as read, with the defaults), `search_information` (`{}`), `travel_modes`, `places_info` and `directions`.

GET
/v1/google/maps/directions

The routes between two places, with the time each travel mode takes, answered as the document: search_metadata, search_parameters (the request as read, with the defaults), search_information ({}), travel_modes, places_info and directions. Durations are seconds and distances meters. A transit route has a time_window and rides between walks; a flying one has the departure, arrival, price and airlines. Places Google cannot find are a 200 with directions: [] and a null address in places_info. Not answered: the route's geometry and the traffic bars; transit preferences (prefer, and route other than best) are a 400. Failures: timeout when the page never named its route request, blocked when the response was not Maps' data.

Authorization

headerX-API-Key<token>

Your API key.

Query Parameters

cancel_token?string

A name you make up for this request (a UUID is fine), so you can later GET /v1/cancel with it. Only you know it, so only you can cancel. Use a new one for every request, retries included: a cancelled token stays cancelled for a few minutes.

Length1 <= length <= 128
from*string

An address, lat,lng, or a data id (0x...:0x...).

Lengthlength <= 300
to*string

The same forms as from.

Lengthlength <= 300
waypoints?array<string>

Up to 8 stops in order. Not with transit or time.

Itemsitems <= 8
travel_mode?string

best is driving, transit and flying, one route of each.

Default"best"
Value in"best""driving""cycling""walking""transit""flying"
time?string

depart_at:<unix seconds> or arrive_by:<unix seconds>. Not with waypoints; last_available is not supported.

Match^(depart_at|arrive_by):[0-9]+$
avoid?array<>

tolls and highways for driving and best; ferries for walking and cycling. A value the mode does not take is a 400.

distance_units?string

Not with transit or flying. automatic is by country.

Default"automatic"
Value in"automatic""km""mi"
route?string

Transit preference; only best is accepted.

prefer?stringDeprecated

Transit preference: not supported, a 400.

gl?string

Country.

Default"us"
hl?string

Language.

Default"en"

Response Body

The routes, as the document. When the page could not be parsed, the usual envelope.

application/json
  1. response

The first three keys of every parsed 200 (the answer is the document itself, no success/data envelope): what the search was (search_metadata), what it asked (search_parameters), the parser's own search_information ({} when it has none). The engine's blocks follow, at the same level. An engine whose answer is a list puts it under results.

search_metadata*
search_parameters*

The request's own fields as sent, engine first, without cancel_token.

search_information*

The parser's own, e.g. yelp_search's; otherwise {}.

travel_modes?array<>
places_info?array<>
directions?array<>
[key: string]?any
Example Request
curl -X GET 'https://api.justserp.com/v1/google/maps/directions?from=New+York&to=Chicago%2C+Illinois&travel_mode=driving'
Example Response
{  "search_metadata": {    "id": "string",    "status": "Success",    "created_at": "string",    "request_url": "string",    "html_url": "string"  },  "search_parameters": {},  "search_information": {},  "travel_modes": [    {      "travel_mode": "string",      "formatted_duration": "string",      "duration": 0    }  ],  "places_info": [    {      "address": "string",      "data_id": "string",      "coordinates": {        "latitude": 0,        "longitude": 0      }    }  ],  "directions": [    {      "travel_mode": "string",      "via": "string",      "formatted_duration": "string",      "duration": 0,      "distance": 0,      "formatted_typical_duration": "string",      "optimistic_duration": 0,      "pessimistic_duration": 0,      "formatted_distance": "string",      "warnings": [        "string"      ],      "time_window": {},      "instructions": [        {          "travel_mode": "string",          "action": "string",          "information": "string",          "formatted_duration": "string",          "formatted_distance": "string",          "duration": 0,          "distance": 0,          "latitude": 0,          "longitude": 0,          "details": [            {              "travel_mode": "string",              "action": "string",              "information": "string",              "formatted_duration": "string",              "formatted_distance": "string",              "duration": 0,              "distance": 0,              "latitude": 0,              "longitude": 0            }          ],          "walking": {},          "depart_from": {            "place": "string",            "at": "string",            "timezone": "string",            "latitude": 0,            "longitude": 0          },          "direction": "string",          "vehicle": "string",          "line_name": "string",          "arrive_at": {            "place": "string",            "at": "string",            "timezone": "string",            "latitude": 0,            "longitude": 0          },          "service_provider": "string",          "stops": [            {}          ]        }      ],      "departure": "string",      "arrival": "string",      "formatted_price": "string",      "price": 0,      "airlines": [        "string"      ],      "flights_link": "string"    }  ]}