# Google Maps Directions Scraper (`boncross/google-maps-directions`) Actor

Get Google Maps directions as JSON for driving, transit, walking and cycling. Add origins and destinations and get every alternative route with duration, distance, fares, transit lines, platforms, stops and per-leg times. Set a leave-at or arrive-by time and add waypoints. $2.50 per 1,000 routes.

- **URL**: https://apify.com/boncross/google-maps-directions.md
- **Developed by:** [BonCross API](https://apify.com/boncross) (community)
- **Categories:** Travel, Automation
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.40 / 1,000 route-computeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Google Maps Directions Scraper

### What is Google Maps Directions Scraper?

Type "King's Cross Station, London -> Heathrow Terminal 5" and Google Maps Directions Scraper gives you the routes Google Maps would show, as JSON: driving, transit, walking and cycling, with the alternatives and not just the first suggestion. You don't need a Google API key or a Google Cloud project. Place names, addresses or coordinates go in, and durations, distances, fares and transit legs come out.

What you get that a plain distance lookup doesn't:

- The alternatives. You typically get 3 for a road route and up to 6 for transit, ranked as Google ranks them.
- Transit you can follow. Each leg has its line and colour, headsign, service pattern, operator, platform and stop codes. A Tokyo subway run returned platform numbers and stop codes such as A18.
- Time-aware routing. Set a leave-at or arrive-by time in the route's own local time, per route or for the whole run.
- The route options from the Maps panel. Avoiding ferries took Seattle to Bainbridge Island from the 10.7-mile ferry route to a 92.5-mile drive round.
- Bulk speed. 120 routes in three modes (360 rows) took 16 seconds.
- $2.50 per 1,000 routes on the Free plan and $1.40 on Business, alternatives and legs included.

**BonCross Verified** means we tested this actor against the live site before release and kept the record:

- 27 of 27 live checks on its inputs and filters passed on 7 October 2026
- 13 routes run the same day on five continents, in 2 travel modes: 18 routes, 8 error rows
- Charges matched the rows: 18 computed, 8 checked
- A route that cannot be computed gets a row saying why

What you can do with it:

- Route between place names, addresses or coordinates, with waypoints on road routes
- Compare modes for the same pair of places in a single run
- Read transit lines, headsigns, service patterns, operators, platforms and stop codes
- Avoid tolls, highways or ferries when driving
- Prefer fewer transfers, less walking or a vehicle type on transit
- Read fares where Google shows them
- Fall back to a comparable weekday when a date is past the published timetable
- Read durations and distances as numbers, with Google's own wording kept beside them

It doesn't return turn-by-turn steps or live traffic. If you need either, read the Limitations section below before you run it.

### What route data do you get?

| | |
|---|---|
| Route alternatives, ranked | ⏱ Duration in seconds and text |
| 📏 Distance in metres and text | Departure and arrival times |
| 💴 Fare where Google shows one | Number of transfers |
| 🚇 Transit line names and colours | 🚌 Vehicle type and operator |
| Headsign and service pattern | From and to stop names |
| Stop codes | Platform |
| 🚶 Per-leg mode and timings | Via roads for driving routes |
| 📍 Resolved origin, destination and stops | Time zone of the route |
| 🗺 Matching Google Maps link | 📅 Substituted date when the fallback is used |

### How to get Google Maps directions

A route can be as short as one line of text, and there's no code to write.

1. [Create a free Apify account](https://console.apify.com/sign-up) and open [Google Maps Directions Scraper](https://apify.com/boncross/google-maps-directions).
2. Add your routes. `Origin -> Destination` is enough for a simple one.
3. Tick the travel modes you want. Transit is selected to begin with.
4. Add a departure or arrival time if the trip isn't for right now.
5. Click Start, then download the routes as JSON, CSV, Excel, XML or HTML.

### ⬇️ Input

Each entry in "Routes" is one trip. Write it as a string, `"King's Cross Station, London -> Heathrow Terminal 5"`, or as an object when you want a time or stops along the way. Origins, destinations and waypoints can be place names, addresses or `lat,lng` coordinates. Times are written `YYYY-MM-DDTHH:MM` in the route's own local time, and a route with no time means leave now.

"Travel modes" decides how many rows you get: each route is requested once per mode, and a run returns one row per route and mode. Six routes in transit and driving is twelve rows.

"Region" is the country Google assumes when a place name is ambiguous. "Springfield" to "Boston" finds a drive with `us` and no route with `gb`. It doesn't change the units: distances come in the units of the country the route is in. "Language" (default `en`) sets the language of names, road labels and line labels.

Waypoints work on driving, walking and cycling routes. Google Maps doesn't plan public transport through stops, so leave them off transit routes.

#### Transit between two places at a given time

```json
{
  "routes": [
    { "origin": "King's Cross Station, London", "destination": "Heathrow Terminal 5", "departAt": "2026-10-27T09:00" }
  ],
  "modes": ["transit"],
  "language": "en",
  "region": "gb"
}
```

#### Arrive-by, several routes, driving and transit compared

```json
{
  "routes": [
    "Times Square, New York -> JFK Airport",
    "Times Square, New York -> Brooklyn Bridge",
    { "origin": "Times Square, New York", "destination": "LaGuardia Airport", "arriveBy": "2026-11-03T10:00" }
  ],
  "modes": ["transit", "driving"],
  "region": "us"
}
```

#### Route options: fewer transfers, no tolls

The route preferences are the choices in the Google Maps route options panel. "Avoid tolls", "Avoid highways" and "Avoid ferries" apply to driving routes. With tolls avoided, Tokyo Station to Yokohama was 30.1 km on national roads where the default was 36.0 km on the expressway. With ferries avoided, Seattle to Bainbridge Island drives 92.5 miles round where the default takes the 10.7-mile ferry route.

"Transit route preference" (best, fewer transfers or less walking) and "Preferred transit modes" (bus, subway, train, tram) apply to public transport. A preferred mode is a preference, as it is in Google Maps, and a route that mixes in other vehicles can still be returned.

```json
{
  "routes": ["Gare du Nord, Paris -> Château de Versailles"],
  "modes": ["transit", "driving"],
  "transitRoutePreference": "fewerTransfers",
  "avoidTolls": true,
  "region": "fr"
}
```

#### A road trip with waypoints

```json
{
  "routes": [
    { "origin": "Paddington Station, London", "destination": "Heathrow Airport", "waypoints": ["Windsor Castle"] }
  ],
  "modes": ["driving"],
  "region": "gb",
  "maxAlternatives": 1
}
```

#### Coordinates in, walking and cycling out

```json
{
  "routes": [
    { "origin": "40.7577,-73.9853", "destination": "40.7484,-73.9857" }
  ],
  "modes": ["walking", "cycling"],
  "includeLegs": false
}
```

#### For developers

- A route object takes `origin`, `destination`, and optionally `departAt` or `arriveBy` and `waypoints`. The run-wide `departAt` and `arriveBy` are defaults that a route's own values override, and `arriveBy` is ignored when `departAt` is set.
- `maxAlternatives` caps the alternatives kept inside each row (default `0`, meaning all that Google returns, and at most 10). `maxItems` caps the routes returned across the whole run (default `0`, no limit).
- `includeLegs` (default `true`) keeps the per-leg breakdown on transit: walk and ride legs with line, platform, boarding and alighting stops and times.
- `fallbackToComparableDate` (Fall back to a comparable date, default `true`): transit timetables are only published a few weeks ahead. When a dated transit query returns nothing, the actor retries the latest same weekday that has a timetable and marks the record with `substitutedDate`. Turn it off to get no route.
- `avoidTolls`, `avoidHighways`, `avoidFerries`, `transitRoutePreference` (`best`, `fewerTransfers`, `lessWalking`) and `transitModes` (`bus`, `subway`, `train`, `tram`) apply run-wide, to all routes of the matching mode. `region` defaults to `us`.
- `maxConcurrency` (Parallel requests, default `32`, 1 to 32) sets how many requests run at once across the whole run. Lower it only if a run reports errors. `delayMs` (Delay between requests, default `0`) adds an optional pause before each request, in milliseconds.
- `id` is stable for the same origin, stops, destination, mode and requested time, which lets you join rows from two runs.
- Rows are written in the order the routes and modes were given. A run that's moved to another server or restarted carries on where it stopped, without writing or charging any route twice.

### ⬆️ Output

You get one record per route and mode, viewable as a table or as JSON in the Output tab. `best` is a summary of the first alternative, and `alternatives` holds them all.

```json
{
  "id": "transit-13e0sct",
  "url": "https://www.google.com/maps/dir/King's%20Cross%20Station%2C%20London/Heathrow%20Terminal%205/data=!4m2!4m1!3e3",
  "origin": "King's Cross Station, London",
  "destination": "Heathrow Terminal 5",
  "waypoints": [],
  "mode": "transit",
  "requestedTime": "2026-10-27T09:00",
  "timeKind": "depart",
  "substitutedDate": null,
  "resolvedOrigin": "King’s Cross, Euston Rd., London N1C 4AP",
  "resolvedDestination": "Terminal 5, Wallis Rd, Longford, Hounslow TW6 2GA",
  "resolvedStops": [
    "King’s Cross, Euston Rd., London N1C 4AP",
    "Terminal 5, Wallis Rd, Longford, Hounslow TW6 2GA"
  ],
  "alternativeCount": 6,
  "best": { "durationSeconds": 3983, "durationText": "1 hr 7 min", "distanceText": "19.4 miles", "departure": "2026-10-27T09:03:37+00:00", "arrival": "2026-10-27T10:10:00+00:00", "fare": "£5.90", "lines": ["Piccadilly"] },
  "alternatives": [
    {
      "index": 0, "durationSeconds": 3983, "durationText": "1 hr 7 min", "distanceMeters": 31248, "distanceText": "19.4 miles", "via": null, "timezone": "Europe/London",
      "departure": "2026-10-27T09:03:37+00:00", "arrival": "2026-10-27T10:10:00+00:00", "fare": "£5.90", "lines": ["Piccadilly"], "transfers": 0,
      "legs": [
        { "mode": "walk", "durationText": "4 min", "distanceText": "472 ft", "line": null, "lineColour": null, "vehicle": null, "headsign": null, "servicePattern": null, "operator": null, "from": null, "to": null, "fromStopCode": null, "toStopCode": null, "platform": null, "depart": null, "arrive": null },
        { "mode": "transit", "durationText": "1 hr 3 min", "distanceText": null, "line": "Piccadilly", "lineColour": "#10069f", "vehicle": "Underground", "headsign": "Heathrow Terminal 5", "servicePattern": null, "operator": "Transport for London", "from": "King's Cross St. Pancras", "to": "Heathrow Airport Terminal 5", "fromStopCode": null, "toStopCode": null, "platform": null, "depart": "2026-10-27T09:07:00+00:00", "arrive": "2026-10-27T10:10:00+00:00" }
      ]
    },
    "…"
  ],
  "mapsUrl": "https://www.google.com/maps/dir/King's%20Cross%20Station%2C%20London/Heathrow%20Terminal%205/data=!4m2!4m1!3e3",
  "scrapedAt": "2026-10-07T19:29:45.469Z"
}
```

When there's no route, you still get the row. It has `alternativeCount: 0`, an empty `alternatives` list and an `error` field saying why: no routes returned, a date beyond the published timetable, or a stop Google couldn't place, named in the message. That row costs $0.0005 (`route-checked`) when Google Maps answered with no route, and nothing when the request couldn't be completed.

`resolvedOrigin` and `resolvedDestination` show what Google matched your text to. They're worth a glance on any route where the place name could exist in two cities.

In a CSV or Excel export the nested legs are flattened into columns. JSON keeps them nested.

### Limitations: no turn-by-turn steps, no live traffic

- **No turn-by-turn steps.** Driving, walking and cycling rows give you the alternatives with their via roads and totals. They have no step list and no per-leg detail.
- **No live traffic.** A driving duration is Google's typical-traffic estimate for the requested time. There's no duration-in-traffic figure and no traffic condition, and an estimate for a date months ahead is not a promise.
- Transit fares are Google's and are often missing or approximate. Take the time from here and the fare from the operator when it matters.
- Beyond the published timetable horizon there are no transit routes. The comparable-date fallback returns typical service for that weekday, clearly marked. It isn't the timetable for your date.
- The fallback only fires when Google refuses a date. A departure about two years ahead was still accepted and routed normally, so you may rarely see it.
- The `via` field is filled for road routes only.
- A driving row with no requested time can have `departure` and `arrival` empty.
- Waypoints work for driving, walking and cycling. A transit route with waypoints gives you a row explaining that Google Maps doesn't plan public transport through stops, and it isn't charged. Split it into separate routes.
- Cycling directions exist only where Google Maps offers them. A cycling request in Kyoto returned no route. A row like that has an `error` and costs the $0.0005 `route-checked` fee.
- Google Maps answers no driving or walking routes in South Korea. That's Google's restriction there.
- A bare place name can match more than one place, and not always the same one. "Statue of Liberty Ferry" resolved to Liberty Island on one run and to the replica in Tokyo on another. Add the city, or use coordinates.
- Route preferences apply run-wide, and the avoid options to driving only. Wheelchair-accessible transit isn't offered, because it couldn't be shown to change any route.

### How many routes can you get, and how fast?

| Run | Rows | Run time |
|---|---|---|
| 1 route, transit and walking | 2 | 2 to 3 s |
| 6 routes, transit and driving | 12 | 6 to 7 s |
| 32 routes, driving | 32 | 6 s |
| 120 routes × transit, driving and walking | 360 | 16 s |

Whole runs on Apify at the default settings, measured on 1 and 2 October 2026. That's over a thousand routes a minute.

For a sense of the detail: five routes run in transit and driving were all answered, and between them covered the Tokyo subway with platform and stop codes, Tokyo JR with service pattern, a Kyoto city bus with stop letter, the London Underground to Heathrow with fare, and the New York subway with fare.

Transit routing is limited by the published timetable horizon, which is usually a few weeks to a few months depending on the operator.

### How much does it cost?

| Event | Free plan | Starter | Scale | Business |
|---|---|---|---|---|
| `actor-start`, per run | $0.002 | $0.002 | $0.002 | $0.002 |
| `route-checked`, per route and mode Google Maps answered with no route | $0.0005 | $0.0005 | $0.0005 | $0.0005 |
| `route-computed`, per route and mode with at least one alternative | $0.0025 | $0.00225 | $0.00195 | $0.0014 |

Enterprise plans pay the Business price.

**$2.50 per 1,000 routes** on the Free plan, $1.40 on Business, alternatives and legs included. That's the full price, with proxy usage and platform usage included. A route Google Maps answers with no route at all costs $0.0005 (`route-checked`). A route that couldn't be reached, or public transport through stops, is free.

- An itinerary planner, 25 legs of a trip in transit and driving: $0.002 + 50 × $0.0025 = **$0.127** ($0.072 on Business).
- A daily commute-time monitor, 200 origin and destination pairs by car each weekday morning: $0.002 + 200 × $0.0025 = **$0.502** per day ($0.282 on Business).

Apify's Free plan includes $5 of credits a month, enough for about 39 runs the size of that itinerary, or about 1,950 routes.

### FAQ

#### Do I need proxies, a Google API key or a Google account?

None of them. There's no Google Cloud project to create and no key to manage. Proxy usage is included in the event prices, with nothing to set up.

#### Is scraping Google Maps directions legal?

Web scraping is legal when the data is publicly available, which map directions are. This actor reads what Google Maps serves to any visitor, and complying with Google's terms and your local law in how you use the data is your responsibility.

#### Do I get turn-by-turn steps or live traffic?

Neither, at the moment. Road routes give you alternatives with via roads, distance and a typical-traffic duration. Transit routes are the detailed ones, leg by leg.

#### How do I set a departure or arrival time?

Per route, add `departAt` or `arriveBy` to the route object. For the whole run, fill in "Depart at" or "Arrive by". Both are in the route's local time, and leaving them empty routes for now.

#### What happens with a date beyond the transit timetable?

With "Fall back to a comparable date" on, the actor retries the latest matching weekday that has a timetable and marks the record with `substitutedDate`. Turn it off and you get an empty result, billed the $0.0005 `route-checked` fee.

#### Why did a route return nothing, and what did it cost?

Usually Google has no route for that mode there (cycling in Kyoto, for one), the date is past the timetable, or a place name couldn't be matched. The row's `error` says which. It costs $0.0005 where Google answered with no route, against $0.0025 for a route.

#### How do I compare driving with public transport for the same trip?

Tick both modes. You get one row per route and mode, and the `id` and the origin and destination columns line them up.

#### Can I route through several stops?

On driving, walking and cycling routes, add `waypoints` to the route. For public transport, split the trip into separate routes, one per hop.

#### Do I get platforms and stop codes?

Where Google shows them. The Tokyo subway run returned platform numbers and stop codes such as A18, and a New York subway run has the line as the vehicle label.

### Use the routes in a planner, a sheet or an agent

Itinerary builders and travel products are the usual home for this data: real transit times, platforms and fares for each hop of a trip, without a mapping contract. It also suits commute analysis from a set of addresses to an office, site selection by car and transit reachability, driving-time estimates with waypoints for logistics, and collecting transit data (lines, headsigns, operators, platforms and stop codes).

An Apify Schedule can recompute a set of routes each morning, and a webhook or the Google Sheets integration can file the durations when the run ends.

From code, a `POST` to `https://api.apify.com/v2/acts/boncross~google-maps-directions/run-sync-get-dataset-items` with the input JSON in the body returns the routes when the run finishes. `apify-client` is on NPM for Node.js and PyPI for Python.

A travel-planning agent can call it through the Apify MCP server at `mcp.apify.com`, where it appears under the name `google-maps-directions`. The agent asks for a route between two places at a given time and gets durations, fares and transit legs as JSON.

### More from BonCross

- [Google Maps Reviews Scraper](https://apify.com/boncross/google-maps-reviews): Google Maps reviews for any place using URLs, Place IDs or names.
- [Google Flights Booking Options Scraper](https://apify.com/boncross/google-flights-booking-options): See every airline and travel agency selling the same flight, each with its own price…
- [Google Flights Deals Scraper](https://apify.com/boncross/google-flights-deals): Describe a trip in plain English and let Google pick the destinations, or get the…
- [Google Flights Explore Scraper](https://apify.com/boncross/google-flights-explore): Find everywhere you can fly from one airport and what each destination costs.
- [Google Flights Multi-City Scraper](https://apify.com/boncross/google-flights-multi-city): Google Flights multi-city trips of three legs or more, and quiet routes Google leaves…
- [Google Flights Scraper](https://apify.com/boncross/google-flights-search): Google Flights for any route and date and get every itinerary with price, airlines,…

### Your feedback

Got a route that looks wrong, or a city where the transit detail is thin? Raise it on the Issues tab in Apify Console and include the route. We read each one, and it's also the place to tell us how much you need steps or traffic.

# Changelog

This Actor's version history is a separate document: https://apify.com/boncross/google-maps-directions/changelog.md

# Actor input Schema

## `routes` (type: `array`):

One per entry: {"origin": "King's Cross Station, London", "destination": "Heathrow Terminal 5"}, with optional "departAt" or "arriveBy" (YYYY-MM-DDTHH:MM, local to the route) and, for driving, walking or cycling, "waypoints": \["Windsor Castle"]: Google does not plan public transport through stops. Plain place names, addresses or coordinates all work; Google geocodes them and the record shows what each one resolved to. A plain string "A -> B" also works.

## `maxItems` (type: `integer`):

Stop after this many routes have been returned across the run. 0 means no limit.

## `modes` (type: `array`):

One request per route per mode.

## `departAt` (type: `string`):

YYYY-MM-DDTHH:MM in the route's own local time. Empty = leave now. Per-route departAt / arriveBy override this.

## `arriveBy` (type: `string`):

YYYY-MM-DDTHH:MM local time. Ignored when Depart at is set.

## `fallbackToComparableDate` (type: `boolean`):

Transit timetables are only published a few weeks ahead. When a dated transit query returns nothing, retry the latest same weekday that has a timetable and mark the record with substitutedDate.

## `avoidTolls` (type: `boolean`):

Driving routes only: route around toll roads.

## `avoidHighways` (type: `boolean`):

Driving routes only: keep off motorways and highways.

## `avoidFerries` (type: `boolean`):

Driving routes only: never take a car ferry.

## `transitRoutePreference` (type: `string`):

Public transport only. Best route (the default), fewer transfers, or less walking.

## `transitModes` (type: `array`):

Public transport only. Prefer these vehicles. A preference, as in Google Maps: when no route uses only them, routes mixing in others still come back.

## `maxAlternatives` (type: `integer`):

0 = all Google returns (typically 3 road, up to 6 transit).

## `includeLegs` (type: `boolean`):

For transit: walk / ride legs with line, platform, boarding and alighting stops and times.

## `language` (type: `string`):

Names, road and line labels in this language, e.g. en, ja, de.

## `region` (type: `string`):

Which country Google assumes when a place name is ambiguous: "Springfield" to "Boston" finds a drive with us and no route with gb. Distances come in the units of the country the route is in, whatever this is set to.

## `maxConcurrency` (type: `integer`):

How many requests run at once across the whole run. The default is the fastest level measured clean; lower it only if a run reports refusals or errors.

## `delayMs` (type: `integer`):

Optional pause before each call, in milliseconds. 0 (the default) runs as fast as the parallel limit allows.

## Actor input object example

```json
{
  "routes": [
    {
      "origin": "King's Cross Station, London",
      "destination": "Heathrow Terminal 5",
      "arriveBy": "2026-10-27T18:00"
    },
    {
      "origin": "Times Square, New York",
      "destination": "JFK Airport"
    }
  ],
  "maxItems": 0,
  "modes": [
    "transit"
  ],
  "departAt": "",
  "arriveBy": "",
  "fallbackToComparableDate": true,
  "avoidTolls": false,
  "avoidHighways": false,
  "avoidFerries": false,
  "transitRoutePreference": "best",
  "transitModes": [],
  "maxAlternatives": 0,
  "includeLegs": true,
  "language": "en",
  "region": "us",
  "maxConcurrency": 32,
  "delayMs": 0
}
```

# Actor output Schema

## `dataset` (type: `string`):

Google Maps directions: every row the run returned.

## `stats` (type: `string`):

Counts for the run: what was resolved, fetched, filtered and returned.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "routes": [
        {
            "origin": "King's Cross Station, London",
            "destination": "Heathrow Terminal 5",
            "arriveBy": "2026-10-27T18:00"
        },
        {
            "origin": "Times Square, New York",
            "destination": "JFK Airport"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("boncross/google-maps-directions").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "routes": [
        {
            "origin": "King's Cross Station, London",
            "destination": "Heathrow Terminal 5",
            "arriveBy": "2026-10-27T18:00",
        },
        {
            "origin": "Times Square, New York",
            "destination": "JFK Airport",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("boncross/google-maps-directions").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "routes": [
    {
      "origin": "King'\''s Cross Station, London",
      "destination": "Heathrow Terminal 5",
      "arriveBy": "2026-10-27T18:00"
    },
    {
      "origin": "Times Square, New York",
      "destination": "JFK Airport"
    }
  ]
}' |
apify call boncross/google-maps-directions --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,boncross/google-maps-directions"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/RAaYr2uBaPCZgmi4y/builds/9Klc02NvFwbNg6XPa/openapi.json
