# Google Direction Scraper (`dev_bodex/google-direction-scraper`) Actor

This actor automates extracting route directions from Google Maps. Using Node.js and Puppeteer, it retrieves travel routes, distances, and estimated times for various transport modes, offering structured data for navigation, logistics, or travel planning applications.

- **URL**: https://apify.com/dev\_bodex/google-direction-scraper.md
- **Developed by:** [Eniola Bode](https://apify.com/dev_bodex) (community)
- **Categories:** Jobs, Lead generation, Travel
- **Stats:** 30 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$25.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

## 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 Direction Scraper

This Apify actor scrapes detailed directions from Google Maps, providing route information such as distance, travel time, and step-by-step instructions for various modes of transportation (driving, walking, cycling, public transport, etc.). This is useful for generating route data for apps, transportation analysis, or travel planning.

## Features

- **Input**: Provide starting and destination locations (either as addresses or coordinates).

- **Modes of Transport**: Supports multiple modes of transportation:
  **Driving**,
  **Walking**,
  **Cycling**,
  **Flight**,
  **Transit**,
  **Two Wheeler**,

- **Detailed Route Information**: Retrieves essential route details:
  **Total distance**,
  **Estimated travel time**,
  **Step-by-step directions (turn-by-turn)**,
  **Transportation mode (e.g., driving, walking, cycling)**,
  **Estimated arrival time for public transportation**,
  **Directions with Google Maps link**,

- **Output Formats**: Results are available in JSON format for easy integration and further use.

## How It Works

This actor queries Google Maps for directions between the specified origin and destination locations and parses the results to extract key details about the route, travel time, distance, and steps.

## Input

The input is a JSON object that includes the following fields:

```javascript
{
  "source": "New York",
  "destination": "Washington"
}
```

- **source**: The starting location for the route (can be an address or coordinates).
- **destination**: The destination location for the route (can be an address or coordinates).

## Output

The output is a JSON object containing detailed route information for the trip. Here’s an example of what the output might look like:

```javascript
[{
  "source": "New York",
  "destination": "Washington",
  "mode": {
    "best": [
      {
        "mode": "Driving",
        "duration": "43 hr",
        "metre": "2,919 miles",
        "direction": "via I-80 W",
        "means": null,
        "info": "43 hr without traffic\n This route has tolls.\n Your destination is in a different time zone."
      },
      {
        "mode": "Driving",
        "duration": "43 hr",
        "metre": "2,923 miles",
        "direction": "via I-40 W",
        "means": null,
        "info": "43 hr without traffic"
      },
      {
        "mode": "Flights",
        "duration": "7 hr 35 min",
        "metre": null,
        "direction": "New York, NY—Fresno, CA",
        "means": null,
        "info": null
      }
    ],
    "walk": [
      {
        "mode": "Walking",
        "duration": "1,033 hr",
        "metre": "2,830 miles",
        "direction": "via IA-2 E",
        "means": null,
        "info": " This route includes a ferry.\n This route has restricted usage or private roads.\n Your destination is in a different time zone."
      }
    ],
    "driving": [
      {
        "mode": "Driving",
        "duration": "43 hr",
        "metre": "2,919 miles",
        "direction": "via I-80 W",
        "means": null,
        "info": "43 hr without traffic\n This route has tolls.\n Your destination is in a different time zone."
      },
      {
        "mode": "Driving",
        "duration": "43 hr",
        "metre": "2,923 miles",
        "direction": "via I-40 W",
        "means": null,
        "info": "43 hr without traffic"
      },
      {
        "mode": "Driving",
        "duration": "43 hr",
        "metre": "2,954 miles",
        "direction": "via I-70 W",
        "means": null,
        "info": "43 hr without traffic"
      }
    ],
    "two-wheeler": null,
    "transit": null,
    "flight": [
      {
        "mode": "Flights",
        "duration": "7 hr 35 min+ - from $481",
        "metre": null,
        "direction": "New York, NY—Fresno, CA",
        "means": null,
        "info": null
      }
    ],
    "cycling": [
      {
        "mode": "Cycling",
        "duration": "296 hr",
        "metre": "3,533 miles",
        "direction": "via Empire State Trl",
        "means": null,
        "info": " This route includes a ferry.\n This route crosses through Canada.\n This route has restricted usage or private roads.\n Your destination is in a different time zone."
      }
    ]
  }
}]
```

## Key Scraped Data

- **Source:** Starting location.
- **Destination:** Final destination.
- **Distance:** Total distance of the route.
- \*\*Duration: Estimated travel time.
- **Mode of Transport:** Driving, walking, cycling, or transit.
- **Steps:** Turn-by-turn directions for each leg of the journey.

## Output Formats

JSON

## Usage

\#On the Apify Platform

1. Go to the Google Direction Scraper actor on Apify.
2. Click Try for Free.
3. Provide the origin, destination, and mode of transport.
4. Run the actor and wait for it to complete.
5. Download the results in your preferred format (JSON).

## Locally via Apify CLI

1. Install Apify CLI.
2. Run the actor locally using the following command:

```javascript
apify run your-username/google-direction-scraper --input='{"source": "New York", "destination": "Washington"}'
```

## Input Example

```javascript
{
  "source": "New York",
  "destination": "Washington"
}
```

This input will fetch the directions from New York to Washington.

## Use Cases

- **Travel and Route Planning:** Get detailed directions between locations for driving, walking, or public transport.
- **Logistics and Transportation:** Automate route generation for delivery services, ridesharing, or commuting apps.
- **Research and Analysis:** Extract travel time and distance data for city planning, transportation studies, or efficiency improvements.

## Limitations

1. Only fetches directions available via Google Maps.
2. Public transportation data may vary based on the region and time of day.

# Actor input Schema

## `source` (type: `string`):

The starting location.

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

The ending location.

## Actor input object example

```json
{
  "source": "New York",
  "destination": "Washington"
}
```

# 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 = {
    "source": "New York",
    "destination": "Washington"
};

// Run the Actor and wait for it to finish
const run = await client.actor("dev_bodex/google-direction-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 = {
    "source": "New York",
    "destination": "Washington",
}

# Run the Actor and wait for it to finish
run = client.actor("dev_bodex/google-direction-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 '{
  "source": "New York",
  "destination": "Washington"
}' |
apify call dev_bodex/google-direction-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dev_bodex/google-direction-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/ho2TGlmU5HmEBuBi8/builds/xzYL2VRuKZ7DbBUoq/openapi.json
