Get Google Maps Directions (SerpAPI)
google_maps_directionsGet directions between two points via SerpAPI. Provide a start point (one of start_addr, start_coords 'lat,lon', or start_data_id) and an end point (one of end_addr, end_coords, or end_data_id) — the data_ids come from google_maps_search results. Returns the route(s) with distance, duration and step-by-step legs. Shape the route with travel_mode (driving/transit/walking/…), avoid, and time. Result shape: { source, fetchedAt, query, search_metadata, search_parameters, places_info: [{ address, data_id, gps_coordinates }], durations: [{ travel_mode, duration, formatted_duration }], directions: [...] } — the list key is directions. Each direction: { travel_mode, via, distance (meters), duration (seconds), formatted_distance, formatted_duration, typical_duration_range, extensions, trips: [{ travel_mode, title, distance, duration, formatted_distance, formatted_duration, details: [{ title, action, distance, duration }] }] } plus, for transit, start_time, end_time, arrive_around, cost, currency; a Flight entry has only { travel_mode, icon, flight }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gl | No | Country code, e.g. 'us', 'uk', 'de'. | |
| hl | No | Language code, e.g. 'en', 'es', 'fr'. | |
| time | No | Departure/arrival time: 'depart_at:<unix>', 'arrive_by:<unix>', or 'last_available' (transit only). | |
| avoid | No | Comma-separated route features to avoid: 'highways', 'tolls', 'ferries'. | |
| route | No | Transit route option (travel_mode=3 only): 2=Fewer transfers, 3=Less walking, 4=Wheelchair accessible. | |
| prefer | No | Comma-separated transit preferences (travel_mode=3 only): 'bus', 'subway', 'train', 'tram_light_rail'. | |
| end_addr | No | Ending address, e.g. 'Dallas, TX'. Provide one of end_addr/end_coords/end_data_id. | |
| no_cache | No | Force a fresh SerpAPI fetch and bypass this server's result cache. Default false. | |
| end_coords | No | Ending GPS coordinates as 'lat,lon'. | |
| start_addr | No | Starting address, e.g. 'Austin, TX'. Provide one of start_addr/start_coords/start_data_id. | |
| zero_trace | No | Enterprise-only ZeroTrace mode: don't store search params/metadata on SerpAPI. Default false. | |
| end_data_id | No | Place data id of the ending point (from a google_maps_search result). | |
| travel_mode | No | Travel mode: 6=Best (default), 0=Driving, 1=Cycling, 2=Walking, 3=Transit, 4=Flight, 9=Two-wheeler. | |
| start_coords | No | Starting GPS coordinates as 'lat,lon', e.g. '30.1974,-97.6663'. | |
| distance_unit | No | Distance unit: 0=km, 1=miles. | |
| start_data_id | No | Place data id of the starting point (from a google_maps_search result). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| source | Yes | ||
| durations | No | ||
| fetchedAt | Yes | ||
| directions | No | ||
| places_info | No | ||
| search_metadata | No | ||
| search_parameters | No |