Google Maps Directions API avatar

Google Maps Directions API

Pricing

from $0.01 / 1,000 results

Go to Apify Store
Google Maps Directions API

Google Maps Directions API

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.

Pricing

from $0.01 / 1,000 results

Rating

5.0

(4)

Developer

John

John

Maintained by Community

Actor stats

4

Bookmarked

62

Total users

21

Monthly active users

a day ago

Last modified

Share

πŸ—ΊοΈ 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

FieldDescription
start, endThe origin and destination used for the lookup.
travel_modeThe requested mode: best, driving, cycling, walking, transit, flight, or two-wheeler.
directions_foundtrue if at least one route option was returned.
directions_countNumber of route options in directions.
best_duration, best_distanceETA and distance of the first (recommended) option, e.g. 3 hr 38 min, 215 miles.
places_infoResolved origin and destination: formatted address, place ID, and GPS coordinates.
directionsEach 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.
durationsTravel time by mode (driving, transit, walking, cycling, flight) for this origin and destination.
google_maps_directions_urlA 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.

Tasks and Schedules (the core recipe). Save one task per corridor you watch (a delivery lane, a commute, a store-to-store leg), then attach a schedule 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 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 and 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):

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 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 on ACTOR.RUN.SUCCEEDED to push each run's dataset into your own service.


βš™οΈ Input examples

Basic route (best options across modes)

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

Driving, avoid tolls and highways, in miles

{
"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

{
"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

{
"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)

{
"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)

EventPriceWhen it fires
setup$0.01Once per Actor run, at startup.
directions_processed$0.015Once 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 (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:

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

New to Claude Code or Claude Cowork? 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."


πŸš€ 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


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

For contrast, other directions scrapers such as this Google Maps Directions Scraper 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 with your origin, destination, and travel mode, then attach a schedule 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 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 returns messy HTML you still have to parse. This Actor gives you the clean, structured result of a purpose-built 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: Make, Zapier, Slack, the n8n community node, and 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 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 with the actor-specific URL https://mcp.apify.com/?tools=actors,docs,johnvc/google-maps-directions-api. In Claude Code (free trial) or Claude Cowork (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.

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 to find and geocode businesses or landmarks, the Google Local API for Local Pack business results in a metro, and the Google Maps Contributor Reviews API for reviewer history. All of this data originates on Google Maps.


n8n integration

Available as an n8n community node, 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).


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.


Last Updated: 2026.07.14