# Google Maps Directions Scraper: Distance Matrix, Traffic & ETA (`scrapebench/google-maps-directions-scraper`) Actor

Distance and travel time between address pairs or a whole origins x destinations matrix, as Google Maps shows them: drive time in traffic for a set departure or arrival, route alternatives with tolls flagged, transit legs, and the resolved place for every stop. No API key.

- **URL**: https://apify.com/scrapebench/google-maps-directions-scraper.md
- **Developed by:** [ScrapeBench](https://apify.com/scrapebench) (community)
- **Categories:** Travel
- **Features:** Limited permissions
- **Stats:** 4 total users, 3 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.002 / route request

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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: Distance Matrix, Traffic & ETA

### Pain points

- Google's Directions and Distance Matrix APIs need a Google Cloud project, billing and an API key before the first request.
- Free-text stops resolve to whatever Google picks: on 2026-11-08 a bare '90210' resolved to a salon in Louisiana on one connection and to Beverly Hills, Colorado on another, and nothing in a plain distance figure shows it.
- Copying drive times for a list of addresses out of the Google Maps page one route at a time takes hours for a few hundred rows.

### What we solve

- Pairs or a full origins x destinations matrix in one run, in up to four travel modes.
- Predicted traffic for a departure or arrival time you choose, or live traffic now, with Google's typical range beside it.
- The place Google resolved every stop to (name, address, latitude, longitude, place ID) on every row, so a wrong match is visible; a stop that resolves to nothing is a free row, never a billed route.
- Avoid tolls, highways or ferries, alternatives on or off, and optional turn-by-turn steps.

### Summary

Give it origin and destination pairs, or a list of origins and a list of destinations to route every origin to every destination, and pick driving, transit, walking or cycling. Each route comes back as one row with its distance in metres, kilometres and miles, the travel time, and for driving the time in traffic and Google's typical range, now or for a departure or arrival time you set. Alternatives come back as their own rows, with the roads each one takes and a toll flag. Transit rows carry the departure and arrival times and every leg: line, vehicle, headsign, agency, boarding and alighting stop and the number of stops. Turn-by-turn steps are one switch away. Every stop is free text that Google resolves inside the request, so every row also carries the name, address, coordinates and place ID Google resolved each stop to, beside what you typed. No Google Cloud account or API key.

### Who it's for

- Delivery and logistics teams sizing routes from a depot to customer addresses
- Field-service dispatch: drive time between jobs and territory balancing
- Real-estate teams putting commute times on listings
- Sales ops assigning accounts to the nearest rep
- Site-selection and market analysts building drive-time catchments
- Transport and urban researchers logging rush-hour durations
- AI agents answering 'how long from A to B' without a Google Cloud key

### How to use

Set the input, run the actor, and collect results from the run's dataset (export to JSON/CSV/Excel, or pull via the Apify API). Example input:

```json
{
  "routes": [
    {
      "origin": "San Jose, CA",
      "destination": "San Francisco, CA"
    }
  ],
  "travelMode": [
    "driving",
    "transit"
  ],
  "alternatives": true
}
```

See **Inputs** below for every available field.

### What you get

One row per record:

| Field | Description |
|---|---|
| `origin` | The origin as you sent it |
| `destination` | The destination as you sent it |
| `travel_mode` | driving, transit, walking or cycling |
| `route_index` | 1 = Google's first route; 2 and up = alternatives |
| `origin_name` | The place Google resolved the origin to |
| `origin_address` | Google's full label for the resolved origin |
| `origin_latitude` | Latitude of the resolved origin |
| `origin_longitude` | Longitude of the resolved origin |
| `origin_place_id` | Google place ID of the resolved origin |
| `destination_name` | The place Google resolved the destination to |
| `destination_address` | Google's full label for the resolved destination |
| `destination_latitude` | Latitude of the resolved destination |
| `destination_longitude` | Longitude of the resolved destination |
| `destination_place_id` | Google place ID of the resolved destination |
| `via` | The roads Google names the route by (driving, walking, cycling) |
| `distance_m` | Route length in metres (also distance_km and distance_miles) |
| `distance_text` | Distance label in the unit you chose |
| `duration_s` | Travel time in seconds (driving: without traffic; also duration_min) |
| `duration_text` | Google's travel-time label |
| `duration_in_traffic_s` | Driving: time in traffic, live or predicted for departAt / arriveBy (and its label) |
| `typical_min_s` | Driving: low end of Google's typical range (typical_max_s, typical_range_text) |
| `has_tolls` | True when Google flags tolls on the route |
| `advisories` | Google's notes on the route |
| `frequency` | Transit: how often the service runs |
| `departure_time` | Transit: local departure time (arrival_time, timezone beside it) |
| `agencies` | Transit: the agencies running the trip |
| `transit_legs` | Transit: each walk and ride; a ride has line, vehicle, headsign, agency, from and to stop, times, number of stops, service alerts |
| `steps` | Turn-by-turn instructions with maneuver, distance and duration (with Include steps on) |
| `google_maps_url` | Opens these directions on Google Maps |
| `source_url` | Where the row came from (its Google Maps link) |

Sample:

```json
{
  "origin": "San Jose, CA",
  "destination": "San Francisco, CA",
  "travel_mode": "driving",
  "route_index": 1,
  "origin_name": "San Jose",
  "origin_address": "San Jose, California",
  "origin_latitude": 37.33874,
  "origin_longitude": -121.88525249999999,
  "origin_place_id": "ChIJ9T_5iuTKj4ARe3GfygqMnbk",
  "destination_name": "San Francisco",
  "destination_address": "San Francisco, California",
  "destination_latitude": 37.7749295,
  "destination_longitude": -122.4194155,
  "destination_place_id": "ChIJIQBpAG2ahYAR_6128GcTUEo",
  "via": "US-101 N",
  "distance_m": 77963,
  "distance_km": 77.96,
  "distance_miles": 48.44,
  "distance_text": "48.4 miles",
  "duration_s": 3508,
  "duration_min": 58.5,
  "duration_text": "58 min",
  "duration_in_traffic_s": 6000,
  "duration_in_traffic_text": "1 hr 40 min",
  "typical_min_s": 4500,
  "typical_max_s": 7800,
  "typical_range_text": "1 hr 15 min to 2 hr 10 min",
  "has_tolls": false,
  "advisories": [],
  "frequency": null,
  "departure_time": null,
  "arrival_time": null,
  "timezone": null,
  "agencies": [],
  "transit_legs": [],
  "steps": null,
  "google_maps_url": "https://www.google.com/maps/dir/?api=1&origin=San+Jose%2C+CA&destination=San+Francisco%2C+CA&travelmode=driving",
  "source_url": "https://www.google.com/maps/dir/?api=1&origin=San+Jose%2C+CA&destination=San+Francisco%2C+CA&travelmode=driving"
}
```

### Inputs

| Field | Required | Type | Default | Description |
|---|---|---|---|---|
| `routes` | no | array | `[{"origin": "San Jose, CA", "destination": "San Francisco, CA"}]` | One entry per trip: {"origin": "...", "destination": "..."}, or the text "Origin -> Destination" (also → or |). A single "A to B" text is never split, because place names can contain "to". A stop can be a full address, a landmark, "ZIP, state" or "lat,lng"; add the state to a city name. |
| `origin` | no | string | — | One starting point. Combined with Destination / Destinations below. |
| `destination` | no | string | — | One end point. Combined with Origin / Origins. |
| `origins` | no | array | `[]` | Matrix mode: every origin is routed to every destination (10 origins x 20 destinations = 200 routes). One best route per pair unless Alternatives is switched on. |
| `destinations` | no | array | `[]` | Matrix mode: the destinations every origin is routed to. |
| `travelMode` | no | array | `["driving"]` | One or more of: driving, transit, walking, cycling. Each pair is routed once per mode. Anything else is ignored (logged). |
| `departAt` | no | string | — | Local date and time at the origin, e.g. 2026-11-10 08:00, for Google's predicted traffic or the transit timetable at that moment. Empty = now. A past date rolls forward to the same weekday and time in the coming week, so a saved schedule keeps working. Set this or Arrive by, not both. |
| `arriveBy` | no | string | — | Local date and time to arrive, e.g. 2026-11-10 09:00. Set this or Depart at, not both. |
| `avoid` | no | array | `[]` | Any of: tolls, highways, ferries (driving routes). |
| `alternatives` | no | boolean | — | On: every alternative Google offers, one row each (usually up to three driving routes; transit lists each departure, 6 for San Jose to San Francisco on 2026-11-08), at no extra charge. Off: the best route only. Left unset: alternatives for Routes, the best route only for an Origins x Destinations matrix. |
| `includeSteps` | no | boolean | `false` | Add the step-by-step instructions (maneuver, distance, duration) to each row. Makes rows larger. |
| `distanceUnit` | no | string | `"miles"` | Unit of the distance_text label. distance_m, distance_km and distance_miles are on every row either way. |
| `language` | no | string | `"en"` | Language of Google's labels and instructions, as a code (en, es, fr, de, ...). |
| `maxResults` | no | integer | `1000` | Cap on route rows for the WHOLE run (not per pair). A spend cap: the run stops once it has this many, and a free row lists the pairs not run. |
| `proxyConfiguration` | no | object | `{"useApifyProxy": false}` | Off by default: Google answered without one when tested. Switch it on only if your runs come back blocked. |

### Pricing (Pay Per Event)

You pay per result (`route`) — **no charge for empty runs**. Example: **1000 route requests** at *$0.002/result* ≈ **$2.00**.

$2.00 per 1,000 route requests, alternatives included, no start fee (2026-11-14). A 10 x 20 matrix is 200 requests, $0.40; San Jose to San Francisco by car and transit is 2 requests ($0.004) for 9 rows.

### Use cases

- Delivery or service territory: drive time in weekday-morning traffic from one depot to every customer address, one row per address (origins: the depot; destinations: the addresses; departAt; alternatives off).
- Commute times on a property listing: one home to the office, the station and the airport, driving and transit, arriving by 9:00 (origin + destinations, travelMode driving and transit, arriveBy).
- Nearest-rep assignment: a reps x accounts matrix, then keep the shortest duration per account in your sheet (origins: reps; destinations: accounts).
- Toll and highway comparison: the same trip with and without tolls or highways, side by side (San Francisco to Los Angeles: I-5 in 5 h 57 against CA-1 in 10 h 39 avoiding all three, 2026-11-08).
- Transit access check: a list of addresses to one hub, arrive by 8:00, with the lines, boarding and alighting stops and agency per leg (travelMode transit, arriveBy, includeSteps).
- Rush-hour log: schedule the same routes every weekday at 8:00 and record duration_in_traffic over time (San Jose to San Francisco: 1 h 40 for a Tuesday 08:00 departure against 1 h 1 off-peak, 2026-11-08).
- Coordinates in, resolved places out: lat,lng points from a GPS export routed to a destination, with Google's resolved address and place ID on each row.

### Why this actor

- One input for pairs or a whole origins x destinations matrix, in several travel modes at once.
- Traffic now or predicted for a departure or arrival time, plus Google's typical range, on every driving row.
- The resolved place of both stops on every row, and free rows (never billed) for a stop Google cannot find.

### Limitations & updates

Data is what Google Maps' directions show at the time of the run: traffic is Google's live or predicted figure, and transit times follow the published timetable. Each stop is resolved by Google from free text, so a vague stop can land somewhere unexpected; check the resolved address on each row. One origin and one destination per route (no intermediate stops). Transit fares, route geometry (polylines) and Street View images are not returned. Distance labels follow Google's US settings (miles) unless you choose kilometres; metres, kilometres and miles are on every row.

### FAQ

**Why did a stop come back as the wrong place?**

Each stop is free text that Google Maps resolves inside the request, the same way the directions page does. A full address, a landmark ('JFK Airport'), 'ZIP, state' ('90210, CA') or 'lat,lng' resolves well; a bare ZIP code or a city with no state can resolve to a business or a same-named town elsewhere (on 2026-11-08 '90210' alone resolved to a salon in Louisiana on one connection and to Beverly Hills, Colorado on another). Every row carries the resolved name, address, latitude, longitude and place ID of each stop beside your input, so a wrong resolution is visible, and a stop that resolves to nothing comes back as a free no_match row, never a billed route.

**How is traffic handled?**

Driving rows carry duration (no traffic), duration_in_traffic and Google's typical range (for example '3 hr 40 min to 5 hr 16 min'). Leave the time empty for live traffic now, or set departAt or arriveBy as a local date and time to get Google's predicted traffic for that moment: San Jose to San Francisco read 1 h 40 for a Tuesday 08:00 departure against 1 h 1 at the time of the check (2026-11-08). Walking and cycling rows have no traffic fields; transit rows carry departure and arrival times instead.

**How do I send routes?**

Three ways, which combine: Routes, a list of {"origin": "...", "destination": "..."} pairs (or the text "Origin -> Destination"); Origin and Destination for one trip; or Origins and Destinations, which routes every origin to every destination. A single text like "Reno to Sacramento" is never split, because a place name can contain "to".

**How am I charged?**

$0.002 per route request: one origin-destination pair in one travel mode, whatever number of rows it returns. With alternatives on (the default for route pairs) a driving, walking or cycling pair usually returns up to three rows, one per alternative, and a transit pair one row per departure Google offers (6 for San Jose to San Francisco, 2026-11-08); the alternatives cost nothing extra. Matrix runs return one best route per origin-destination pair unless you switch alternatives on. Rows that explain something (a stop that did not resolve, a refused request, a reached cap, input to fix) are free. A 10 x 20 matrix is 200 requests, $0.40. Set Maximum routes to cap a run's spend.

### Guides & use cases

Written up on **[scrapebench.dev](https://scrapebench.dev)** — the bench that runs and verifies this actor against the live source every night:

- **How-to:** [How to run Google Maps Directions Scraper: Distance Matrix, Traffic & ETA](https://scrapebench.dev/guides/how-to-google-maps-directions-scraper/)
- **Use case:** [Drive time in weekday-morning traffic from one depot to many addresses](https://scrapebench.dev/use-cases/depot-drive-time-matrix/)

More actors, coverage and nightly verification results: **[scrapebench.dev](https://scrapebench.dev)**

### Works with AI assistants (MCP)

Callable as an MCP tool, so Claude, Cursor, VS Code Copilot and other MCP clients can run it directly. Grab the config from the [MCP tab](https://apify.com/scrapebench/google-maps-directions-scraper/api/mcp) on this page — Apify hosts the server and keeps that snippet current, and OAuth signs you in on first connect, so no API token goes in your config file.

Then just ask:

> "How long is the drive from San Jose, CA to San Francisco, CA leaving Tuesday at 8:00 AM in traffic, and what is the transit option with its legs?"

Two stops, two modes: 9 rows on 2026-11-08 (3 driving alternatives, 6 transit departures). Add the state to a city name and avoid a bare ZIP code, so the stop resolves to the place you mean; every row carries Google's resolved address and place ID. Runs started this way bill exactly like any other run.

### Data & lawful use

This actor collects publicly available information that Google (Google Maps) publishes for public
lookup — licence records, business listings and the contact details professionals list there.
Some of it identifies individuals (sole proprietors, licence holders, agents), so treat any
names, phone numbers and emails in your results as personal data.

When you run this actor, you decide what is collected and what it is used for, so you are the
controller of that data and we act only as your processor (Apify Standard Actor Contract).
You need a lawful basis for your use, must honour opt-out and deletion requests, and must
follow the marketing rules that apply to you (CAN-SPAM, TCPA, GDPR, CCPA and similar).
Don't use the output for unsolicited bulk messaging, for screening covered by the FCRA, or
for anything the source's own terms forbid.

Your results are stored in your own Apify account. We don't keep a copy of your results and
don't sell or share them.

### Disclaimer

This is an independent tool. It is not affiliated with, endorsed by or sponsored by
Google (Google Maps). Names and marks are used only to describe the data source. Records are
provided as published by the source and may be out of date or incomplete. For anything
consequential (hiring, a permit, a legal decision), confirm the record with the issuing
agency. You are responsible for making sure your use complies with applicable law and the
source's terms.

### Need help?

Open an issue on this actor's **Issues** tab and we'll respond there. Bug reports, missing
fields and feature requests are all welcome. Guides and examples: [scrapebench.dev](https://scrapebench.dev).

If you are a person named in this data and want your record removed from our copy, email
apify-help@scrapebench.dev; the source agency remains the official record.

Your run may be used to improve our services. If something looks off, or you want this actor to fit your use better, please share your run data with us: [Apify Console → Settings → Security → Share run data with developers](https://console.apify.com/settings/security). It lets us see exactly what went wrong and keep improving the actor.

If this actor saved you time, a short review on its Store page helps other buyers find it.

# Actor input Schema

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

One entry per trip: {"origin": "...", "destination": "..."}, or the text "Origin -> Destination" (also → or |). A single "A to B" text is never split, because place names can contain "to". A stop can be a full address, a landmark, "ZIP, state" or "lat,lng"; add the state to a city name.

## `origin` (type: `string`):

One starting point. Combined with Destination / Destinations below.

## `destination` (type: `string`):

One end point. Combined with Origin / Origins.

## `origins` (type: `array`):

Matrix mode: every origin is routed to every destination (10 origins x 20 destinations = 200 routes). One best route per pair unless Alternatives is switched on.

## `destinations` (type: `array`):

Matrix mode: the destinations every origin is routed to.

## `travelMode` (type: `array`):

One or more of: driving, transit, walking, cycling. Each pair is routed once per mode. Anything else is ignored (logged).

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

Local date and time at the origin, e.g. 2026-11-10 08:00, for Google's predicted traffic or the transit timetable at that moment. Empty = now. A past date rolls forward to the same weekday and time in the coming week, so a saved schedule keeps working. Set this or Arrive by, not both.

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

Local date and time to arrive, e.g. 2026-11-10 09:00. Set this or Depart at, not both.

## `avoid` (type: `array`):

Any of: tolls, highways, ferries (driving routes).

## `alternatives` (type: `boolean`):

On: every alternative Google offers, one row each (usually up to three driving routes; transit lists each departure, 6 for San Jose to San Francisco on 2026-11-08), at no extra charge. Off: the best route only. Left unset: alternatives for Routes, the best route only for an Origins x Destinations matrix.

## `includeSteps` (type: `boolean`):

Add the step-by-step instructions (maneuver, distance, duration) to each row. Makes rows larger.

## `distanceUnit` (type: `string`):

Unit of the distance_text label. distance_m, distance_km and distance_miles are on every row either way.

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

Language of Google's labels and instructions, as a code (en, es, fr, de, ...).

## `maxResults` (type: `integer`):

Cap on route rows for the WHOLE run (not per pair). A spend cap: the run stops once it has this many, and a free row lists the pairs not run.

## `proxyConfiguration` (type: `object`):

Off by default: Google answered without one when tested. Switch it on only if your runs come back blocked.

## Actor input object example

```json
{
  "routes": [
    {
      "origin": "San Jose, CA",
      "destination": "San Francisco, CA"
    }
  ],
  "origins": [],
  "destinations": [],
  "travelMode": [
    "driving"
  ],
  "avoid": [],
  "includeSteps": false,
  "distanceUnit": "miles",
  "language": "en",
  "maxResults": 1000,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

One row per route: resolved origin and destination, mode, via, distance, duration, duration in traffic, typical range, tolls, transit legs, optional steps.

# 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": "San Jose, CA",
            "destination": "San Francisco, CA"
        }
    ],
    "travelMode": [
        "driving"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapebench/google-maps-directions-scraper").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": "San Jose, CA",
            "destination": "San Francisco, CA",
        }],
    "travelMode": ["driving"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("scrapebench/google-maps-directions-scraper").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": "San Jose, CA",
      "destination": "San Francisco, CA"
    }
  ],
  "travelMode": [
    "driving"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call scrapebench/google-maps-directions-scraper --silent --output-dataset

```

## MCP server setup

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

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/mb1DYQYH9A2VoImQd/builds/bkKOyrgylk9dKC3RM/openapi.json
