See SWAGGER on: https://www.km4city.org/swagger/external/index.html?urls.primaryName=What-if%20Router%20API
See user interface tool: How to: Routing with What-if, find a route among points and to-be-avoided areas
The API refer to an advanced version of GraphHopper,GH, tool.
please note that cluster of GH tools can be provided in certain Snap4City installations to perform massive optimisations and/or services.
This is the template for the api:
https://snap4city.org/whatif-router/route?vehicle=<vehicle>&waypoints=<lng1,lat1;lng2,lat2;...>&weighting=<weighting>&startDatetime=<datetime>&avoid_area=<avoid_area>&wkt=<true/false>&routing=<pt/public_transport>
Let’s breakdown the parameters:
- vehicle: the vehicle used to move. Available values : car, roads, bike, racingbike, mtb, foot, hike, motorcycle, wheelchair, bus, taxi. Default value : car
- waypoints: list of waypoints required for the route. The waypoints must be separated by semicolon.
- weighting: the route rules. Available values : fastest, shortest, short_fastest, fastest_with_traffic. Default value : fastest
- startDatetime: datetime used as start date and time searching. Default is current time.
- avoid_area: geoJSON representing polygons of areas to be avoided.
- wkt: flag that indicates if the wkt polyline of the route is returned.
- routing: label that is needed to do multimodal routing. Alternatively, this type of routing can be done with vehicle=bus
Returned value:
- 500: router can’t find a route
- 400: waypoints are not wellformed or missing
- 200: the responsed route.
The structure of 200 response is like:
{
"paths": [
{
"wkt": "LINESTRING (lng1 lat1, lng2 lat2, lng3 lat3, ...)", //wkt that can be drawn, (only with wkt=true)
"instructions": [...], //list of instructions
"distance": ..., //total distance of the route. In meters
"bbox": [lng1, lat1, lng2, lat2], //bounding box of the line string of the route
"time": ..., //total time of the route. In milliseconds.
"points_encoded": true, //boolean flag that indicates if the returned points are encripted. Always true.
"points": "..." //encoded list of points.
},
… alternative routes if present...
],
"info": {
"copyrights": [
"GraphHopper",
"OpenStreetMap contributors"
]
}
}
An instruction can be:
BASIC:
{
"distance": float, //distance of a segment's route. In meters
"heading": float, //compass direction that indicates the orientation of movement at a given point. In degrees.
"sign": integer, //label of Graphhopper action
"interval": [integer, integer], //the index of start and finish waypoints of that instruction.
"text": "Continue onto ...", //textual representation of the instruction
"time": integer, //time needed to cover segment's route. In milliseconds.
"street_name": "…" //street name
}
BUS:
{
"interval": [...],
"text": "Pt_start_trip", //start of the bus instruction.
"leg": {
"map": {
"trip_id": "...", //id of bus trip
"travelTime": integer, //time needed to cover segment's route. In milliseconds.
"route_id": "...", //id of bus route
"agency_name": "...", //bus agency name
"stop": {
"myArrayList": [
{
"map": {
"stop_arrivalTime": "yyyy-MM-ddThh:mm:ssZ", //Bus arrival timestamp
"stop_id": "...", //id of bus stop
"stop_name": "…" //name of the bus stop
}
},
...
]
},
"route_name": "...", //bus route name
"agency_id": "...", //id of agency
"type": "pt",//type of route. Is always 'pt'
"trip_headsign": "...", //destination headsign of bus route
"feed_id": "…" //id of GTFS feed
}
}
},
{
"distance": 0,
"sign": ...,
"interval":[...],
"text": "Pt_end_trip", //end of the bus instruction.
"time": 0,
"street_name": "..."
}
Modal routing produce only basic type of instruction, multimodal routing both type if bus route is found, else only basic.
Examples
text desc + api call + api response + img (all with alternatives)
Example #1: Pedestrian area
Suppose user wants to go through a pedestrian area (here the city center of Florence, in grey) and follow the shortest path. The inputs are:
- vehicle = foot
- weighting = shortest
Its response:
{"paths":[{"wkt":"LINESTRING (11.253722 43.773609, 11.253754 43.773575, 11.253777 43.773498, 11.25381 43.773499, 11.253835 43.773452, 11.254006 43.773456, 11.254001 43.773408, 11.254024 43.773408, 11.254015 43.772851, 11.254433 43.772876, 11.254575 43.772762, 11.254524 43.772724, 11.254514 43.772208, 11.255358 43.772215, 11.25607 43.772204, 11.256807 43.772132, 11.256929 43.771498, 11.257889 43.771502, 11.257907 43.771235, 11.257872 43.770916, 11.257915 43.770912, 11.257894 43.770641, 11.257919 43.77064, 11.257912 43.770594, 11.258101 43.770578)","instructions":[{"distance":13.285,"heading":145.99,"sign":0,"interval":[0,2],"text":"Continue","time":9565,"street_name":""},{"distance":2.666,"sign":-2,"interval":[2,3],"text":"Turn left","time":1920,"street_name":""},{"distance":5.533,"sign":2,"interval":[3,4],"text":"Turn right onto Via Ferdinando Zannetti","time":3984,"street_name":"Via Ferdinando Zannetti"},{"distance":13.736,"sign":-2,"interval":[4,5],"text":"Turn left onto Via dei Cerretani","time":9890,"street_name":"Via dei Cerretani"},{"distance":5.317,"sign":2,"interval":[5,6],"text":"Turn right onto Piazza dell'Olio","time":3828,"street_name":"Piazza dell'Olio"},{"distance":1.807,"sign":-2,"interval":[6,7],"text":"Turn left","time":1301,"street_name":""},{"distance":61.928,"sign":2,"interval":[7,8],"text":"Turn right","time":44588,"street_name":""},{"distance":33.634,"sign":-2,"interval":[8,9],"text":"Turn left","time":24216,"street_name":""},{"distance":17.099,"sign":2,"interval":[9,10],"text":"Turn right","time":12311,"street_name":""},{"distance":5.875,"sign":2,"interval":[10,11],"text":"Turn right","time":4230,"street_name":""},{"distance":57.395,"sign":-7,"interval":[11,12],"text":"Keep left","time":41324,"street_name":""},{"distance":184.641,"sign":-2,"interval":[12,15],"text":"Turn left onto Via dei Tosinghi","time":132942,"street_name":"Via dei Tosinghi"},{"distance":71.195,"sign":2,"interval":[15,16],"text":"Turn right onto Via dello Studio","time":51260,"street_name":"Via dello Studio"},{"distance":77.052,"sign":-2,"interval":[16,17],"text":"Turn left","time":55477,"street_name":""},{"distance":65.286,"sign":2,"interval":[17,19],"text":"Turn right","time":47006,"street_name":""},{"distance":3.507,"sign":-2,"interval":[19,20],"text":"Turn left","time":2526,"street_name":""},{"distance":32.14,"sign":2,"interval":[20,22],"text":"Turn right","time":23141,"street_name":""},{"distance":5.109,"sign":2,"interval":[22,23],"text":"Turn right","time":3679,"street_name":""},{"distance":15.309,"sign":-2,"interval":[23,24],"text":"Turn left onto Via Ghibellina","time":11022,"street_name":"Via Ghibellina"},{"distance":0,"sign":4,"last_heading":96.69235750627772,"interval":[24,24],"text":"Arrive at destination","time":0,"street_name":""}],"distance":672.514005487,"bbox":[10.0185096,42.3148,12.2088999,44.1385999],"time":484210,"points_encoded":true,"points":"_pdjGw~tcADENC?EFE?a@H??ClB@CsAT[FHfB@AgD@oCLqC~BWA_Et@C~@D?Gt@B?CH?Be@"},{"wkt":"LINESTRING (11.253722 43.773609, 11.253754 43.773575, 11.253777 43.773498, 11.254537 43.7735, 11.254885 43.773486, 11.255321 43.773436, 11.255377 43.773528, 11.256006 43.773497, 11.256533 43.773497, 11.256771 43.773657, 11.256841 43.773684, 11.257089 43.773674, 11.257253 43.773583, 11.257194 43.773533, 11.257347 43.773425, 11.257609 43.773199, 11.257744 43.772886, 11.257831 43.772579, 11.257927 43.771494, 11.257926 43.771217, 11.257894 43.770914, 11.257915 43.770912, 11.257894 43.770641, 11.257919 43.77064, 11.257912 43.770594, 11.258101 43.770578)","instructions":[{"distance":13.285,"heading":145.99,"sign":0,"interval":[0,2],"text":"Continue","time":9565,"street_name":""},{"distance":124.472,"sign":-2,"interval":[2,5],"text":"Turn left","time":89620,"street_name":""},{"distance":11.126,"sign":-2,"interval":[5,6],"text":"Turn left onto Via dei Martelli","time":8011,"street_name":"Via dei Martelli"},{"distance":161.863,"sign":2,"interval":[6,12],"text":"Turn right","time":116541,"street_name":""},{"distance":128.611,"sign":2,"interval":[12,17],"text":"Turn right onto Via dei Servi","time":92600,"street_name":"Via dei Servi"},{"distance":185.541,"sign":0,"interval":[17,20],"text":"Continue onto Via del Proconsolo","time":133590,"street_name":"Via del Proconsolo"},{"distance":1.741,"sign":-2,"interval":[20,21],"text":"Turn left","time":1254,"street_name":""},{"distance":32.14,"sign":2,"interval":[21,23],"text":"Turn right","time":23141,"street_name":""},{"distance":5.109,"sign":2,"interval":[23,24],"text":"Turn right","time":3679,"street_name":""},{"distance":15.309,"sign":-2,"interval":[24,25],"text":"Turn left onto Via Ghibellina","time":11022,"street_name":"Via Ghibellina"},{"distance":0,"sign":4,"last_heading":96.69235750627772,"interval":[25,25],"text":"Arrive at destination","time":0,"street_name":""}],"distance":679.1970054870002,"bbox":[10.0185096,42.3148,12.2088999,44.1385999],"time":489023,"points_encoded":true,"points":"_pdjGw~tcADENCAwCBeAHwAQID}B?iB_@o@EM@o@Pa@HJT]l@s@|@[|@QvEQv@?z@D?Ct@B?CH?Be@"}],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}}
And its visual representation
Fig.1

In green the first route, in purple the alternative. Red pins are start and stop waypoints.
Example #2: Cycle lane
Suppose user wants to go on a cycle lane and follow the shortest path. The inputs are:
- vehicle = bike
- weighting = shortest
Api call:
Its response:
{"paths":[{"wkt":"LINESTRING (11.297054 43.7197, 11.297041 43.7197, 11.297058 43.720159, 11.296997 43.720161, 11.296976 43.720185, 11.296856 43.720213, 11.296835 43.720273, 11.29669 43.720396, 11.296667 43.720437, 11.296683 43.720465, 11.296743 43.720489, 11.29684 43.720568, 11.296913 43.720675, 11.296994 43.720846, 11.297026 43.720971, 11.296967 43.721, 11.297009 43.721153, 11.297009 43.721237, 11.296769 43.722797, 11.296732 43.722792, 11.296694 43.722992)","instructions":[{"distance":1.038,"heading":270.32,"sign":0,"interval":[0,1],"text":"Continue onto Via Spinello Aretino","time":208,"street_name":"Via Spinello Aretino"},{"street_ref":"SP56","distance":51.066,"sign":2,"interval":[1,2],"text":"Turn right onto Via di Tizzano","time":10213,"street_name":"Via di Tizzano"},{"distance":121.707,"sign":-2,"interval":[2,15],"text":"Turn left","time":109536,"street_name":""},{"distance":204.242,"sign":2,"interval":[15,19],"text":"Turn right","time":41329,"street_name":""},{"distance":22.449,"sign":2,"interval":[19,20],"text":"Turn right onto Via del Ponte Nuovo","time":4490,"street_name":"Via del Ponte Nuovo"},{"distance":0,"sign":4,"last_heading":341.0416683957199,"interval":[20,20],"text":"Arrive at destination","time":0,"street_name":""}],"distance":400.5025692241668,"bbox":[10.0185096,42.3148,12.2088999,44.1385999],"time":165776,"points_encoded":true,"points":"c_ziGqm}cA?@yAAAJCBEVKBWZGDECCKOQUOa@OYECJ_@GO?wHn@?Dg@F"}],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}}
And its visual representation
Fig.2

In that area there’s a cycle path passing on narrow bridge to cross the river.
Example #3: Bus route
Suppose user wants to take the bus. The inputs are:
- startDatetime = 2025-06-13T10:55
- vehicle = bus
or alternatively
- routing= pt or routing=public_transport
Api call:
Its response:
{"paths":[{"wkt":"LINESTRING (11.276221 43.765603, 11.276303 43.765598, 11.276227 43.765678, 11.27621 43.765741, 11.276219 43.76583, 11.27625 43.765877, 11.2772 43.766661, 11.277268 43.766715, 11.277357 43.766788, 11.278112 43.76741, 11.27828 43.767547, 11.279198 43.768338, 11.279291 43.768413, 11.280641 43.769528, 11.280785 43.769651, 11.280895 43.769732, 11.281207 43.76997, 11.281435 43.770134, 11.281687 43.770306, 11.281901 43.770471, 11.283323 43.771649, 11.283652 43.771934, 11.283797 43.772107, 11.283891 43.772228, 11.284219 43.772532, 11.284358 43.772659, 11.284471 43.772762, 11.284694 43.773079, 11.284694 43.773079, 11.282315 43.773559, 11.279792 43.776171, 11.278874 43.77821, 11.278773 43.778046, 11.280458 43.779909, 11.280468 43.779919, 11.280416 43.779944)","instructions":[{"distance":6.634,"heading":95.61,"sign":0,"interval":[0,1],"text":"Continue onto Lungarno del Tempio","time":4776,"street_name":"Lungarno del Tempio"},{"distance":589.387,"sign":-3,"interval":[1,14],"text":"Turn sharp left onto Via Piagentina","time":424358,"street_name":"Via Piagentina"},{"distance":365.379,"sign":0,"interval":[14,22],"text":"Continue onto Piazza Leon Battista Alberti","time":263072,"street_name":"Piazza Leon Battista Alberti"},{"distance":90.835,"sign":0,"interval":[22,26],"text":"Continue onto Via Edmondo De Amicis","time":65402,"street_name":"Via Edmondo De Amicis"},{"distance":5.338,"sign":-2,"interval":[26,27],"text":"Turn left","time":3843,"street_name":""},{"interval":[27,31],"text":"Pt_start_trip","leg":{"map":{"trip_id":"6073_70200951","travelTime":180000,"route_id":"2516017259","agency_name":"Autolinee Toscane - Urbano Area Metropolitana Fiorentina","stop":{"myArrayList":[{"map":{"stop_arrivalTime":"2025-06-13T09:09:00Z","stop_id":"FI0214_600","stop_name":"De Amicis Torretta"}},{"map":{"stop_arrivalTime":"2025-06-13T09:10:00Z","stop_id":"FI0699_600","stop_name":"Campo D'Arrigo Torretta"}},{"map":{"stop_arrivalTime":"2025-06-13T09:11:00Z","stop_id":"FI0700_600","stop_name":"Campo D'Arrigo Puccioni"}},{"map":{"stop_arrivalTime":"2025-06-13T09:12:00Z","stop_id":"FI0483_600","stop_name":"Fanti Stadio Ridolfi"}}]},"route_name":"20","agency_id":"888-48","type":"pt","trip_headsign":"Caruso","feed_id":"gtfs_17"}}},{"distance":0,"sign":103,"interval":[31,32],"text":"Pt_end_trip","time":0,"street_name":"Fanti Stadio Ridolfi"},{"distance":248.845,"heading":33.15,"sign":0,"interval":[32,34],"text":"Continue onto Viale Manfredo Fanti","time":179169,"street_name":"Viale Manfredo Fanti"},{"distance":5.027,"sign":-2,"interval":[34,35],"text":"Turn left","time":3620,"street_name":""},{"distance":0,"sign":4,"last_heading":303.20353560528036,"interval":[35,35],"text":"Arrive at destination","time":0,"street_name":""}],"distance":1311.445369772591,"bbox":[10.0185096,42.3148,12.2088999,44.1385999],"time":1202789,"points_encoded":true,"points":"_~bjGkkycA@OONMBOAIG}C}DIKMQ{BwC[_@}CwDOS}EmGY[OUo@}@_@m@a@q@a@k@iF{Gy@aAa@[WS}@_AW[UW}@k@??_BzMkOvNwKvD`@RsJoIAAEH"},{"wkt":"LINESTRING (11.276221 43.765603, 11.276007 43.765619, 11.276037 43.765772, 11.276049 43.765826, 11.27557 43.765863, 11.275575 43.765883, 11.275788 43.766833, 11.275719 43.766841, 11.275733 43.766902, 11.275934 43.767775, 11.275949 43.767824, 11.275976 43.767903, 11.276251 43.768606, 11.276279 43.768682, 11.276309 43.768763, 11.276796 43.770033, 11.276814 43.770078, 11.276833 43.770113, 11.277137 43.770654, 11.277179 43.770695, 11.277243 43.770798, 11.278118 43.772236, 11.278049 43.772253, 11.278026 43.772361, 11.277562 43.772508, 11.277579 43.772536, 11.277601 43.772576, 11.277613 43.772597, 11.276956 43.772795, 11.276965 43.772811, 11.276935 43.77282, 11.27739 43.773587, 11.277549 43.773877, 11.277539 43.773957, 11.277531 43.774004, 11.277557 43.774078, 11.277731 43.774311, 11.278339 43.775053, 11.278312 43.775094, 11.27832 43.775106, 11.278302 43.775127, 11.277312 43.776172, 11.276907 43.776593, 11.276762 43.776641, 11.276536 43.776658, 11.276573 43.776675, 11.276728 43.776757, 11.276943 43.77687, 11.277079 43.776944, 11.277213 43.777015, 11.277494 43.777165, 11.278193 43.777539, 11.278639 43.777774, 11.278726 43.777834, 11.278719 43.777861, 11.27875 43.777896, 11.278784 43.777935, 11.278849 43.778009, 11.280535 43.779871, 11.280544 43.779881, 11.280468 43.779919, 11.280416 43.779944)","instructions":[{"distance":17.25,"heading":275.61,"sign":0,"interval":[0,1],"text":"Continue onto Lungarno del Tempio","time":12420,"street_name":"Lungarno del Tempio"},{"distance":23.351,"sign":2,"interval":[1,3],"text":"Turn right","time":16813,"street_name":""},{"distance":147.973,"sign":-2,"interval":[3,6],"text":"Turn left","time":106541,"street_name":""},{"distance":5.6,"sign":-2,"interval":[6,7],"text":"Turn left","time":4032,"street_name":""},{"distance":632.887,"sign":2,"interval":[7,21],"text":"Turn right onto Via del Ghirlandaio","time":455679,"street_name":"Via del Ghirlandaio"},{"distance":5.879,"sign":-2,"interval":[21,22],"text":"Turn left","time":4233,"street_name":""},{"distance":52.776,"sign":2,"interval":[22,24],"text":"Turn right onto Via Fra' Paolo Sarpi","time":37999,"street_name":"Via Fra' Paolo Sarpi"},{"distance":10.666,"sign":2,"interval":[24,27],"text":"Turn right","time":7679,"street_name":""},{"distance":59.021,"sign":-2,"interval":[27,29],"text":"Turn left onto Via Luca Landucci","time":42495,"street_name":"Via Luca Landucci"},{"distance":2.632,"sign":-2,"interval":[29,30],"text":"Turn left","time":1895,"street_name":""},{"distance":136.458,"sign":2,"interval":[30,33],"text":"Turn right onto Via Capo di Mondo","time":98250,"street_name":"Via Capo di Mondo"},{"distance":139.002,"sign":0,"interval":[33,37],"text":"Continue onto Via Capo di Mondo","time":100081,"street_name":"Via Capo di Mondo"},{"distance":5.106,"sign":-2,"interval":[37,38],"text":"Turn left","time":3676,"street_name":""},{"distance":202.053,"sign":2,"interval":[38,42],"text":"Turn right onto Via Capo di Mondo","time":145479,"street_name":"Via Capo di Mondo"},{"distance":31.058,"sign":-7,"interval":[42,44],"text":"Keep left","time":22362,"street_name":""},{"distance":219.257,"sign":3,"interval":[44,53],"text":"Turn sharp right","time":169899,"street_name":""},{"distance":3.034,"sign":-2,"interval":[53,54],"text":"Turn left","time":2184,"street_name":""},{"distance":268.145,"sign":1,"interval":[54,59],"text":"Turn slight right","time":193064,"street_name":""},{"distance":12.409,"sign":-2,"interval":[59,61],"text":"Turn left","time":8935,"street_name":""},{"distance":0,"sign":4,"last_heading":303.20353560528036,"interval":[61,61],"text":"Arrive at destination","time":0,"street_name":""}],"distance":1974.5574945080489,"bbox":[10.0185096,42.3148,12.2088999,44.1385999],"time":1433716,"points_encoded":true,"points":"_~bjGkkycAAj@_@EIAG|AC?}Di@ALKCmDg@IAOEkCw@OCOE}FaBGCGCkB{@GGSM_HmDCLUB[zAEAGECAg@bCCA?DyCyAy@_@O@I?MCo@c@sCwBGBA?C@qEdEsApAIZAl@CGO]Uk@OYM[]w@iAkCo@wAKQE@EEGGMKuJqIAAENEH"}],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}}
And its visual representation
Fig.3

In green the pedestrian segment to take the bus, in blue the bus route and in purple the alternative only pedestrian route.
Example #4: Taxi route
Suppose user drive a taxi or an emergency service vehicle. The inputs are:
- vehicle = taxi
Api call:
Its response:
{"paths":[{"wkt":"LINESTRING (11.285417 43.762191, 11.282908 43.762426, 11.28286 43.762462, 11.28266 43.76254, 11.282595 43.762547, 11.282549 43.762537, 11.282504 43.762632, 11.281818 43.763368, 11.281761 43.763533, 11.281768 43.763585, 11.281841 43.763722, 11.281927 43.763816, 11.281933 43.76391, 11.281668 43.764253, 11.281851 43.765694)","instructions":[{"distance":203.149,"heading":277.37,"sign":0,"interval":[0,1],"text":"Continue onto Via Giovanni dalle Bande Nere","time":16252,"street_name":"Via Giovanni dalle Bande Nere"},{"exit_number":2,"distance":183.866,"sign":6,"exited":true,"turn_angle":-2.03,"interval":[1,10],"text":"At roundabout, take exit 2 onto Via Poggio Bracciolini","time":14330,"street_name":"Via Poggio Bracciolini"},{"exit_number":2,"distance":66.78,"sign":6,"exited":true,"interval":[10,13],"text":"At roundabout, take exit 2 onto Ponte Giovanni da Verrazzano","time":5342,"street_name":"Ponte Giovanni da Verrazzano"},{"distance":160.978,"sign":1,"interval":[13,14],"text":"Turn slight right onto Ponte Giovanni da Verrazzano","time":12861,"street_name":"Ponte Giovanni da Verrazzano"},{"distance":0,"sign":4,"last_heading":2.1084846860814292,"interval":[14,14],"text":"Arrive at destination","time":0,"street_name":""}],"distance":614.7736034630897,"bbox":[10.0185133,42.3148,12.2088999,44.1385999],"time":48785,"points_encoded":true,"points":"uhbjGyd{cAm@tNGHOd@?L@HSFqChCa@HI?[OQOQAeAt@_He@"}],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}}
And its visual representation
Fig.4

To see what really matters let’s compare the same waypoints route but with a car:
Fig.5

As you can see car can’t take “Via Giovanni dalle Bande Nere” because the direction of travel is left-to-right.
In real life there’s a right-to-left preferential lane that can be used by taxi, bus, emergency but not by car.
Example #5: Intermediate stops
Suppose user wants to visit numerous locations. The inputs are:
- waypoints = 11.263228654861452,43.76849838492288;11.256147623062134,43.76955206675817;11.255654096603395,43.773441231644576
Api call:
Its response:
{"paths":[{"wkt":"LINESTRING (11.263229 43.768499, 11.26237 43.768848, 11.262433 43.768926, 11.261395 43.769201, 11.260848 43.769371, 11.260523 43.768964, 11.259267 43.769095, 11.258769 43.769178, 11.258767 43.769174, 11.257504 43.76943, 11.256825 43.769496, 11.256541 43.769495, 11.256374 43.769488, 11.25614 43.769527, 11.256374 43.769488, 11.256541 43.769495, 11.25656 43.769557, 11.255919 43.769748, 11.255296 43.769887, 11.255272 43.770013, 11.255293 43.770573, 11.254474 43.770587, 11.254462 43.770886, 11.254524 43.772724, 11.254575 43.772762, 11.254433 43.772876, 11.254509 43.7735, 11.254885 43.773486, 11.255321 43.773436, 11.255377 43.773528, 11.255661 43.773514)","instructions":[{"distance":89.154,"heading":299.23,"sign":0,"interval":[0,2],"text":"Continue onto Largo Piero Bargellini","time":64191,"street_name":"Largo Piero Bargellini"},{"distance":136.634,"sign":-2,"interval":[2,4],"text":"Turn left","time":98377,"street_name":""},{"distance":52.239,"sign":-2,"interval":[4,5],"text":"Turn left onto Via Giuseppe Verdi","time":37612,"street_name":"Via Giuseppe Verdi"},{"distance":142.904,"sign":2,"interval":[5,7],"text":"Turn right onto Borgo de' Greci","time":102891,"street_name":"Borgo de' Greci"},{"distance":0.465,"sign":-2,"interval":[7,8],"text":"Turn left onto Via dei Magalotti","time":335,"street_name":"Via dei Magalotti"},{"distance":105.4,"sign":2,"interval":[8,9],"text":"Turn right","time":75888,"street_name":""},{"distance":79.019,"sign":2,"interval":[9,11],"text":"Turn right","time":56894,"street_name":""},{"distance":32.721,"sign":-7,"interval":[11,13],"text":"Keep left onto Piazza della Signoria","time":23559,"street_name":"Piazza della Signoria"},{"distance":0,"sign":5,"last_heading":282.73748316320734,"interval":[13,13],"text":"Waypoint 1","time":0,"street_name":""},{"distance":32.721,"heading":102.74,"sign":-98,"interval":[13,15],"text":"Make a U-turn onto Piazza della Signoria","time":23559,"street_name":"Piazza della Signoria"},{"distance":7.041,"sign":-2,"interval":[15,16],"text":"Turn left onto Piazza della Signoria","time":5070,"street_name":"Piazza della Signoria"},{"distance":108.119,"sign":-2,"interval":[16,18],"text":"Turn left onto Piazza della Signoria","time":77846,"street_name":"Piazza della Signoria"},{"distance":14.16,"sign":2,"interval":[18,19],"text":"Turn right onto Piazza della Signoria","time":10195,"street_name":"Piazza della Signoria"},{"distance":62.283,"sign":1,"interval":[19,20],"text":"Turn slight right onto Via dei Calzaiuoli","time":44844,"street_name":"Via dei Calzaiuoli"},{"distance":65.795,"sign":-2,"interval":[20,21],"text":"Turn left onto Via dei Lamberti","time":47372,"street_name":"Via dei Lamberti"},{"distance":237.803,"sign":2,"interval":[21,23],"text":"Turn right","time":171218,"street_name":""},{"distance":5.875,"sign":1,"interval":[23,24],"text":"Turn slight right","time":4230,"street_name":""},{"distance":17.099,"sign":-2,"interval":[24,25],"text":"Turn left","time":12311,"street_name":""},{"distance":69.721,"sign":1,"interval":[25,26],"text":"Turn slight right","time":50199,"street_name":""},{"distance":65.665,"sign":2,"interval":[26,28],"text":"Turn right","time":47279,"street_name":""},{"distance":11.126,"sign":-2,"interval":[28,29],"text":"Turn left onto Via dei Martelli","time":8011,"street_name":"Via dei Martelli"},{"distance":22.856,"sign":2,"interval":[29,30],"text":"Turn right","time":16457,"street_name":""},{"distance":0,"sign":4,"last_heading":93.93070093374716,"interval":[30,30],"text":"Arrive at destination","time":0,"street_name":""}],"distance":1358.8002465767397,"bbox":[10.0185096,42.3148,12.2088999,44.1385999],"time":978338,"points_encoded":true,"points":"apcjGczvcAeAhDOKw@nEa@lBpA~@YzFObB??s@zFKfC?v@@`@Gn@Fo@Aa@KCe@`C[zBYBoBCAbD{@@oJKGIUZ}BMBkAHwAQI@y@"}],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}}
And its visual representation
Fig.6

The blue pin is the intermediate pin
Example #6: Avoid areas
Suppose user has to avoid certain areas for any reason. The inputs are:
- avoid_areas = %7B%22type%22%3A%22FeatureCollection%22%2C%22features%22%3A%5B%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B11.253921%2C43.781172%5D%2C%5B11.252226%2C43.77922%5D%2C%5B11.253889%2C43.778694%5D%2C%5B11.255445%2C43.780615%5D%2C%5B11.253921%2C43.781172%5D%5D%5D%7D%7D%5D%7D // this is the encoded string of a Feature Collection object
Api call:
Its response:
{"paths":[{"wkt":"LINESTRING (11.252017 43.780721, 11.25196 43.780744, 11.25209 43.780865, 11.252229 43.781077, 11.252276 43.781212, 11.252644 43.781614, 11.25283 43.781765, 11.252989 43.781831, 11.253813 43.782031, 11.256703 43.782688, 11.256802 43.782613, 11.256865 43.782519, 11.256232 43.781791, 11.256531 43.78152, 11.256929 43.781101, 11.255474 43.779252, 11.255525 43.77923)","instructions":[{"distance":5.245,"heading":299.98,"sign":0,"interval":[0,1],"text":"Continue onto Viale Filippo Strozzi","time":629,"street_name":"Viale Filippo Strozzi"},{"distance":112.118,"sign":2,"interval":[1,5],"text":"Turn right onto Viale Filippo Strozzi","time":9994,"street_name":"Viale Filippo Strozzi"},{"distance":350.229,"sign":7,"interval":[5,9],"text":"Keep right onto Viale Filippo Strozzi","time":19398,"street_name":"Viale Filippo Strozzi"},{"distance":23.167,"sign":2,"interval":[9,11],"text":"Turn right onto Via Santa Caterina D'Alessandria","time":2780,"street_name":"Via Santa Caterina D'Alessandria"},{"distance":95.574,"sign":2,"interval":[11,12],"text":"Turn right onto Via Santa Caterina D'Alessandria","time":11469,"street_name":"Via Santa Caterina D'Alessandria"},{"distance":95.004,"sign":-2,"interval":[12,14],"text":"Turn left onto Via delle Ruote","time":11400,"street_name":"Via delle Ruote"},{"distance":236.542,"sign":2,"interval":[14,15],"text":"Turn right onto Via San Zanobi","time":28386,"street_name":"Via San Zanobi"},{"distance":4.801,"sign":-2,"interval":[15,16],"text":"Turn left onto Via Ventisette Aprile","time":384,"street_name":"Via Ventisette Aprile"},{"distance":0,"sign":4,"last_heading":119.80547496185515,"interval":[16,16],"text":"Arrive at destination","time":0,"street_name":""}],"distance":922.6799014819663,"bbox":[10.0185133,42.3148,12.2088999,44.1385999],"time":84440,"points_encoded":true,"points":"o|ejGattcACHWWi@[[IoAiA]c@M_@g@eDaCaQLSRKnC|Bv@{@pAmApJ`HBI"}],"info":{"copyrights":["GraphHopper","OpenStreetMap contributors"]}}
And its visual representation
Fig.7

Let’s compare with a empty avoid area version
Fig.8

As you can see with an avoid area the responsed route try to find, if possible, an alternative path to connect the points and to not intersect the area passed.