Search APIs
Loading…
← API Store
Search & SEO

Google Maps

Google Maps

Google Maps directions

GET /google-maps/v1/directions
Test this endpoint

Routes between two points for a travel mode: distance, duration (typical and in current traffic), warnings (tolls, ferries) and turn-by-turn steps. Points are lat,lng or a place name (resolved with a Maps search). Every response includes credits_used: the credits this call cost.

Each call costs 1 credits; failed calls are free. Run it in the console playground to see a live result.

Parameters

NameTypeDescription
originrequiredstringStart: `lat,lng` or a place name. Example: 40.7580,-73.9855
destinationrequiredstringEnd: `lat,lng` or a place name. Example: JFK Airport
modestringdriving (default), walking, cycling or transit. Example: driving
hlstringLanguage (default en).
glstringCountry (default us).

Every endpoint also takes: raw、fields、fresh、output、records

{
  "cached": false,
  "credits_used": 1,
  "destination": {
    "lat": 40.6446124,
    "lng": -73.7797278,
    "name": "John F. Kennedy International Airport"
  },
  "mode": "driving",
  "origin": {
    "lat": 40.758,
    "lng": -73.9855,
    "name": null
  },
  "routes": [
    {
      "distance": "17.4 miles",
      "distance_m": 27937,
      "duration": "41 min",
      "duration_s": 2453,
      "duration_typical": "1 hr 13 min",
      "legs": [
        {
          "distance": "17.4 mi",
          "distance_m": 27937,
          "duration": "41 min",
          "duration_in_traffic": "1 hr 13 min",
          "duration_s": 2455,
          "steps": [
            {
              "…": "6 fields"
            },
            {
              "…": "6 fields"
            },
            "… 18 more"
          ]
        }
      ],
      "position": 1,
      "summary": "I-495",
      "warnings": [
        "This route has tolls."
      ]
    },
    {
      "distance": "17.0 miles",
      "distance_m": 27343,
      "duration": "1 hr 6 min",
      "duration_s": 3930,
      "duration_typical": "1 hr 27 min",
      "legs": [
        {
          "distance": "17.0 mi",
          "distance_m": 27343,
          "duration": "1 hr 6 min",
          "duration_in_traffic": "1 hr 27 min",
          "duration_s": 3930,
          "steps": [
            {
              "…": "6 fields"
            },
            {
              "…": "6 fields"
            },
            "… 25 more"
          ]
        }
      ],
      "position": 2,
      "summary": "Queens Blvd",
      "warnings": []
    },
    "… 1 more"
  ]
}
Response fields (33)

Field paths and types observed in the sample response; the live response is authoritative.

$object
$.cachedboolean
$.credits_usedinteger
$.destinationobject
$.destination.latnumber
$.destination.lngnumber
$.destination.namestring
$.modestring
$.originobject
$.origin.latnumber
$.origin.lngnumber
$.origin.namenull
$.routesarray
$.routes[]object | string
$.routes[].distancestring
$.routes[].distance_minteger
$.routes[].durationstring
$.routes[].duration_sinteger
$.routes[].duration_typicalstring
$.routes[].legsarray
$.routes[].legs[]object
$.routes[].legs[].distancestring
$.routes[].legs[].distance_minteger
$.routes[].legs[].durationstring
$.routes[].legs[].duration_in_trafficstring
$.routes[].legs[].duration_sinteger
$.routes[].legs[].stepsarray
$.routes[].legs[].steps[]object | string
$.routes[].legs[].steps[].…string
$.routes[].positioninteger
$.routes[].summarystring
$.routes[].warningsarray
$.routes[].warnings[]string