Scrape Google Driving Directions for Your App Automatically
You want one number: how long is the drive from A to B. The official path to that number runs through a Google Cloud project, a billing account, an API key you have to restrict, and a quota table that bills you per "element." For a side project or an internal dashboard, that is a lot of ceremony for a drive time.
Here is the shortcut I use instead.
[[

IMG1]]
The Google Maps Directions API on Apify takes an origin and a destination and returns every route option in one call. The minimum input really is two fields:
{
"start_addr": "New York, NY",
"end_addr": "Boston, MA"
}The default best mode returns driving, transit, flight, and more in a single charge, each with distance, ETA, and turn-by-turn steps.
The fields that matter in practice:
best_duration and best_distance, formatted like 3 hr 38 min and 215 miles.
typical_duration_range, the traffic-aware spread (3 hr 21 min to 4 hr 10 min). This is the field that makes route monitoring worth doing.
durations, comparing travel time across every mode for the same pair.
google_maps_directions_url, a link that opens the same route in a browser. The most useful field for anything customer facing.
Avoid tolls and highways, work in miles, and pin the mode:
{
"start_addr": "Los Angeles, CA",
"end_addr": "San Francisco, CA",
"travel_mode": "driving",
"distance_unit": "miles",
"avoid_tolls": true,
"avoid_highways": true
}You can also pass GPS coordinates or Google Maps place IDs instead of addresses, and set a departure or arrival time with time_type and time_value. Coordinates take precedence over place ID, which takes precedence over address.
Run it like any other Apify Actor:
POST /v2/acts/johnvc~google-maps-directions-api/runs
{
"start_addr": "Brooklyn, NY",
"end_addr": "Times Square, New York, NY",
"travel_mode": "transit"
}Or add it to Claude or Cursor as an MCP tool and skip the glue code entirely:
https://mcp.apify.com/?tools=actors,docs,johnvc/google-maps-directions-api[[

IMG2]]
A route ETA is not a constant. Save a task per corridor you watch (a delivery lane, a commute, a store-to-store leg), attach a schedule, and distance and traffic-aware duration refresh on a cron you pick:
0 7 * * * # daily at 7 AM
0 */6 * * * # every six hours
0 8 * * 1-5 # weekday morningsOne schedule can trigger many tasks at once, so a whole set of routes refreshes in a single pass.
$0.01 setup per run plus $0.015 per route lookup, so one lookup is $0.025 flat. That single charge covers every route option the best mode returns, which is the part that compares well against per-element billing.
Yes. Supply the input fields and the Actor handles retrieval. There is no Google Cloud project, no key to restrict, and no per-element quota to reason about.
Both, and that is the point. An official maps API is rate limited and billed per element. A plain scraper hands back messy HTML you still have to parse. This returns the clean structured result of a purpose-built API with the no-key convenience of a scraper.
Yes. Set travel_mode to transit, time_type to arrive_by, and put an ISO 8601 datetime in time_value. Transit options come back with stops, lines, operators, and times.
Yes, and that is where it earns its keep. Save a task, attach a schedule, and store each run so a route history accumulates. See travel time between two addresses for a ready-to-run starting point.
It routes between points; it does not find the points. Pair it with a places scraper to discover and geocode the businesses first. Flight and two-wheeler modes are region dependent, so they will not resolve for every pair; those rows come back with directions_found: false and a note.
If you have ever abandoned a project at the "enable billing on your Google Cloud project" step, start here: Google Maps Directions API. Or wire it into an agent with directions via MCP in AI agents.
0
0
0