Google Maps Directions API
The Google Maps Directions API returns route data for driving, transit, walking, cycling, and flying. Extract step-by-step directions with coordinates, travel times, distances, and service provider details. Flight results include ticket prices and direct booking links to Google Flights. Transit routes include schedules, station information, provider contacts, and ticket purchase links. Driving directions include toll warnings and traffic-optimized routing.
API Parameters
Search Query
-
- Name
-
from - Required
- Required
- Description
-
Parameter defines the origin of the route. Can be a plain address, data ID, or coordinates (lat,long).
-
- Name
-
to - Required
- Required
- Description
-
Parameter defines the destination of the route. Can be a plain address, data ID, or coordinates (lat,long).
-
- Name
-
waypoints - Required
- Optional
- Description
-
Parameter defines the waypoints of the route. Should be an array where each element is a string that can be a plain address, data ID, or coordinates (lat,long).
Example:["0x40d8a9890932b5d5:0x8b7c49e19a7fc6a4", "Times Square, New York"]
Maximum 8 elements.
Note: This parameter is not supported whentravel_modeis set totransit.
Note: This parameter cannot be used together with thetimeparameter.
-
- Name
-
travel_mode - Required
- Optional
- Description
-
Parameter defines the mode of travel. Allowed options are:
-
bestDefault drivingcyclingwalking-
transitNot supported whenwaypointsis present flying
-
-
- Name
-
time - Required
- Optional
- Description
-
Parameter defines the departure or arrival time for the route. Supports three formats:
depart_at:<timestamp>- Departure time as Unix timestamparrive_by:<timestamp>- Arrival time as Unix timestamp-
last_availableOnly supported whentravel_modeistransit
Note: This parameter cannot be used together with thewaypointsparameter.
-
- Name
-
route - Required
- Optional
- Description
-
Parameter defines the route preference for transit directions. Allowed options are:
-
bestDefault fewer_transfersless_walkingwheelchair_accessible
Note: This parameter is only supported whentravel_modeis set totransit. -
-
- Name
-
prefer - Required
- Optional
- Description
-
Parameter defines the preferred transit types for transit directions. Should be an array where each element is a string representing a transit type preference. Allowed options are:
bussubwaytraintram_and_light_rail
Example:["bus", "subway"]
Note: This parameter is only supported whentravel_modeis set totransit.
-
- Name
-
avoid - Required
- Optional
- Description
-
Parameter defines what to avoid when calculating routes. Should be an array where each element is a string representing something to avoid. Available options:
-
tolls- Avoid toll roads (Only available for driving and best modes) -
highways- Avoid highways (Only available for driving and best modes) -
ferries- Avoid ferries (Only available for walking and cycling modes)
Example:["tolls", "highways"](for driving mode) -
-
- Name
-
distance_units - Required
- Optional
- Description
-
Parameter defines the unit of distance measurements in the response. Allowed options are:
-
automaticDefault km- Kilometersmi- Miles
Note: This parameter is not supported whentravel_modeis set toflyingortransit. -
Localization
-
- Name
-
gl - Required
- Optional
- Description
-
The default parameter
usdefines the country to use for the search. Check the full list of supported Googleglcountries.
-
- Name
-
hl - Required
- Optional
- Description
-
The default parameter
endefines the interface language of the search. Check the full list of supported Googlehllanguages.
Engine
-
- Name
-
engine - Required
- Required
- Description
-
Parameter defines an engine that will be used to retrieve real-time data. It must be set to
google_maps_directions.
API key
-
- Name
-
api_key - Required
- Required
- Description
-
The
api_keyauthenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY) or in the Authorization header (Bearer YOUR_API_KEY).
Zero Data Retention
-
- Name
-
zero_retention - Enterprise Only
- Enterprise Only
- Required
- Optional
- Description
-
Set this parameter to
trueto disable all logging and persistent storage. No request parameters, HTML, or JSON responses are stored or logged. Suitable for high-compliance use cases. Debugging and support may be limited while enabled.
API Examples
Full Response
https://www.searchapi.io/api/v1/search?engine=google_maps_directions&from=New+York&to=Chicago - Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests url = "https://www.searchapi.io/api/v1/search" params = { "engine": "google_maps_directions", "from": "New York", "to": "Chicago" } response = requests.get(url, params=params) print(response.text) { "search_metadata": { "id": "search_DdeYJm72pz81tz5Qo9ZEPlbV", "status": "Success", "created_at": "2025-09-12T14:23:48Z", "request_time_taken": 1.88, "parsing_time_taken": 0.09, "total_time_taken": 1.97, "request_url": "https://www.google.com/maps/dir/New+York/Chicago%2C+Illinois", "html_url": "https://www.searchapi.io/api/v1/searches/search_DdeYJm72pz81tz5Qo9ZEPlbV.html", "json_url": "https://www.searchapi.io/api/v1/searches/search_DdeYJm72pz81tz5Qo9ZEPlbV" }, "search_parameters": { "engine": "google_maps_directions", "from": "New York", "to": "Chicago", "travel_mode": "best", "route": "best", "distance_units": "automatic", "gl": "us", "hl": "en" }, "travel_modes": [ { "travel_mode": "Driving", "formatted_duration": "12 hr", "duration": 44087 }, { "travel_mode": "Transit", "formatted_duration": "20 hr", "duration": 70800 }, ... ], "places_info": [ { "address": "New York", "data_id": "0x89c24fa5d33f083b:0xc80b8f06e177fe62", "coordinates": { "latitude": 40.7127753, "longitude": -74.0059728 } }, { "address": "Chicago, Illinois", "data_id": "0x880e2c3cd0f4cbed:0xafe0a6ad09c0c000", "coordinates": { "latitude": 41.88325, "longitude": -87.6323879 } } ], "directions": [ { "travel_mode": "Driving", "via": "I-80 W", "formatted_duration": "12 hr 10 min", "duration": 43813, "distance": 1271793, "formatted_typical_duration": "11 hr 22 min to 14 hr 17 min", "optimistic_duration": 40939, "pessimistic_duration": 51408, "formatted_distance": "790 miles", "warnings": [ "This route has tolls.", "Your destination is in a different time zone." ], "instructions": [ { "travel_mode": "Driving", "action": "Take Hudson St and I-78 W to NJ-139 W in Jersey City", "formatted_duration": "15 min", "formatted_distance": "3.6 mi", "duration": 882, "distance": 5774, "details": [ { "travel_mode": "Driving", "action": "Head southeast toward Park Row", "information": "Partial restricted usage road", "formatted_duration": "21 sec", "formatted_distance": "200 ft", "duration": 21, "distance": 61, "latitude": 40.71257449099273, "longitude": -74.00641981461534 }, ... ] }, ... ] }, { "travel_mode": "Transit", "time_window": { "depart_at": "2:05 PM", "depart_at_tz": "America/New_York", "arrive_at": "8:45 AM", "arrive_at_tz": "America/Chicago" }, "formatted_duration": "19 hr 40 min", "formatted_distance": "851 miles", "duration": 70800, "distance": 1369556, "instructions": [ { "travel_mode": "Transit", "depart_from": { "place": "New York (Port Authority Bus Terminal)", "at": "2:05 PM", "timezone": "America/New_York", "latitude": 40.757, "longitude": -73.99186, "data_id": "0x89c25852d804d943:0xe56f50849cfe6488" }, "vehicle": "Bus", "line_name": "FAB 202", "line_number": "Pittsburgh", "formatted_duration": "7 hr 45 min", "duration": 27900, "arrive_at": { "place": "Pittsburgh", "at": "9:50 PM", "timezone": "America/New_York", "latitude": 40.444496, "longitude": -79.99342, "data_id": "0x8834f3e26d2e0879:0xb8c52273c7bd107c" }, "service_provider": { "name": "Fullington Trailways", "contact": "1 (800) 942-8287", "website": "https://ride.fullingtontours.com/" }, "stops": [ { "place": "State College (Bus Terminal)", "at": "7:05 PM", "timezone": "America/New_York", "latitude": 40.7921, "longitude": -77.866, "data_id": "0x89cea89a2e07410d:0xef633c510c13d93e" } ] }, { "walking": { "travel_mode": "Walking", "formatted_duration": "3 min", "duration": 169 } }, { "travel_mode": "Transit", "depart_from": { "place": "Pittsburgh Union Station", "at": "11:59 PM", "timezone": "America/New_York", "latitude": 40.444738, "longitude": -79.992307, "data_id": "0x8834f1589fe2b1bf:0x6dffce30c7354135" }, "direction": "Chicago", "vehicle": "Train", "line_name": "Floridian", "line_number": "40", "formatted_duration": "9 hr 46 min", "duration": 35160, "arrive_at": { "place": "Chicago Union Station", "at": "8:45 AM", "timezone": "America/Chicago", "latitude": 41.8803197, "longitude": -87.6394109, "data_id": "0x880e2c8dbbb32f5d:0x5f985dc0044b1109" }, "service_provider": { "name": "Amtrak", "website": "https://www.amtrak.com/" }, "stops": [ { "place": "Alliance Amtrak", "at": "1:39 AM", "timezone": "America/New_York", "latitude": 40.921275, "longitude": -81.09290399999999, "data_id": "0x8836b4b8cb64b793:0xb13235a1669f926" }, ... ] } ] }, { "travel_mode": "Flying", "departure": "Newark, NJ", "arrival": "Chicago, IL", "formatted_duration": "2 hr 20 min", "duration": 8400, "formatted_price": "$145", "price": 145, "airlines": [ "Spirit", "Frontier", "American" ], "flights_link": "https://www.google.com/travel/flights?tfs=CAcQAhopEgoyMDI1LTA5LTI4ag0IAhIJL20vMDJfMjg2cgwIAhIIL20vMDFfZDQaKRIKMjAyNS0xMC0wMmoMCAISCC9tLzAxX2Q0cg0IAhIJL20vMDJfMjg2&source=maps&hl=en&authuser=0" } ] } Driving
https://www.searchapi.io/api/v1/search?engine=google_maps_directions&from=Chicago&to=Santa+Monica&travel_mode=driving - Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests url = "https://www.searchapi.io/api/v1/search" params = { "engine": "google_maps_directions", "from": "Chicago", "to": "Santa Monica", "travel_mode": "driving" } response = requests.get(url, params=params) print(response.text) { "directions": [ { "travel_mode": "Driving", "via": "I-80 W", "formatted_duration": "29 hr", "duration": 105862, "distance": 3269280, "formatted_typical_duration": "29–35 hr", "optimistic_duration": 103460, "pessimistic_duration": 126069, "formatted_distance": "2,031 miles", "warnings": [ "This route has tolls.", "Your destination is in a different time zone.", "Fastest route, the usual traffic" ], "instructions": [ { "travel_mode": "Driving", "action": "Take N Clark St to IL-110 W/Chicago - Kansas City Expy/Dwight D. Eisenhower Expy/Eisenhower Expy", "formatted_duration": "5 min", "formatted_distance": "0.8 mi", "duration": 292, "distance": 1250, "details": [ { "travel_mode": "Driving", "action": "Head east on W Washington St toward N Clark St", "formatted_duration": "26 sec", "formatted_distance": "394 ft", "duration": 26, "distance": 120, "street_view": "https://streetviewpixels-pa.googleapis.com/v1/thumbnail?panoid=avTFVBIVsF3UUWArxWP20A&cb_client=maps_sv.tactile.gps&w=203&h=100&yaw=272.88528&pitch=0&thumbfov=100", "latitude": 41.8832316, "longitude": -87.63260404027585 }, ... ] }, ... ] } ] } Transit
https://www.searchapi.io/api/v1/search?engine=google_maps_directions&from=New+York&to=Boston&travel_mode=transit - Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests url = "https://www.searchapi.io/api/v1/search" params = { "engine": "google_maps_directions", "from": "New York", "to": "Boston", "travel_mode": "transit" } response = requests.get(url, params=params) print(response.text) { "directions": [ { "travel_mode": "Transit", "time_window": { "depart_at": "9:30 AM", "depart_at_tz": "America/New_York", "arrive_at": "1:50 PM", "arrive_at_tz": "America/New_York" }, "buy_ticket": { "title": "One-way price for 1 adult · Tue, Oct 21", "price": "$49.99", "offers": [ { "source": "Wanderu", "price": "$49.99", "link": "https://google-partner.wanderu.com/link?service_date%3D%255B%252220251021%2522%255D%26from_ticketing_stop_time_id%3D%255B%2522NYCUSPPL%2522%255D%26to_ticketing_stop_time_id%3D%255B%2522BOSSSB%2522%255D%26boarding_time%3D%255B%25222025-10-21T13:30:00%252B00:00%2522%255D%26arrival_time%3D%255B%25222025-10-21T17:50:00%252B00:00%2522%255D", "favicon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyODMgMjgyIiB3aWR0aD0iMjgzIiBoZWlnaHQ9IjI4MiIgZmlsbD0ibm9uZSI+PHBhdGggZD0iTTI1OS4xNTQgMzIuODA0Yy00My45NDItMzkuODY5LTc3LjA0OC05Ljk4Ny0xMTYuNTg2LTguNy0zOS4yMDMgMS4yNzYtODAuNTExLTI4LjY2LTExOS4zMjYgMTAuMjQxQzEwLjk0OSA0OC41OTQtMy41NjIgOTIuMDcu..." } ] }, "formatted_duration": "4 hr 20 min", "formatted_distance": "230 miles", "duration": 15600, "distance": 369967, "instructions": [ { "travel_mode": "Transit", "depart_from": { "place": "Port Authority Bus Terminal", "at": "9:30 AM", "timezone": "America/New_York", "latitude": 40.7569006, "longitude": -73.9902798, "data_id": "0x89c258533c0d4f09:0xa8790f841589c36e" }, "direction": "Boston (South Station), MA", "vehicle": "Bus", "line_name": "Peter Pan", "line_number": "5619", "formatted_duration": "4 hr 20 min", "duration": 15600, "arrive_at": { "place": "South Station", "at": "1:50 PM", "timezone": "America/New_York", "latitude": 42.3518283, "longitude": -71.0562097, "data_id": "0x89e37a78aa90726b:0xa5147c622a35c46a" }, "service_provider": { "name": "Peter Pan Bus Lines", "contact": "1 (800) 343-9999", "website": "https://peterpanbus.com/" }, "stops": [ { "place": "Union Station, Hartford, CT", "at": "11:50 AM", "timezone": "America/New_York", "latitude": 41.768891, "longitude": -72.681611, "data_id": "0x89e653614a7366b1:0x520d228b099e1116" } ] } ] }, ... ] } Walking
https://www.searchapi.io/api/v1/search?engine=google_maps_directions&from=Duke+Ellington+Circle%2C+NYC&to=Columbus+Cir%2C+NYC&travel_mode=walking - Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests url = "https://www.searchapi.io/api/v1/search" params = { "engine": "google_maps_directions", "from": "Duke Ellington Circle, NYC", "to": "Columbus Cir, NYC", "travel_mode": "walking" } response = requests.get(url, params=params) print(response.text) { "directions": [ { "travel_mode": "Walking", "via": "5th Ave", "formatted_duration": "1 hr 5 min", "duration": 3893, "distance": 4686, "formatted_distance": "2.9 miles", "instructions": [ { "travel_mode": "Walking", "formatted_duration": "1 hr 5 min", "formatted_distance": "2.9 mi", "duration": 3893, "distance": 4686, "details": [ { "travel_mode": "Walking", "action": "Head southwest on 5th Ave toward Duke Ellington Circle", "information": "Parts of this road may be closed at certain times or days", "formatted_duration": "36 min", "formatted_distance": "1.6 mi", "duration": 2163, "distance": 2558, "street_view": "https://streetviewpixels-pa.googleapis.com/v1/thumbnail?panoid=8oJOBNcAAJl58zrwTdmV8A&cb_client=maps_sv.tactile.gps&w=203&h=100&yaw=262.59985&pitch=0&thumbfov=100", "latitude": 40.79729683620528, "longitude": -73.9490482000821 }, { "travel_mode": "Walking", "action": "Slight right", "formatted_duration": "52 sec", "formatted_distance": "171 ft", "duration": 52, "distance": 52, "street_view": "https://streetviewpixels-pa.googleapis.com/v1/thumbnail?panoid=uZdzkK2_HxHVDelhFt-w8A&cb_client=maps_sv.tactile.gps&w=203&h=100&yaw=231.58138&pitch=0&thumbfov=100", "latitude": 40.77705167096609, "longitude": -73.96380734846424 }, ... ] } ] } ] } Cycling
https://www.searchapi.io/api/v1/search?engine=google_maps_directions&from=The+Hague&to=Amsterdam&travel_mode=cycling - Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests url = "https://www.searchapi.io/api/v1/search" params = { "engine": "google_maps_directions", "from": "The Hague", "to": "Amsterdam", "travel_mode": "cycling" } response = requests.get(url, params=params) print(response.text) { "directions": [ { "travel_mode": "Cycling", "via": "Hoofdweg Oostzijde", "formatted_duration": "3 hr 26 min", "duration": 12365, "distance": 62110, "formatted_distance": "62.1 km", "instructions": [ { "travel_mode": "Cycling", "formatted_duration": "3 hr 26 min", "formatted_distance": "62.1 km", "duration": 12365, "distance": 62110, "details": [ { "travel_mode": "Cycling", "action": "Head northeast toward Vaillantlaan/S100", "formatted_duration": "10 sec", "formatted_distance": "43 m", "duration": 10, "distance": 43, "street_view": "https://streetviewpixels-pa.googleapis.com/v1/thumbnail?panoid=mS-95UezFIP6d7-StaS2zg&cb_client=maps_sv.tactile.gps&w=203&h=100&yaw=51.68569&pitch=0&thumbfov=100", "latitude": 52.07018746926732, "longitude": 4.300649582678608 }, { "travel_mode": "Cycling", "action": "Exit the roundabout onto Buitenom/S100", "formatted_duration": "1 min", "formatted_distance": "220 m", "duration": 72, "distance": 219, "street_view": "https://streetviewpixels-pa.googleapis.com/v1/thumbnail?panoid=UXJxgIpujkTElkoShXLzkw&cb_client=maps_sv.tactile.gps&w=203&h=100&yaw=9.541462&pitch=0&thumbfov=100", "latitude": 52.07046915544492, "longitude": 4.30103743330316 }, ... ] } ] } ] } Flying
https://www.searchapi.io/api/v1/search?engine=google_maps_directions&from=JFK%2C+NYC&to=San+Francisco&travel_mode=flying - Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests url = "https://www.searchapi.io/api/v1/search" params = { "engine": "google_maps_directions", "from": "JFK, NYC", "to": "San Francisco", "travel_mode": "flying" } response = requests.get(url, params=params) print(response.text) { "directions": [ { "travel_mode": "Flying", "departure": "New York, NY", "arrival": "San Francisco, CA", "formatted_duration": "5 hr 55 min", "duration": 21300, "formatted_price": "$170", "price": 170, "airlines": [ "Frontier", "United", "JetBlue" ], "flights_link": "https://www.google.com/travel/flights?tfs=CAcQAhopEgoyMDI1LTExLTA2ag0IAhIJL20vMDJfMjg2cgwIAhIIL20vMGQ2bHAaKRIKMjAyNS0xMS0xMGoMCAISCC9tLzBkNmxwcg0IAhIJL20vMDJfMjg2&source=maps&hl=en&authuser=0" } ] }