/google-maps-directions

Returns directions between two points from Google Maps.

↗ Open in API Explorer
GET

Google Directions

Returns directions between two points from Google Maps.

Request

Endpoint: GET https://api.outscraper.cloud/google-maps-directions

Parameters

NameInTypeRequiredDescriptionExampleConstraints
origin query array<string> Yes The parameter defines the origin. You can use anything that you would use on Google Maps directions (e.g., Lincoln Way & 19th Ave, San Francisco, USA). It supports batching by sending arrays with up to 1000 origins. It allows multiple directions to be sent in one request and save on network latency time. - -
destination query array<string> Yes The parameter defines the destination. You can use anything that you would use on Google Maps directions (e.g., 19th Ave & Taraval St, San Francisco, USA). It supports batching by sending arrays with up to 1000 destinations. It allows multiple directions to be sent in one request and save on network latency time. - -
departure_time query integer No The parameter specifies the departure timestamp. The current timestamp is used when the value is not provided. - -
finish_time query integer No The parameter specifies the end departure timestamp. Using this parameter requires using the interval parameter. - -
interval query integer No The parameter specifies the interval to use between departure_time and finish_time. - -
travel_mode query string enum No Tne parameter specifies one of the travel modes. - default best, allowed best, car, transit, walk, bike, flight
language query string enum No The parameter specifies the language to use for website. - default en, allowed en, de, es, es-419, fr, hr, it, nl, …
region query string enum No The parameter specifies the country to use for website. It's recommended to use it for a better search experience. - allowed AF, AL, DZ, AS, AD, AO, AI, AG, …
fields query string No The parameter defines which fields you want to include with each item returned in the response. By default, it returns all fields. Use &fields=query,name to return only the specific ones. - -
async query boolean Yes The parameter defines the way you want to submit your task to Outscraper. It can be set to false to open an HTTP connection and keep it open until you got your results, or true (default) to just submit your requests to Outscraper and retrieve them later (usually within 1-3 minutes) with the Request Results endpoint. Each response is available for 4 hours after a request has been completed. A good practice is to send async requests and start checking the results after the estimated execution time. Check out this Python implementation as an example. As most of the requests take some time to be executed the async=true option is preferred to avoid HTTP requests timeouts. - default true
ui query boolean No The parameter defines whether a task will be executed as a UI task. This is commonly used when you want to create a regular platform task with API. Using this parameter overwrites the async parameter to true. - default false
format query array<string enum> No The parameter defines the format of the output data. Using this parameter overwrites the ui parameter to true. - -
webhook query string No The parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations. - -

Responses

200

application/json

The response contains the status of the request and data.

{
  "id": "your-request-id",
  "status": "Success",
  "data": [
    [
      {
        "road": "I-94 W",
        "distance(meters)": 156550,
        "distance_label": "97.3 miles",
        "duration(minutes)": 100,
        "duration_min(minutes)": 90,
        "duration_max(minutes)": 120,
        "origin_coordinates": "41.513124399999995, -87.92831819999999",
        "road_distance_timing(meters:seconds)": {
          "0": 0,
          "30": 10,
          "94": 47,
          "111": 49,
          "156325": 5885,
          "156376": 5891,
          "156461": 5898,
          "156552": 5905
        },
        "origin": "Lincoln-Way Central High School, Southwest Suburbs, 1801 E Lincoln Hwy, New Lenox, IL 60451",
        "destination": "18th St and 19th Ave, Kenosha, WI 53140",
        "destination_coordinates": "42.624320999999995, -87.83267",
        "query_origin": "Lincoln Way ",
        "query_destination": "19th Ave ",
        "timestamp": 1598288400,
        "datetime_utc": "08/24/2020 17:00:00"
      },
      {
        "road": "I-355 N",
        "distance(meters)": 183183,
        "distance_label": "114 miles",
        "duration(minutes)": 150,
        "duration_min(minutes)": 130,
        "duration_max(minutes)": 200,
        "origin_coordinates": "41.513124399999995, -87.92831819999999",
        "road_distance_timing(meters:seconds)": {
          "0": 0,
          "30": 10,
          "94": 47,
          "111": 48,
          "182961": 8972,
          "183015": 8978,
          "183103": 8985,
          "183187": 8991
        },
        "origin": "Lincoln-Way Central High School, Southwest Suburbs, 1801 E Lincoln Hwy, New Lenox, IL 60451",
        "destination": "18th St and 19th Ave, Kenosha, WI 53140",
        "destination_coordinates": "42.624320999999995, -87.83267",
        "query_origin": "Lincoln Way ",
        "query_destination": "19th Ave ",
        "timestamp": 1598288400,
        "datetime_utc": "08/24/2020 17:00:00"
      }
    ]
  ]
}

202

application/json

The response contains a request ID that can be used to fetch results by using Request Results endpoint. Each response is available for 4 hours after a request has been completed.

{
  "id": "your-request-id",
  "status": "Pending",
  "results_location": "https://api.outscraper.cloud/requests/your-request-id"
}

401

application/json

Wrong or missing API Key (token).

{
  "error": true,
  "errorMessage": "401 Unauthorized: The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required."
}

402

application/json

Past due invoices or a payment method not connected.

{
  "error": true,
  "errorMessage": "Please close past due invoices or verify your card information is correct."
}

422

application/json

Wrong query url parameters.

{
  "error": true,
  "errorMessage": "422 Unprocessable Entity: The request was well-formed but was unable to be followed due to semantic errors."
}

Code Samples

cURL

curl -X GET "https://api.outscraper.cloud/google-maps-directions?origin=Lincoln%20Way%20&%2019th%20Ave,%20San%20Francisco,%20USA&destination=19th%20Ave%20&%20Taraval%20St,%20San%20Francisco,%20USA&departure_time=1598288400&async=false" -H  "X-API-KEY: YOUR-API-KEY"

cURL (async)

curl -X GET "https://api.outscraper.cloud/google-maps-directions?origin=Lincoln%20Way%20&%2019th%20Ave,%20San%20Francisco,%20USA&destination=19th%20Ave%20&%20Taraval%20St,%20San%20Francisco,%20USA&departure_time=1598288400" -H  "X-API-KEY: YOUR-API-KEY"

Python

from outscraper import OutscraperClient

api_client = OutscraperClient(api_key='YOUR-API-KEY')
results = api_client.google_maps_directions(['29.696596, 76.994928    30.7159662444353, 76.8053887016268', '29.696596, 76.994928    30.723065, 76.770169'])

Related Endpoints

Returns Google Maps photos from places when using search queries (e.g., restaurants, Manhattan, NY, USA) or from a single place when using IDs or names (e.g., NoMad Restaurant, NY…

Returns Google Maps reviews from places when using search queries (e.g., restaurants, Manhattan, NY, USA) or from a single place when using Google IDs or names (e.g., NoMad Restau…

Returns places from Google Maps based on a given search query (or many queries). The results from searches are the same as you would see by visiting a regular Google Maps site. Ho…