DEV Community

Cover image for Google Maps Directions API Without a Google Cloud Key: Routes and ETAs as JSON (2026)
Truffle Pig Data
Truffle Pig Data

Posted on

Google Maps Directions API Without a Google Cloud Key: Routes and ETAs as JSON (2026)

Getting a route out of Google Maps programmatically means a Google Cloud project, an API key, billing enabled, and a pricing sheet you will read three times and still not trust. All you wanted was distance, ETA, and the steps between two addresses. For that job I use the Google Maps Directions API on Apify: one call, any travel mode, structured JSON, no Google Cloud key anywhere in the flow.

Disclosure: the Apify links in this post are affiliate links. If you run the Actor, I may earn a referral commission at no extra cost to you.

Doesn't Google already sell a Directions API?

It does, and if you are building turn-by-turn navigation into a consumer app, use it. The friction is everything around it: a Cloud project, key restrictions, billing setup, and per-element pricing that punishes exploratory or batch work. When you just need route data, an Actor you call with two addresses is the shorter path: same underlying answers, one JSON response, billed as a plain Apify run.

What the Google Maps Directions API returns

The Google Maps Directions API returns route options between an origin and a destination as structured JSON: distance, duration, traffic-aware ranges, and turn-by-turn steps for driving, transit, walking, cycling, and flights.

Field Example Notes
best_duration 42 min Fastest option found
best_distance 31.2 km Set distance_unit for miles
travel_mode transit Seven modes, including cycling and flight
directions [...] Each option's distance, duration, via, and turn-by-turn trips
places_info { "formatted_address": ... } Resolved address, place ID, and GPS for both ends
google_maps_directions_url https://www.google.com/maps/dir/... Open the same route in a browser

Transit options carry stops, lines, operators, and times, and a durations block compares travel time across modes in one response.

Who this is for

Logistics and delivery teams estimating drive times between stops, AI agent builders who want their assistant to answer "how long to the airport at 5 pm", and analysts doing transit analysis across neighborhoods without a GIS budget.

The manual way, and where it breaks

You can automate the Google Maps website yourself: build the directions URL, render it in a headless browser, and parse the panel. It works until it does not. The page is JavaScript all the way down, selectors rot quickly, and coordinates-based queries get awkward fast. The official route means quota management and a key you must guard, which is a strange tax on a script that checks one commute. Either way you end up maintaining plumbing instead of using route data.

The faster way: run the Google Maps Directions API

Apify Console

  1. Open the Google Maps Directions API and click Try for free.
  2. Enter an origin and a destination as an address, lat,lng coordinates, or a place ID, and pick a travel_mode.
  3. Run it and grab the JSON from the dataset.

REST

curl -X POST "https://api.apify.com/v2/acts/johnvc~google-maps-directions-api/runs?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "origin": "Boston Logan Airport", "destination": "Kendall Square, Cambridge, MA", "travel_mode": "transit" }'
Enter fullscreen mode Exit fullscreen mode

Endpoint reference: the Apify API docs.

Get directions in Python

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("johnvc/google-maps-directions-api").call(
    run_input={
        "origin": "Boston Logan Airport",
        "destination": "Kendall Square, Cambridge, MA",
        "travel_mode": "driving",
    }
)

for route in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(route["travel_mode"], route["best_duration"], route["best_distance"])
Enter fullscreen mode Exit fullscreen mode

Options like avoid_tolls, avoid_highways, and a departure or arrival time refine the result the same way the Maps UI does.

Pull directions as plain JSON

The baseline recipe. The task Get Google Maps directions by API as JSON shows the minimal input and the full output shape.

Skip the API key entirely

If you landed here searching for a keyless option, Get Google Maps directions without an API key is the worked example: no Cloud project, just an Apify token.

Compare travel time between two addresses

Travel time between two addresses returns best_duration per mode, handy for commute scoring or delivery-zone checks.

Give your AI agent real routes via MCP

Over Apify's MCP server the Actor becomes a tool that Claude, Claude Code, and Cursor can call mid-conversation, so "can I make the 6:10 train from the office" gets answered with live route data. Two tasks show the setup: directions via MCP in AI agents and directions in Claude Cowork. More about Claude at claude.ai.

FAQ about scraping Google Maps directions

Is this directions scraper free to use?

Each lookup runs as a normal Apify Actor run billed to your account, and new accounts come with free platform credit that covers plenty of route checks. There is no Google Cloud billing account anywhere in the loop, which for me was the whole point.

Does the scraper handle transit, cycling, and flights?

Yes. travel_mode accepts best, driving, cycling, walking, transit, flight, and two-wheeler, and transit results include the stops, lines, and operators for each option.

Can Claude or Cursor use this directions scraper over MCP?

Yes. Connected through Apify's MCP server, the Actor is a callable tool, and the MCP example task above is the fastest way to wire it up.

Can I schedule the scraper to watch a commute?

Yes. Save your origin and destination as a task, attach a cron schedule for the times you care about, and each run appends a fresh ETA reading. Start from the Google Maps Directions API page.

What will this scraper not do?

It is not a navigation SDK. You get route data at request time, including traffic-aware duration ranges, but it will not stream live position updates or reroute a driver mid-trip. For embedded turn-by-turn guidance, Google's official offering is the right tool.

More from Truffle Pig Data

The same Actor from other angles: Google Maps Directions API for AI Agents on Medium, the LinkedIn article, and the Peerlist write-up.

Wrapping up

Route data should not require a cloud console. Send two addresses to the Google Maps Directions API and get distance, ETA, and steps back as JSON.

Top comments (0)