# Google Maps Directions API (`johnvc/google-maps-directions-api`) Actor

Get Google Maps directions for any route - driving, transit, walking, cycling, or flight - with distance, ETA, and turn-by-turn steps as JSON. Use addresses, coordinates, or place IDs; avoid tolls, highways, or ferries; set departure or arrival time. MCP-ready for Claude and AI agents.

- **URL**: https://apify.com/johnvc/google-maps-directions-api.md
- **Developed by:** [John](https://apify.com/johnvc) (community)
- **Categories:** Travel, Developer tools, SEO tools
- **Stats:** 107 total users, 20 monthly users, 100.0% runs succeeded, 5 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.01 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 🗺️ Google Maps Directions API

Get Google Maps directions between any origin and destination as structured JSON: route options for driving, transit, walking, cycling, and flight, with distance, ETA, traffic-aware duration ranges, and turn-by-turn steps. Provide addresses, GPS coordinates, or place IDs. MCP-ready so Claude and other AI agents can call it as a tool. The Google Maps Directions API needs no Google Cloud key: send an origin and a destination, and every route option comes back in one call.

> **Example code (Python):** <https://github.com/johnisanerd/Apify-Google-Maps-Directions-API>

***

### 📋 What this API returns

| Field | Description |
|---|---|
| `start`, `end` | The origin and destination used for the lookup. |
| `travel_mode` | The requested mode: best, driving, cycling, walking, transit, flight, or two-wheeler. |
| `directions_found` | `true` if at least one route option was returned. |
| `directions_count` | Number of route options in `directions`. |
| `best_duration`, `best_distance` | ETA and distance of the first (recommended) option, e.g. `3 hr 38 min`, `215 miles`. |
| `places_info` | Resolved origin and destination: formatted address, place ID, and GPS coordinates. |
| `directions` | Each route option with mode, distance, duration, route summary (`via`), notes (`extensions`), and `trips` containing turn-by-turn steps. Transit options include stops, lines, operators, and times. |
| `durations` | Travel time by mode (driving, transit, walking, cycling, flight) for this origin and destination. |
| `google_maps_directions_url` | A direct Google Maps link that opens the same route in a browser. |

***

### 🎯 Use cases

- **Logistics and delivery.** Compute ETA and distance between stops to plan and price routes.
- **Travel and trip planning.** Compare driving, transit, walking, and cycling options for a journey.
- **Apps and dashboards.** Embed turn-by-turn directions and a Google Maps link without managing a maps key.
- **AI agent workflows.** Drive this API over MCP from Claude (see below) to answer "how do I get from A to B?" in-conversation.
- **Transit analysis.** Pull public-transit legs, operators, and departure/arrival times for a corridor.

***

### 🔌 Integrations: Automate the Google Maps Directions API

A single run answers one question ("how do I get from A to B right now?"). The real value comes from running this API on a schedule, so route ETAs, distances, and traffic-aware durations land in your stack every morning or after every new stop. See the full list of [Apify platform integrations](https://docs.apify.com/platform/integrations).

**Tasks and Schedules (the core recipe).** Save one [task](https://docs.apify.com/platform/actors/running/tasks) per corridor you watch (a delivery lane, a commute, a store-to-store leg), then attach a [schedule](https://docs.apify.com/platform/schedules) from the actor's Actions, then Schedule menu. Each run refreshes distance, ETA, and traffic-aware duration for that route. Useful cron strings: `0 7 * * *` (daily 7 AM), `0 */6 * * *` (every 6 hours), `0 8 * * 1-5` (weekday mornings), `0 9 * * 1` (Mondays). One schedule can trigger many tasks at once, so a whole set of routes refreshes in a single pass. The [Get Google Maps directions by API as JSON](https://apify.com/johnvc/google-maps-directions-api/examples/get-google-maps-directions-by-api-as-json?fpr=9n7kx3) task is a ready-to-run starting point.

**n8n.** This API ships an n8n community node (see the n8n integration section below). A four-step monitor: Schedule Trigger, then the Google Maps Directions API node, then a Filter on `best_duration`, then Slack or email when a route slows down.

**Make and Zapier.** The same pattern works no-code with [Make](https://docs.apify.com/platform/integrations/make) and [Zapier](https://docs.apify.com/platform/integrations/zapier): trigger on a schedule, run the actor, route each result where you need it.

**Store the history (Supabase).** Send each run's rows into a table so a route and ETA history accumulates over time. No-code: the n8n Actor node, then a Supabase node. Or in Python (each row carries `start`, `end`, `best_duration`, `best_distance`, `directions_count`, and `google_maps_directions_url`):

```python
from apify_client import ApifyClient
from supabase import create_client

apify = ApifyClient("YOUR_APIFY_TOKEN")
supabase = create_client("YOUR_SUPABASE_URL", "YOUR_SUPABASE_KEY")

run = apify.actor("johnvc/google-maps-directions-api").call(run_input={
    "start_addr": "New York, NY",
    "end_addr": "Boston, MA",
    "travel_mode": "best",
})

rows = []
for item in apify.dataset(run["defaultDatasetId"]).iterate_items():
    rows.append({
        "start": item["start"],
        "end": item["end"],
        "best_duration": item["best_duration"],
        "best_distance": item["best_distance"],
        "directions_count": item["directions_count"],
        "maps_url": item["google_maps_directions_url"],
    })

supabase.table("route_history").insert(rows).execute()
```

**MCP and AI agents.** Add this API as a tool in Claude or Cursor through the [Apify MCP server](https://mcp.apify.com/) so an agent can answer "how long is the drive from A to B in current traffic?" with live data (see the Use this API from Claude section below).

**Webhooks.** For anything custom, fire an [Apify webhook](https://docs.apify.com/platform/integrations/webhooks) on `ACTOR.RUN.SUCCEEDED` to push each run's dataset into your own service.

***

### ⚙️ Input examples

#### Basic route (best options across modes)

```json
{
  "start_addr": "New York, NY",
  "end_addr": "Boston, MA"
}
```

#### Driving, avoid tolls and highways, in miles

```json
{
  "start_addr": "Los Angeles, CA",
  "end_addr": "San Francisco, CA",
  "travel_mode": "driving",
  "distance_unit": "miles",
  "avoid_tolls": true,
  "avoid_highways": true
}
```

#### Transit, arriving by a specific time

```json
{
  "start_addr": "Brooklyn, NY",
  "end_addr": "Times Square, New York, NY",
  "travel_mode": "transit",
  "transit_routing": "less_walking",
  "time_type": "arrive_by",
  "time_value": "2026-06-01T09:00:00"
}
```

#### Exact coordinates

```json
{
  "start_coords": "40.7128,-74.0060",
  "end_coords": "42.3601,-71.0589",
  "travel_mode": "driving"
}
```

Provide an origin and a destination as an address, coordinates (`latitude,longitude`), or a Google Maps place ID. The API returns one row per run.

***

### 📦 Example output (trimmed)

```json
{
  "result_type": "directions",
  "start": "New York, NY",
  "end": "Boston, MA",
  "travel_mode": "best",
  "directions_found": true,
  "directions_count": 3,
  "best_duration": "3 hr 38 min",
  "best_distance": "215 miles",
  "places_info": [
    { "address": "New York", "data_id": "0x89c24fa5d33f083b:0xc80b8f06e177fe62", "gps_coordinates": { "latitude": 40.7127753, "longitude": -74.0059728 } },
    { "address": "Boston, Massachusetts", "data_id": "0x89e3652d0d3d311b:0x787cbf240162e8a0", "gps_coordinates": { "latitude": 42.3555076, "longitude": -71.0565364 } }
  ],
  "directions": [
    {
      "travel_mode": "Driving",
      "via": "CT-15 N and I-90 E",
      "distance": 346243,
      "duration": 13082,
      "formatted_distance": "215 miles",
      "formatted_duration": "3 hr 38 min",
      "typical_duration_range": "3 hr 21 min to 4 hr 10 min",
      "extensions": ["Fastest route now due to traffic conditions", "This route has tolls."],
      "trips": [
        {
          "travel_mode": "Driving",
          "title": "Get on FDR Dr",
          "formatted_distance": "0.9 mi",
          "formatted_duration": "5 min",
          "details": [
            { "title": "Head toward Park Row", "action": "straight", "formatted_distance": "200 ft", "formatted_duration": "21 sec" }
          ]
        }
      ]
    }
  ],
  "durations": [
    { "travel_mode": "Driving", "formatted_duration": "3 hr 38 min" },
    { "travel_mode": "Transit", "formatted_duration": "4 hr 25 min" },
    { "travel_mode": "Flight", "formatted_duration": "1 hr 15 min" }
  ],
  "google_maps_directions_url": "https://www.google.com/maps/dir/...",
  "gl": "us",
  "hl": "en",
  "fetched_at": "2026-05-29T12:00:00+00:00"
}
```

***

### 💰 Pricing (pay-per-event)

| Event | Price | When it fires |
|---|---|---|
| `setup` | $0.01 | Once per Actor run, at startup. |
| `directions_processed` | $0.015 | Once per route lookup. One lookup returns every route option for the origin and destination. |

A single route lookup costs $0.01 + $0.015 = **$0.025**, flat and predictable. One lookup with the default `best` mode returns several route options (driving, transit, flight, and more) in that one charge.

***

### 🔌 Use this API from Claude (MCP)

This Actor is MCP-server-compatible, so [Claude Code](https://claude.ai/referral/uIlpa7nPLg) (free trial), Claude (desktop and web), Cursor, and other MCP clients can call it as a tool through Apify's hosted MCP server.

Add it with this Actor-specific URL:

https://mcp.apify.com/?tools=actors,docs,johnvc/google-maps-directions-api

Setup walkthrough:

https://www.youtube.com/watch?v=jREWahDGhJM

Apify MCP integration docs: https://docs.apify.com/platform/integrations/mcp

**New to [Claude Code](https://claude.ai/referral/uIlpa7nPLg) or [Claude Cowork](https://claude.ai/referral/uIlpa7nPLg)?** Start a free trial here: https://claude.ai/referral/uIlpa7nPLg

Then ask Claude:

> *"Use the Google Maps Directions API to get driving directions from New York, NY to Boston, MA, and tell me the distance and ETA."*

***

### 💸 Pay per run with crypto (x402)

The Google Maps Directions API supports agentic payments via the [x402 protocol](https://docs.apify.com/platform/integrations/x402).
AI agents and MCP clients can pay for runs in USDC (on Base) with no Apify account or API token needed:
point your agent at the [Apify MCP server](https://mcp.apify.com/?tools=actors,docs,johnvc/google-maps-directions-api) and it can
discover, pay for, and run this Actor autonomously. Read the
[Apify x402 announcement](https://apify.com/change-log/pay-for-apify-actors-with-x402?fpr=9n7kx3) for details.

### 🚀 How to get started

1. Open the Actor and enter a start and end point (address, coordinates, or place ID).
2. Optionally choose a travel mode, units, avoidance options, transit preferences, or a departure/arrival time.
3. Run it and read the results from the dataset (JSON, CSV, Excel, or API).

[View on Apify Store](https://apify.com/johnvc/google-maps-directions-api?fpr=9n7kx3)

***

### 🔗 Related Tools

Build a full mapping workflow by pairing this API with related tools in the same catalog:

- [Google Maps Places Scraper](https://apify.com/johnvc/google-maps-places-api?fpr=9n7kx3) - find and geocode the businesses or landmarks you want to route between, and get the place IDs and coordinates this API accepts as input.
- [Google Local API](https://apify.com/johnvc/google-local-api?fpr=9n7kx3) - pull the Local Pack and business-search results for a metro, then feed those addresses into a route lookup.
- [Google Maps Contributor Reviews API](https://apify.com/johnvc/google-maps-contributor-reviews-api?fpr=9n7kx3) - collect a reviewer's full contribution history across Google Maps.
- [Google Maps Reviewer Geo Profile API](https://apify.com/johnvc/google-maps-reviewer-geo-profile-api?fpr=9n7kx3) - map where a Google Maps reviewer has left reviews to spot local-guide patterns.

For contrast, other directions scrapers such as [this Google Maps Directions Scraper](https://apify.com/crawlerbros/google-maps-directions?fpr=9n7kx3) exist, but it shows almost no adoption (a single-digit user count), carries no user rating, and reports a lower success rate. This API is actively maintained and returns clean, structured JSON with turn-by-turn steps for every route option.

***

### ❓ FAQ

#### Which travel modes are supported?

Best (all modes), driving, cycling, walking, transit, flight, and two-wheeler. Flight and two-wheeler are only available for some regions and routes; when a mode has no route, the row comes back with `directions_found: false` and a short `note`.

#### Can I use coordinates or place IDs instead of addresses?

Yes. Set `start_coords`/`end_coords` as `latitude,longitude`, or `start_data_id`/`end_data_id` with a Google Maps place ID. Coordinates take precedence over place ID, which takes precedence over address.

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

Set `time_type` to `depart_at` or `arrive_by` and put an ISO 8601 datetime (or a Unix timestamp) in `time_value`. This is most useful for transit, and a departure time also informs driving traffic estimates.

#### Do I need a Google Maps API key?

No. Supply only the input fields; the Actor handles data retrieval for you.

#### Can I schedule the Google Maps Directions API?

Yes, and this is where the API earns its keep. Save a [task](https://docs.apify.com/platform/actors/running/tasks) with your origin, destination, and travel mode, then attach a [schedule](https://docs.apify.com/platform/schedules) from the actor's Actions, then Schedule menu. Concrete cron strings: `0 7 * * *` for daily at 7 AM, `0 */6 * * *` for every six hours, and `0 9 * * 1` for Mondays. One schedule can trigger many tasks at once, so a whole set of routes refreshes in a single pass. See the Integrations section above for the full monitoring recipe, and [Apify schedules](https://docs.apify.com/platform/schedules) for the docs.

#### Should I use an API or a web scraper for directions?

Both, and this Actor is both. An official maps API is rate limited, quota bound, and billed per element, while a plain [web scraper](https://en.wikipedia.org/wiki/Web_scraping) returns messy HTML you still have to parse. This Actor gives you the clean, structured result of a purpose-built [API](https://en.wikipedia.org/wiki/API): send an origin and a destination, get every route option back as JSON, with no Google Cloud key and no per-element quotas.

#### Can I integrate this API with other apps?

Yes. It connects to almost any cloud service through [Apify integrations](https://docs.apify.com/platform/integrations): [Make](https://docs.apify.com/platform/integrations/make), [Zapier](https://docs.apify.com/platform/integrations/zapier), [Slack](https://docs.apify.com/platform/integrations/slack), the n8n community node, and [webhooks](https://docs.apify.com/platform/integrations/webhooks) on `ACTOR.RUN.SUCCEEDED` for custom actions. See the Integrations section above for the full recipes.

#### Can I use the Google Maps Directions API programmatically?

Yes. The Apify API runs the actor, schedules it, and fetches datasets, and the `apify-client` package exists for both Node.js and Python. See the actor's [API tab](https://apify.com/johnvc/google-maps-directions-api/api?fpr=9n7kx3) for ready-made code in several languages.

#### Can I use the Google Maps Directions API through an MCP server?

Yes. Add it as a tool in any MCP client (Claude, Cursor, and others) through the hosted [Apify MCP server](https://mcp.apify.com/) with the actor-specific URL `https://mcp.apify.com/?tools=actors,docs,johnvc/google-maps-directions-api`. In [Claude Code](https://claude.ai/referral/uIlpa7nPLg) (free trial) or [Claude Cowork](https://claude.ai/referral/uIlpa7nPLg) (free trial) your agent can then answer questions like "how do I get from A to B, and how long will it take?" with live route data. See the [Apify MCP docs](https://docs.apify.com/platform/integrations/mcp).

#### How do AI agent workflows use this API?

In AI agent workflows, the API is one tool the agent calls when a task needs a real route: a trip-planning agent works out drive time between stops, a logistics agent prices a delivery lane, or a support agent answers "how far is it and how long will it take?" in conversation. Because it is MCP-ready, no glue code is needed; the agent calls it directly and reads back distance, ETA, and turn-by-turn steps.

#### How does this API help logistics and delivery?

For logistics and delivery, the API gives you distance and traffic-aware ETA between any two stops, so you can plan routes, price deliveries, and set customer expectations. Run it on a schedule per lane to watch how drive times shift through the day, and store the results (see the Integrations section) to build a route history you can analyze later.

#### How else can I get Google Maps data?

This API covers routing between points; pair it with related tools when you need the points themselves. Use the [Google Maps Places Scraper](https://apify.com/johnvc/google-maps-places-api?fpr=9n7kx3) to find and geocode businesses or landmarks, the [Google Local API](https://apify.com/johnvc/google-local-api?fpr=9n7kx3) for Local Pack business results in a metro, and the [Google Maps Contributor Reviews API](https://apify.com/johnvc/google-maps-contributor-reviews-api?fpr=9n7kx3) for reviewer history. All of this data originates on [Google Maps](https://www.google.com/maps).

***

### n8n integration

Available as an n8n community node, **[n8n-nodes-google-maps-directions-api](https://www.npmjs.com/package/n8n-nodes-google-maps-directions-api)**. In n8n: Settings, Community Nodes, install `n8n-nodes-google-maps-directions-api`, then use it in any workflow (it also works as an AI Agent tool).

***

### Featured Tasks

Ready-to-run examples that show this API solving a specific problem. Each opens its own setup so you can
run it on your account in one click.

- [Get Google Maps directions via MCP in AI agents](https://apify.com/johnvc/google-maps-directions-api/examples/get-google-maps-directions-via-mcp-in-ai-agents?fpr=9n7kx3) - give any MCP client live route options with distance, ETA, and turn-by-turn steps.
- [Get Google Maps directions in Claude Cowork](https://apify.com/johnvc/google-maps-directions-api/examples/get-google-maps-directions-in-claude-cowork?fpr=9n7kx3) - wire directions into [Claude Cowork](https://claude.ai/referral/uIlpa7nPLg) (free trial available) as an MCP plugin for trip planning and logistics.
- [Get Google Maps directions by API as JSON](https://apify.com/johnvc/google-maps-directions-api/examples/get-google-maps-directions-by-api-as-json?fpr=9n7kx3) - call one endpoint and get every route option as clean JSON, no Google Cloud setup.
- [Get Google Maps Directions Without an API Key](https://apify.com/johnvc/google-maps-directions-api/examples/get-google-maps-directions-without-api-key?fpr=9n7kx3) - route options with best\_duration, best\_distance, turn-by-turn steps, and a maps link, no Google Cloud key.
- [Get Travel Time Between Two Addresses by API](https://apify.com/johnvc/google-maps-directions-api/examples/travel-time-between-two-addresses?fpr=9n7kx3) - driving, transit, walking, and cycling durations between two addresses in one call.

***

### 🌐 About Alpha OSINT

This Actor is part of [Alpha OSINT](https://www.alphaosint.com), toolset of financial and operations data sources and APIs.
See the [Google Maps Directions API source page](https://www.alphaosint.com/sources/google-maps-directions-api/) for related tools and use cases.
For support or requests for this actor, please start a ticket [directly on our support page](https://apify.com/johnvc/google-maps-directions-api/issues/open?fpr=9n7kx3).

Last Updated: 2026.08.04

# Actor input Schema

## `start_addr` (type: `string`):

Enter the starting address or place name (e.g. 'New York, NY' or 'Empire State Building'). Provide this or `start_coords` or `start_data_id` for the origin.

## `end_addr` (type: `string`):

Enter the destination address or place name (e.g. 'Boston, MA' or 'Fenway Park'). Provide this or `end_coords` or `end_data_id` for the destination.

## `start_coords` (type: `string`):

Optionally set the origin as exact GPS coordinates in 'latitude,longitude' format (e.g. '40.7128,-74.0060'). Overrides the start address when provided.

## `end_coords` (type: `string`):

Optionally set the destination as exact GPS coordinates in 'latitude,longitude' format (e.g. '42.3601,-71.0589'). Overrides the end address when provided.

## `start_data_id` (type: `string`):

Optionally set the origin as a Google Maps place data ID (e.g. '0x89c24fa5d33f083b:0xc80b8f06e177fe62'). Overrides the start address when provided.

## `end_data_id` (type: `string`):

Optionally set the destination as a Google Maps place data ID. Overrides the end address when provided.

## `travel_mode` (type: `string`):

Choose how to travel. 'Best' returns the best options across modes; the others restrict the result to one mode. Flight and two-wheeler are only available for some regions and routes.

## `distance_unit` (type: `string`):

Choose the distance unit for the results. 'Automatic' lets the region decide.

## `avoid_tolls` (type: `boolean`):

Enable to prefer routes without toll roads. Applied as a preference; Google may still include tolls if no alternative exists.

## `avoid_highways` (type: `boolean`):

Enable to prefer routes that avoid highways.

## `avoid_ferries` (type: `boolean`):

Enable to prefer routes that avoid ferries.

## `transit_prefer` (type: `string`):

Set a preferred public transit mode. Only applied when Travel Mode is 'Transit'. Leave as 'None' for no preference.

## `transit_routing` (type: `string`):

Set how transit routes are optimized. Only applied when Travel Mode is 'Transit'. Leave as 'None' for the default.

## `time_type` (type: `string`):

Choose whether the time below is a departure time, an arrival time, or to leave now. 'Leave now' ignores the time value.

## `time_value` (type: `string`):

Set the departure or arrival time as an ISO 8601 datetime (e.g. '2026-06-01T09:00:00') or a Unix timestamp. Used only when Time Mode is 'Depart at' or 'Arrive by'.

## `hl` (type: `string`):

Set the two-letter interface language code (ISO 639-1, e.g. 'en', 'es', 'fr'). Controls the language of instructions and place names. Defaults to 'en'.

## `gl` (type: `string`):

Set the two-letter country code (ISO 3166-1, e.g. 'us', 'gb', 'ca'). Influences regional routing and defaults. Defaults to 'us'.

## Actor input object example

```json
{
  "start_addr": "New York, NY",
  "end_addr": "Boston, MA",
  "travel_mode": "best",
  "distance_unit": "auto",
  "avoid_tolls": false,
  "avoid_highways": false,
  "avoid_ferries": false,
  "transit_prefer": "none",
  "transit_routing": "none",
  "time_type": "leave_now",
  "hl": "en",
  "gl": "us"
}
```

# Actor output Schema

## `allResults` (type: `string`):

Every dataset item from this run: the resolved directions row (result\_type='directions') or an error row.

## `overview` (type: `string`):

Tabular overview using the dataset schema's default view. Columns: type, start, end, mode, route options, best duration, best distance, map link, fetched-at.

# 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 = {
    "start_addr": "New York, NY",
    "end_addr": "Boston, MA",
    "hl": "en",
    "gl": "us"
};

// Run the Actor and wait for it to finish
const run = await client.actor("johnvc/google-maps-directions-api").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 = {
    "start_addr": "New York, NY",
    "end_addr": "Boston, MA",
    "hl": "en",
    "gl": "us",
}

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

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

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

```

## CLI example

```bash
echo '{
  "start_addr": "New York, NY",
  "end_addr": "Boston, MA",
  "hl": "en",
  "gl": "us"
}' |
apify call johnvc/google-maps-directions-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=johnvc/google-maps-directions-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/czXNneHcGQ1vsxmwu/builds/9wySD7A53xr93yo0P/openapi.json
