Street routing
Available on the following API tiers:
Plan a turn-by-turn route between two or more locations, across auto, bicycle, pedestrian, and related travel modes. For transit itineraries, use transit routing.
GETPOSThttps://transit.land/api/v2/routing/valhalla/route
Calculate a route between locations with turn-by-turn directions, across auto, pedestrian, bicycle, and related travel modes. For transit routing use the Transitland Routing API.
Request
The request object, url-encoded. Identical to the POST body. Encode spaces as %20 rather than +, or send the JSON without spaces; a + is not decoded as a space here and the request will be rejected as unparseable.
admins (array of administrative regions the route passes through) and admin_crossings (array of objects with from_admin_index, to_admin_index, from_shape_index, and to_shape_index indicating where and along which edge an administrative boundary is crossed).
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
search_filter.exclude_closures is false for origin and/or destination location and the route starts/ends on closed edges). Its value can range from 1.0 - don't penalize closed edges, to 10.0 - apply high cost penalty to closed edges. Default value is 9.0. Note: This factor is applicable only for motorized modes of transport, i.e auto, motorcycle, motor_scooter, bus, truck & taxi.
true, ignores all closures, marked due to live traffic closures, during routing. Note: This option cannot be set if location.search_filter.exclude_closures is also specified in the request and will return an error if it is.
true, ignores one-way restrictions. Especially useful for matching GPS traces to the road network ignoring uni-directional traffic rules. Not included in ignore_restrictions option.
true, ignores any restrictions (e.g. turn/dimensional/conditional restrictions). Especially useful for matching GPS traces to the road network regardless of restrictions.
shortest will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models.
top_speed without penalizing roads where the edge speed is much lower than top_speed, set this value to 0.
date_time to be set. If the array is left empty, or none of these sources are available, Valhalla will fall back to the default speed.
exclude_bridges is set to true it is allowed to start and end with bridges, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_ferries is set to true it is allowed to start and end with ferries, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_highways is set to true it is allowed to start and end with highways, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_tolls is set to true it is allowed to start and end with tolls, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_tunnels is set to true it is allowed to start and end with tunnels, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
search_filter.exclude_closures is false for origin and/or destination location and the route starts/ends on closed edges). Its value can range from 1.0 - don't penalize closed edges, to 10.0 - apply high cost penalty to closed edges. Default value is 9.0. Note: This factor is applicable only for motorized modes of transport, i.e auto, motorcycle, motor_scooter, bus, truck & taxi.
true, ignores all closures, marked due to live traffic closures, during routing. Note: This option cannot be set if location.search_filter.exclude_closures is also specified in the request and will return an error if it is.
true, ignores one-way restrictions. Especially useful for matching GPS traces to the road network ignoring uni-directional traffic rules. Not included in ignore_restrictions option.
true, ignores any restrictions (e.g. turn/dimensional/conditional restrictions). Especially useful for matching GPS traces to the road network regardless of restrictions.
shortest will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models.
top_speed without penalizing roads where the edge speed is much lower than top_speed, set this value to 0.
date_time to be set. If the array is left empty, or none of these sources are available, Valhalla will fall back to the default speed.
exclude_bridges is set to true it is allowed to start and end with bridges, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_ferries is set to true it is allowed to start and end with ferries, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_highways is set to true it is allowed to start and end with highways, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_tolls is set to true it is allowed to start and end with tolls, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
exclude_tunnels is set to true it is allowed to start and end with tunnels, but is not allowed to have them in the middle of the route path, otherwise they are allowed. If set to true, it is highly plausible that no path will be found.
no_shape is not valid for isochrone.Examplepolyline6
lanes array describing lane-level guidance: possible directions and which lanes are valid or active for following the maneuver.
Exampleauto
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06. Required for types 1, 2, 3.YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
YYYY-MM-DDTHH:MM, e.g. 2016-07-03T08:06.lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
lat and lon parameters will be treated as the routing location and the display_lat and display_lon will be used to determine the side of street. Both display_lat and display_lon must be provided and valid to achieve the desired effect.
heading parameter. The default value is service configuration dependent (60 by default).
Exampleopposite
Exampleprimary
break.Examplebreak
[[lon,lat],…] or a GeoJSON FeatureCollection. Roads intersecting these rings will be avoided during path finding. Takes one of the 2 forms listed below.properties.levels array to restrict exclusion to specific building/indoor levels in pedestrian routing.geotiff is isochrone-only.Examplejson
"factor" property or a plain object with a "shape" key, whose value needs to be an encoded polyline (with 6 digit precision), and a "factor" key whose value needs to be float. Valhalla will perform an edge walk (see the map matching documentation for more info) to match the geometry onto edges and use those factors in costing. Edges with factors larger than 1 will be increasingly avoided, while edges with factors smaller than 1 increasingly favored.
Example request
curl --get "https://transit.land/api/v2/routing/valhalla/route" \
-H "apikey: YOUR_API_KEY" \
--data-urlencode 'json={"costing":"auto","directions_type":"instructions","locations":[{"lat":37.7793,"lon":-122.4193},{"lat":37.7844,"lon":-122.4079}]}'Response
Exampleen-US
status.ExampleFound route between points
Example response
Show response
{
"trip": {
"language": "en-US",
"legs": [
{
"maneuvers": [
{
"bearing_after": 352,
"begin_shape_index": 0,
"cost": 22.899,
"end_shape_index": 8,
"instruction": "Drive north on US 101 North/Van Ness Avenue.",
"length": 0.207,
"street_names": [
"US 101 North",
"Van Ness Avenue"
],
"time": 20.747,
"travel_mode": "drive",
"travel_type": "car",
"type": 2,
"verbal_multi_cue": true,
"verbal_post_transition_instruction": "Continue for 200 meters.",
"verbal_pre_transition_instruction": "Drive north on U.S. 1 o1 North, Van Ness Avenue. Then, in 200 meters, Turn right onto Golden Gate Avenue.",
"verbal_succinct_transition_instruction": "Drive north. Then, in 200 meters, Turn right onto Golden Gate Avenue."
},
{
"bearing_after": 81,
"bearing_before": 351,
"begin_shape_index": 8,
"cost": 220.14,
"end_shape_index": 35,
"has_time_restrictions": true,
"instruction": "Turn right onto Golden Gate Avenue.",
"length": 0.826,
"street_names": [
"Golden Gate Avenue"
],
"time": 107.211,
"travel_mode": "drive",
"travel_type": "car",
"type": 10,
"verbal_post_transition_instruction": "Continue for 800 meters.",
"verbal_pre_transition_instruction": "Turn right onto Golden Gate Avenue.",
"verbal_succinct_transition_instruction": "Turn right.",
"verbal_transition_alert_instruction": "Turn right onto Golden Gate Avenue."
},
{
"bearing_after": 351,
"bearing_before": 81,
"begin_shape_index": 35,
"cost": 70.994,
"end_shape_index": 51,
"instruction": "Turn left toward Taylor Street/Turk Street.",
"length": 0.247,
"sign": {},
"street_names": [
"Taylor Street"
],
"time": 30.317,
"travel_mode": "drive",
"travel_type": "car",
"type": 15,
"verbal_post_transition_instruction": "Continue for 200 meters.",
"verbal_pre_transition_instruction": "Turn left toward Taylor Street, Turk Street.",
"verbal_succinct_transition_instruction": "Turn left toward Taylor Street, Turk Street.",
"verbal_transition_alert_instruction": "Turn left toward Taylor Street."
},
{
"bearing_after": 81,
"bearing_before": 351,
"begin_shape_index": 51,
"cost": 70.695,
"end_shape_index": 61,
"instruction": "Turn right onto Eddy Street.",
"length": 0.218,
"street_names": [
"Eddy Street"
],
"time": 31.418,
"travel_mode": "drive",
"travel_type": "car",
"type": 10,
"verbal_post_transition_instruction": "Continue for 200 meters.",
"verbal_pre_transition_instruction": "Turn right onto Eddy Street.",
"verbal_succinct_transition_instruction": "Turn right.",
"verbal_transition_alert_instruction": "Turn right onto Eddy Street."
},
{
"bearing_after": 155,
"bearing_before": 81,
"begin_shape_index": 61,
"cost": 20.629,
"end_shape_index": 69,
"instruction": "Turn right onto Cyril Magnin Street.",
"length": 0.046,
"street_names": [
"Cyril Magnin Street"
],
"time": 7.122,
"travel_mode": "drive",
"travel_type": "car",
"type": 10,
"verbal_multi_cue": true,
"verbal_post_transition_instruction": "Continue for 50 meters.",
"verbal_pre_transition_instruction": "Turn right onto Cyril Magnin Street. Then Your destination will be on the left.",
"verbal_succinct_transition_instruction": "Turn right. Then Your destination will be on the left.",
"verbal_transition_alert_instruction": "Turn right onto Cyril Magnin Street."
},
{
"bearing_before": 135,
"begin_shape_index": 69,
"cost": 0,
"end_shape_index": 69,
"instruction": "Your destination is on the left.",
"length": 0,
"time": 0,
"travel_mode": "drive",
"travel_type": "car",
"type": 6,
"verbal_pre_transition_instruction": "Your destination is on the left.",
"verbal_transition_alert_instruction": "Your destination will be on the left."
}
],
"shape": "{oz`gA|o|nhFwJjAuI\\}V~CiGjAuEx@cWzCeW|CyC\\SwCyIusAYaFYeEsAkS{GceAWuD_@sFkFiy@_Co^UmD_@{EsDuk@yDsl@UsD]_Fo@{IwEst@eBmXWyD]yEYoEi@sIEe@m@eJWaEsBo[iBiGgA_PWy@_@w@u@o@w`@nEq@HaD^uFp@SBoCZuC\\uS|BaCZiW`DmC\\W{Du@yKsBe[oDyj@W_EYcEUmDuAaTm@kJo@yJnAE~@Kr@[p@m@zAoBpAgBxC}DlAcB",
"summary": {
"cost": 405.358,
"has_ferry": false,
"has_highway": false,
"has_time_restrictions": true,
"has_toll": false,
"length": 1.545,
"level_changes": [
[
57,
0
]
],
"max_lat": 37.784462,
"max_lon": -122.408233,
"min_lat": 37.779214,
"min_lon": -122.420355,
"time": 196.817
}
}
],
"locations": [
{
"lat": 37.7793,
"lon": -122.4193,
"original_index": 0,
"side_of_street": "right",
"type": "break"
},
{
"lat": 37.7844,
"lon": -122.4079,
"original_index": 1,
"side_of_street": "left",
"type": "break"
}
],
"status": 0,
"status_message": "Found route between points",
"summary": {
"cost": 405.358,
"has_ferry": false,
"has_highway": false,
"has_time_restrictions": true,
"has_toll": false,
"length": 1.545,
"max_lat": 37.784462,
"max_lon": -122.408233,
"min_lat": 37.779214,
"min_lon": -122.420355,
"time": 196.817
},
"units": "kilometers"
}
}See the Routing Platform overview for API access, travel modes, and the machine-readable schema.
Reference: Valhalla turn-by-turn API reference