Skip to main content

GET /v1/route

Overview​

Compute the best route between two points on the road network, with distance, duration, geometry, and optional turn-by-turn instructions in English or French.

Cost: 2 credits per request. Availability: all plans. The car profile is included everywhere; bike and foot require the Startup plan or above, truck and moto require Growth or above.

Request​

GET https://api.geocodeme.net/v1/route

Required header: X-Api-Key: gm_YOUR_API_KEY

Parameters​

ParameterTypeRequiredDefaultDescription
fromstringYesn/aOrigin as lon,lat (e.g. 2.3522,48.8566)
tostringYesn/aDestination as lon,lat (e.g. 4.8357,45.7640)
profilestringNocarVehicle profile: car, bike, foot, truck, or moto (plan-gated, see above)
geometriesstringNogeojsonGeometry format: geojson, polyline, or polyline6
stepsbooleanNofalseInclude turn-by-turn instructions
languagestringNoenInstruction language (en or fr), only relevant with steps=true
use_tollsbooleanNon/aPrefer (true) or avoid (false) toll roads. Motorized profiles only
truck_heightfloatNon/aVehicle height in meters (0 to 10). Requires profile=truck
truck_widthfloatNon/aVehicle width in meters (0 to 5). Requires profile=truck
truck_weightfloatNon/aVehicle weight in metric tons (0 to 100). Requires profile=truck
Costing option rules
  • truck_height / truck_width / truck_weight are only valid with profile=truck; with any other profile the API returns a 400 INVALID_PARAMETER.
  • use_tolls only applies to motorized profiles; combining it with bike or foot returns a 400 INVALID_PARAMETER.

Requests rejected by these validations are not charged any credits.

Code Examples​

curl -H "X-Api-Key: gm_YOUR_API_KEY" \
"https://api.geocodeme.net/v1/route?from=2.3522,48.8566&to=2.2945,48.8584&profile=car&steps=true"

Response​

info

All responses include rate limiting headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Monthly-Remaining, etc.).

With geometries=geojson (default) and steps=true (geometry shortened for readability):

{
"coordinates": [
[2.3522, 48.8566],
[2.3488, 48.8589],
[2.3305, 48.8630],
[2.3079, 48.8621],
[2.2945, 48.8584]
],
"distance_meters": 6284.0,
"duration_seconds": 941.0,
"steps": [
{
"instruction": "Drive west on Rue de Rivoli.",
"distance_meters": 1520.0,
"duration_seconds": 210.0,
"type": 1,
"street_names": ["Rue de Rivoli"]
},
{
"instruction": "Turn right onto Quai des Tuileries.",
"distance_meters": 980.0,
"duration_seconds": 145.0,
"type": 10,
"street_names": ["Quai des Tuileries"]
},
{
"instruction": "You have arrived at your destination.",
"distance_meters": 0.0,
"duration_seconds": 0.0,
"type": 4,
"street_names": []
}
],
"attribution": "Route data (c) OpenStreetMap contributors",
"meta": {
"took_ms": 38,
"cache_hit": false
}
}

With geometries=polyline (or polyline6), the geometry is returned as geometry_polyline (an encoded string) and coordinates is omitted.

note

This endpoint omits fields that do not apply to your request instead of returning them as null: coordinates and geometry_polyline are mutually exclusive, and steps is only present when steps=true.

Schema​

FieldTypeDescription
coordinatesarrayRoute geometry as [[longitude, latitude], ...], present when geometries=geojson
geometry_polylinestringEncoded polyline string, present when geometries=polyline or polyline6
distance_metersfloatTotal route distance in meters
duration_secondsfloatEstimated travel time in seconds
stepsarrayTurn-by-turn maneuvers, present only when steps=true
steps[].instructionstringHuman-readable instruction, in the requested language
steps[].distance_metersfloatLength of this maneuver in meters
steps[].duration_secondsfloatDuration of this maneuver in seconds
steps[].typeintegerManeuver type code (routing engine convention: start, turn, arrival, ...)
steps[].street_namesarrayStreet names involved in the maneuver
attributionstringAlways "Route data (c) OpenStreetMap contributors"
meta.took_msintegerServer processing time in milliseconds
meta.cache_hitbooleanWhether the response was served from cache

Error Responses​

Profile not included in your plan​

{
"error": {
"code": "PLAN_UPGRADE_REQUIRED",
"message": "The 'truck' profile is not included in your plan. Upgrade to unlock it.",
"field": "profile",
"upgrade_url": "https://geocodeme.net/dashboard/billing"
}
}

Malformed coordinate​

{
"error": {
"code": "INVALID_PARAMETER",
"message": "'from' must be 'lon,lat' (e.g. 2.3522,48.8566)",
"field": "from"
}
}

Truck dimensions without the truck profile​

{
"error": {
"code": "INVALID_PARAMETER",
"message": "truck_height/truck_width/truck_weight require profile=truck",
"field": "profile"
}
}
tip

All endpoints are also subject to INVALID_API_KEY (401) and RATE_LIMIT_EXCEEDED / QUOTA_EXCEEDED (429) errors. See Error Codes for the full reference.