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.
MEDIAN LAGon demand
PARAMETERS14
TOTAL USERS92
MONTHLY ACTIVE21
TOTAL RUNS1,253
RUNS SUCCEEDED99.0%
RATING5.0 (4)
Input parameters
| PARAMETER | TYPE | REQ | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| start_addr | string | no | — | Enter the starting address or place name (e.g. 'New York, NY' or 'Empire State Building'). |
| end_addr | string | no | — | Enter the destination address or place name (e.g. 'Boston, MA' or 'Fenway Park'). |
| start_coords | string | no | — | Optionally set the origin as exact GPS coordinates in 'latitude,longitude' format (e.g. '40.7128,-74.0060'). |
| end_coords | string | no | — | Optionally set the destination as exact GPS coordinates in 'latitude,longitude' format (e.g. '42.3601,-71.0589'). |
| start_data_id | string | no | — | Optionally set the origin as a Google Maps place data ID (e.g. '0x89c24fa5d33f083b:0xc80b8f06e177fe62'). |
| end_data_id | string | no | — | Optionally set the destination as a Google Maps place data ID. |
| travel_mode | enum | no | best | Choose how to travel. 'Best' returns the best options across modes; the others restrict the result to one mode. |
| distance_unit | enum | no | auto | Choose the distance unit for the results. 'Automatic' lets the region decide. |
| avoid_tolls | boolean | no | False | Enable to prefer routes without toll roads. |
| avoid_highways | boolean | no | False | Enable to prefer routes that avoid highways. |
| avoid_ferries | boolean | no | False | Enable to prefer routes that avoid ferries. |
| transit_prefer | enum | no | none | Set a preferred public transit mode. |
| transit_routing | enum | no | none | Set how transit routes are optimized. |
| time_type | enum | no | leave_now | Choose whether the time below is a departure time, an arrival time, or to leave now. 'Leave now' ignores the time value. |
Worked examples
{
"start_addr": "New York, NY",
"end_addr": "Boston, MA"
}
Coverage
7
travel mode — best driving cycling walking transit +2
Tasks
Saved runs with the inputs already filled in — each one a standalone page and a working configuration example.
Code
curl
curl -X POST "https://api.apify.com/v2/acts/johnvc~google-maps-directions-api/run-sync-get-dataset-items" \
-H "Authorization: Bearer $APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"start_addr": "New York, NY", "end_addr": "Boston, MA"}'
Python
from apify_client import ApifyClient
client = ApifyClient("APIFY_TOKEN")
run = client.actor("johnvc/google-maps-directions-api").call(
run_input={'start_addr': 'New York, NY', 'end_addr': 'Boston, MA'}
)
for item in client.dataset(run.default_dataset_id).iterate_items():
print(item)