Google Maps Route & Distance Matrix Scraper: MCP config, n8n workflow and API

Google Maps routes and travel-time matrices include resolved locations, distances, durations, traffic estimates and optional turn-by-turn steps. Choose it for comparing journeys across locations or retrieving route alternatives for a planned trip.

Choose mode and add stops for a route, origins and destinations for a matrix, or directionsUrls for existing Google Maps directions links.

Fastest route, in Claude Code:

claude mcp add --transport http google-maps-route-and-distance-matrix-scraper "https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/google-maps-route-and-distance-matrix-scraper"

One click, signs in with Apify on first use:

Any other client, one command (writes the config for 25+ agents, including Windsurf, Zed, Cline and Goose):

npx add-mcp "https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/google-maps-route-and-distance-matrix-scraper" --name google-maps-route-and-distance-matrix-scraper

Every file on this page is generated from the Actor's published schema: 51 of 51 checks pass (validated, not run)
  • MCP configs: 7 of 7 (Uses Apify's hosted MCP endpoint over HTTPS; The tools parameter lists exactly the chosen Actors as owner/name; JSON configs parse and use the client's top-level key and the same URL; Codex TOML has a [mcp_servers.<name>] table with url and bearer_token_env_var; CLI commands quote the same URL and use the streamable HTTP transport; One-click install links decode back to the same URL and carry no token; Only placeholders, no real token)
  • n8n workflow: 11 of 11 (It has a nodes array and a connections object; Every node has a name, type, typeVersion, position and parameters; Node names are unique; Every node type is a known n8n core node (or the Apify node); Every node uses a typeVersion that n8n ships; Every connection points at an existing node; At least one trigger starts the workflow; Every working node is reachable from a trigger; Apify calls use POST and a credential for the token; Actor input matches the Actor's published input schema; No token or credential value is embedded)
  • long-run workflow: 11 of 11 (It has a nodes array and a connections object; Every node has a name, type, typeVersion, position and parameters; Node names are unique; Every node type is a known n8n core node (or the Apify node); Every node uses a typeVersion that n8n ships; Every connection points at an existing node; At least one trigger starts the workflow; Every working node is reachable from a trigger; Apify calls use POST and a credential for the token; Actor input matches the Actor's published input schema; No token or credential value is embedded)
  • example input: 5 of 5 (The schema has no required fields; Every input key exists in the published input schema; Every value has the type the schema declares; Every choice field uses one of its published options; Numbers respect the published minimum and maximum)
  • code snippets: 4 of 4 (curl calls the documented run-sync-get-dataset-items endpoint for this Actor; Python (apify-client 3.x typed Run) and JavaScript use the official apify-client call() then read the run's dataset; Multi-line shell commands continue every line with a backslash; Token read from APIFY_TOKEN, none embedded)
  • SKILL.md: 13 of 13 (SKILL.md starts with YAML front matter; name is 1-64 lowercase letters, digits and single hyphens; name matches the skill folder name; description is present, at most 1024 characters and has no angle brackets; front matter uses only spec fields; compatibility is at most 500 characters; body has instructions; field descriptions end on whole sentences; no credential values are embedded; the token is read from APIFY_TOKEN; the run command calls this Actor's run-sync endpoint; the example input is valid JSON; the example input matches the published input schema)

What the checks cover

What a run costs

Every run pays a start fee plus a price per result. On the Free plan this Actor's start fee is $0.40 (the start event, $0.10 per GB, times its default 4 GB of memory), $0.12 on Business; results cost $0.99 per 1,000 results (pay per event). Checked 2026-11-12.

Results in one runStartResultsRun total
10$0.40$0.010$0.41
100$0.40$0.10$0.50
1,000$0.40$0.99$1.39

Plus Apify platform usage for the run, which the caller pays. A smaller memory setting lowers the start fee if the Actor still finishes. Prices can change; the Store pricing tab is the source of truth.

MCP config

One URL works in every client: https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/google-maps-route-and-distance-matrix-scraper. It exposes this Actor as a tool, plus fetch-actor-details so the agent can read the input schema before calling it. Pick your client:

Claude Code configterminal or .mcp.json

claude mcp add --transport http google-maps-route-and-distance-matrix-scraper "https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/google-maps-route-and-distance-matrix-scraper"

Run the command in your project folder. Add --scope user to make it available in every project. Full Claude Code setup

Tools your agent gets

Listed by Apify's MCP server 0.21.5 for this exact URL on 2026-11-11 (a tools/list call; nothing was run).

  • fetch-actor-detailsreads the input schema
  • get-actor-runchecks a run's status
  • get-dataset-itemsreads a run's results
  • get-key-value-store-recordreads a stored record such as a file or summary
  • abort-actor-runstops a run that is still going
  • vexaloom-labs--google-maps-route-and-distance-matrix-scraperruns the Actor and returns its results

n8n workflow

A manual and a daily trigger call the Actor through the HTTP Request node with your Apify token, then hand each record to the destination you pick. The Actor input sits in the request body, already filled with the example below.

Send the records to
  • Run by hand
  • Every day
  • Run Apify Actor

n8n workflowgoogle-maps-route-and-distance-matrix-scraper.n8n.json

Actor on Apify
{
  "name": "Google Maps Route & Distance Matrix Scraper to n8n only",
  "nodes": [
    {
      "id": "82c1f24e-882a-4e33-a7ac-6842b0f74c13",
      "name": "Run by hand",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "112dccc6-9b8b-4609-ae87-c3984a419d83",
      "name": "Every day",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "notes": "Activate the workflow to run on this schedule."
    },
    {
      "id": "0260b0ca-2b61-48d6-ad1d-b7cf258d33fb",
      "name": "Run Apify Actor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        100
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/actors/vexaloom-labs~google-maps-route-and-distance-matrix-scraper/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"mode\": \"route\",\n  \"stops\": [\n    \"Times Square, New York, NY\",\n    \"Central Park, New York, NY\"\n  ],\n  \"origins\": [\n    \"Times Square, New York, NY\",\n    \"Grand Central Terminal, New York, NY\"\n  ],\n  \"destinations\": [\n    \"Central Park, New York, NY\",\n    \"Brooklyn Bridge, New York, NY\",\n    \"JFK Airport, New York, NY\"\n  ],\n  \"maxPairs\": 100,\n  \"travelMode\": \"driving\",\n  \"avoidTolls\": false,\n  \"avoidHighways\": false,\n  \"avoidFerries\": false,\n  \"maxAlternatives\": 1,\n  \"maxItems\": 5,\n  \"includeSteps\": false,\n  \"includeStreetView\": false,\n  \"language\": \"en\",\n  \"units\": \"metric\",\n  \"requestDelayMs\": 250\n}",
        "options": {
          "timeout": 310000
        }
      },
      "notes": "Actor: vexaloom-labs/google-maps-route-and-distance-matrix-scraper. Select a Header Auth credential: name Authorization, value Bearer + your Apify token. Edit the JSON body to change the input.",
      "notesInFlow": false
    },
    {
      "id": "e8a28d56-449d-44d5-a4ac-1d6035f8ffab",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -370
      ],
      "parameters": {
        "content": "## Google Maps Route & Distance Matrix Scraper\n\nSource: [vexaloom-labs/google-maps-route-and-distance-matrix-scraper](https://apify.com/vexaloom-labs/google-maps-route-and-distance-matrix-scraper) on Apify.\n\n1. In **Run Apify Actor**, create a Header Auth credential: name `Authorization`, value `Bearer YOUR_APIFY_TOKEN` with your token.\n2. Click **Execute workflow**. Each record arrives as one n8n item.\n3. Edit the JSON body of **Run Apify Actor** to change the input.\n\nGenerated by recipeforagents.com. Validated, not executed: runs are billed to your Apify account.",
        "height": 340,
        "width": 460,
        "color": 6
      }
    }
  ],
  "connections": {
    "Run by hand": {
      "main": [
        [
          {
            "node": "Run Apify Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every day": {
      "main": [
        [
          {
            "node": "Run Apify Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}

Import with Workflows, Import from file, or paste into the canvas. Credentials are not included: you select them after import.

All 7 destination variants pass the same checks at build time. Built-in nodes only, at versions n8n has shipped since 1.80: they import on n8n Cloud and older self-hosted instances without community nodes. Prefer Apify's own node? The verified community node @apify/n8n-nodes-apify runs the same Actor with OAuth sign-in on n8n Cloud.

Runs longer than 5 minutes? The synchronous endpoint answers HTTP 408 after 300 seconds. The long-run variant starts the run, checks it every minute until it ends, then reads its dataset (HTTP Request, If and Stop and Error nodes only).

Download the long-run workflow11 of 11 checks pass, not executed

Call it from code

Run the Actor from a script or your own agent framework with the Apify API. The call waits for the run to finish and returns the records. The input is the example below.

curl

API docs on Apify
curl -X POST "https://api.apify.com/v2/actors/vexaloom-labs~google-maps-route-and-distance-matrix-scraper/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"route","stops":["Times Square, New York, NY","Central Park, New York, NY"],"origins":["Times Square, New York, NY","Grand Central Terminal, New York, NY"],"destinations":["Central Park, New York, NY","Brooklyn Bridge, New York, NY","JFK Airport, New York, NY"],"maxPairs":100,"travelMode":"driving","avoidTolls":false,"avoidHighways":false,"avoidFerries":false,"maxAlternatives":1,"maxItems":5,"includeSteps":false,"includeStreetView":false,"language":"en","units":"metric","requestDelayMs":250}'

Example input

These values come from the Actor's Store prefill and required defaults. Change the search, URL or limit before your first run.

Actor inputinput.json

{
  "mode": "route",
  "stops": [
    "Times Square, New York, NY",
    "Central Park, New York, NY"
  ],
  "origins": [
    "Times Square, New York, NY",
    "Grand Central Terminal, New York, NY"
  ],
  "destinations": [
    "Central Park, New York, NY",
    "Brooklyn Bridge, New York, NY",
    "JFK Airport, New York, NY"
  ],
  "maxPairs": 100,
  "travelMode": "driving",
  "avoidTolls": false,
  "avoidHighways": false,
  "avoidFerries": false,
  "maxAlternatives": 1,
  "maxItems": 5,
  "includeSteps": false,
  "includeStreetView": false,
  "language": "en",
  "units": "metric",
  "requestDelayMs": 250
}

FieldTypeWhat it does
mode string (3 options) What to scrape: one route (with optional waypoints), a distance matrix, or a list of Google Maps directions URLs.
stops array Ordered stops for route mode: 2–10 locations. The first is the origin, the last is the destination, and everything in between becomes a waypoint.
origins array Starting locations for matrix mode. Each origin is paired with every destination below.
destinations array Ending locations for matrix mode. Each destination is paired with every origin above.
maxPairs integer Maximum number of origin × destination pairs to request in matrix mode. Pairs beyond this cap are left out.
travelMode string (4 options) How to travel between the stops.
avoidTolls boolean Driving only — ask Google Maps to avoid toll roads. If no toll-free route exists, Google may still return a toll route.
avoidHighways boolean Driving only — ask Google Maps to avoid highways and motorways. If no practical alternative exists, Google may still return a highway route.
avoidFerries boolean Driving only — prefer routes without ferry crossings. If every route uses a ferry, the result is still returned and marked with avoidanceUnmet.
maxAlternatives integer Maximum number of route alternatives to return per trip, including Google's recommended route. Applies to route and URLs modes. Google usually supplies up to 3 alternatives.
maxItems integer Global cap on the number of records pushed to the dataset.
includeSteps boolean Add turn-by-turn steps with instruction, distance, duration, maneuver, coordinates and route geometry for every returned route.
includeStreetView boolean Add a Street View panorama ID and thumbnail URL to each step where Google publishes one. This also enables step details.
language string (11 options) Language for instructions and other localized text.
units string (2 options) Preferred distance units for the formatted distance fields. Meter values stay unchanged.
requestDelayMs integer Pause between directions requests. A small delay keeps large matrix runs polite and reduces rate limiting.

3 more optional fields on the Store input tab.

What your agent receives

Each run returns a list of records. The Actor publishes 35 fields, starting with origin, destination, originResolved, destinationResolved.

Field
recordType
origin
destination
originResolved
destinationResolved
routeName
routeIndex
isRecommended
travelMode
distance
25 more fields
Field
distanceMeters
duration
durationSeconds
durationInTraffic
typicalDuration
noTrafficDuration
trafficRange
trafficCondition
departureTime
arrivalTime
fare
availableModes
googleMapsUrl
sourceUrl
scrapedAt
steps
notes
originIndex
destinationIndex
pairIndex
routesAvailable
transitLine
transitVehicle
transitHeadsign
transit

Agent skill

A SKILL.md in the open Agent Skills format. It teaches Claude Code, Codex and other skill-aware agents when to call this Actor, how to build the input and how to read the result, using the API directly.

SKILL.mdgoogle-maps-route-and-distance-matrix-scraper/SKILL.md

---
name: google-maps-route-and-distance-matrix-scraper
description: "Route, matrix and URL records from Google Maps directions — resolved stops, distance, duration, traffic, route alternatives, steps, geometry, transit lines and fares. Runs the Apify Actor vexaloom-labs/google-maps-route-and-distance-matrix-scraper. Use when the user needs Google Maps data with fields such as recordType, origin, destination, originResolved, destinationResolved, routeName and an Apify token is available."
compatibility: "Needs network access, curl, and an APIFY_TOKEN environment variable. Runs are billed to the token owner's Apify account."
metadata:
  actor: "vexaloom-labs/google-maps-route-and-distance-matrix-scraper"
  store-url: "https://apify.com/vexaloom-labs/google-maps-route-and-distance-matrix-scraper"
---

# Google Maps Route & Distance Matrix Scraper

Use this skill to fetch Google Maps data with the Apify Actor `vexaloom-labs/google-maps-route-and-distance-matrix-scraper` and work with the returned rows.

## Before running

1. Check that `APIFY_TOKEN` is set in the environment. Never print it or write it to a file.
2. Build `input.json` from the user's request using the fields below. Keep limits small for a first run.
3. Confirm the search terms or URLs with the user if the request is ambiguous.

## Input fields

| Field | Type | Meaning |
| --- | --- | --- |
| `mode` | one of `route`, `matrix`, `urls` | What to scrape: one route (with optional waypoints), a distance matrix, or a list of Google Maps directions URLs. |
| `stops` | array | Ordered stops for route mode: 2–10 locations. The first is the origin, the last is the destination, and everything in between becomes a waypoint. |
| `origins` | array | Starting locations for matrix mode. Each origin is paired with every destination below. |
| `destinations` | array | Ending locations for matrix mode. Each destination is paired with every origin above. |
| `maxPairs` | integer | Maximum number of origin × destination pairs to request in matrix mode. Pairs beyond this cap are left out. |
| `travelMode` | one of `driving`, `walking`, `bicycling`, `transit` | How to travel between the stops. |
| `avoidTolls` | boolean | Driving only — ask Google Maps to avoid toll roads. If no toll-free route exists, Google may still return a toll route. |
| `avoidHighways` | boolean | Driving only — ask Google Maps to avoid highways and motorways. If no practical alternative exists, Google may still return a highway route. |
| `avoidFerries` | boolean | Driving only — prefer routes without ferry crossings. If every route uses a ferry, the result is still returned and marked with avoidanceUnmet. |
| `maxAlternatives` | integer | Maximum number of route alternatives to return per trip, including Google's recommended route. Applies to route and URLs modes. Google usually supplies up to 3 alternatives. |
| `maxItems` | integer | Global cap on the number of records pushed to the dataset. |
| `includeSteps` | boolean | Add turn-by-turn steps with instruction, distance, duration, maneuver, coordinates and route geometry for every returned route. |
| `includeStreetView` | boolean | Add a Street View panorama ID and thumbnail URL to each step where Google publishes one. This also enables step details. |
| `language` | string | Language for instructions and other localized text. |

Example `input.json` (the Actor's published prefill):

```json
{
  "mode": "route",
  "stops": [
    "Times Square, New York, NY",
    "Central Park, New York, NY"
  ],
  "origins": [
    "Times Square, New York, NY",
    "Grand Central Terminal, New York, NY"
  ],
  "destinations": [
    "Central Park, New York, NY",
    "Brooklyn Bridge, New York, NY",
    "JFK Airport, New York, NY"
  ],
  "maxPairs": 100,
  "travelMode": "driving",
  "avoidTolls": false,
  "avoidHighways": false,
  "avoidFerries": false,
  "maxAlternatives": 1,
  "maxItems": 5,
  "includeSteps": false,
  "includeStreetView": false,
  "language": "en",
  "units": "metric",
  "requestDelayMs": 250
}
```

## Run

```bash
curl -sS -X POST "https://api.apify.com/v2/acts/vexaloom-labs~google-maps-route-and-distance-matrix-scraper/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d @input.json > results.json
```

The call waits for the run to finish and returns the dataset items as a JSON array. If the run needs more than 300 seconds the API answers with HTTP 408; then start the run with `POST /v2/acts/vexaloom-labs~google-maps-route-and-distance-matrix-scraper/runs`, poll `GET /v2/actor-runs/{runId}` until `SUCCEEDED`, and read `GET /v2/datasets/{defaultDatasetId}/items`.

## Output

Each item is one record. Published fields include: `recordType`, `origin`, `destination`, `originResolved`, `destinationResolved`, `routeName`, `routeIndex`, `isRecommended`, `travelMode`, `distance`, `distanceMeters`, `duration`, `durationSeconds`, `durationInTraffic`, `typicalDuration`, `noTrafficDuration`, `trafficRange`, `trafficCondition`, `departureTime`, `arrivalTime`.

Summarise what was found, cite the record URLs when present, and say how many items came back. Do not invent values for empty fields.

  • Claude Code: save it as ~/.claude/skills/google-maps-route-and-distance-matrix-scraper/SKILL.md, or .claude/skills/google-maps-route-and-distance-matrix-scraper/SKILL.md in a project.
  • Codex and other agents: ~/.agents/skills/google-maps-route-and-distance-matrix-scraper/SKILL.md, or .agents/skills/google-maps-route-and-distance-matrix-scraper/ in a project.
  • Or let the skills CLI place it for your agent: npx skills add https://recipeforagents.com --skill google-maps-route-and-distance-matrix-scraper
  • Set APIFY_TOKEN in the agent's environment.

Good jobs for this Actor

  • Compare distance and duration across origin–destination pairs for a travel-planning workflow.
  • Present route alternatives with routeName, isRecommended and trafficCondition.
  • Build an itinerary from ordered stops and includeSteps to retrieve instructions and route geometry.
  • Attach transit lines and fares to journey summaries when Google Maps returns them.

Prompts to try

  • Find driving routes from Times Square, New York, NY to Central Park, New York, NY, and include turn-by-turn steps.
  • Build a travel-time matrix from Times Square and Grand Central Terminal to Central Park, Brooklyn Bridge and JFK Airport.
  • Compare walking and bicycling routes from Times Square to Central Park, keeping the results grouped by travelMode.

Troubleshooting

Why does the client say Unauthorized or invalid token?

Every Apify Actor tool needs a signed-in Apify account. Reconnect the server so the OAuth sign-in runs again, or switch to the token variant: an Authorization: Bearer header with an API token from Apify Console, Settings, API and integrations. For a local server the token must be in the server's own env block, not only in your shell.

Source: Apify MCP server README

Why did my agent's tool list change after an update?

Without a tools parameter Apify's server loads its default tool set, which changes between releases. The URLs on this site pin the tools with ?tools=, so the agent always gets the same Actor tool plus fetch-actor-details. Apify's README gives the same advice for production.

Source: Apify MCP server README

What happens when the agent sends input the Actor rejects?

The server answers with the Actor's input schema, so the agent can fix the arguments and call again. The fetch-actor-details tool in every scoped URL lets it read that schema before the first call.

Source: Apify MCP server README

Questions

How do route and matrix modes differ?

Route mode follows the ordered locations in stops, using intermediate locations as waypoints. Matrix mode pairs origins with destinations, with maxPairs limiting how many pairs are requested.

Can driving routes avoid tolls, highways and ferries?

avoidTolls, avoidHighways and avoidFerries express driving preferences. Google Maps can still return a route using those features when alternatives are unavailable or impractical.

How are detailed directions enabled?

Set includeSteps to add instructions, maneuvers, coordinates and route geometry. includeStreetView also enables step details and adds panorama references where Google publishes them.

How do I connect Google Maps Route & Distance Matrix Scraper to Claude?

In Claude Code run: claude mcp add --transport http google-maps-route-and-distance-matrix-scraper "https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/google-maps-route-and-distance-matrix-scraper". In Claude Desktop or claude.ai add a custom connector with the URL https://mcp.apify.com/?tools=fetch-actor-details,vexaloom-labs/google-maps-route-and-distance-matrix-scraper and sign in to Apify. The agent then gets one tool for this Actor plus a tool that reads its input schema.

What input does Google Maps Route & Distance Matrix Scraper need?

No field is required by the published input schema. The example on this page uses the Actor's own Store prefill, so it is a sensible first run.

What does Google Maps Route & Distance Matrix Scraper cost to run?

The Apify Store lists $0.99 per 1,000 results (pay per event) for this Actor, checked 2026-11-12. Runs are billed to the Apify account whose token or sign-in the agent uses; Apify platform usage can add to that.

Which tools does the MCP config give my agent?

6 tools: fetch-actor-details, get-actor-run, get-dataset-items, get-key-value-store-record, abort-actor-run, vexaloom-labs--google-maps-route-and-distance-matrix-scraper. Apify's MCP server listed them for this exact URL on 2026-11-11.