Avoid Highways & Tolls

Products Used: Directions API & Navigation API


Use the avoid feature in the routing APIs to ensure that your delivery vans are not taking the roads with tolls or plying on the highways with few and far between exit ramps. This can help save both time and money when traveling to delivery locations. Depending on the information needed, users can use this feature either in NextBillion.ai’s Directions API to get desired route directions along with ETA and distance information, or they can also use Navigation API to get turn-by-turn navigation instructions as well along with other information about the route.

Following is a sample Directions API request with following parameters:

  • A pair of origin & destination locations
  • mode option set to “car”
  • avoid option set to “toll” and “highway”

Directions API request

1curl --location 'https://api.nextbillion.io/directions/json?origin=38.94508068,-77.34270692&destination=39.31131584,-76.61936891&mode=car&key=<your_api_key>&avoid=toll|highway&overview=simplified'

Directions API response

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "qmulFz~`wMtYwpBcJwiAmz@{D}WibAja@odBmm@q|@biBcdC~V_kBw\\gzAp`A_kCuu@udCoTeeEz_BcoD~iCckCld@{cDzkBck@me@}~@pOwdIeUu~FmnBw_C_eC_fAuyAggB_eCuf@_vCk}AquAiuC{zLkgF_pHoyJytDkjBqgGw|FgyDueJafCuYey@gbAysAsL}nAmsAu`@pi@{n@Msn@}m@yz@uD",
6 "distance": 100368.6,
7 "duration": 6755.1,
8 "legs": [
9 {
10 "distance": {
11 "value": 100368
12 },
13 "duration": {
14 "value": 6755
15 },
16 "steps": []
17 }
18 ]

Notice that if the “avoid” configuration is removed a different route is suggested in that case.

Let’s take a look at how a Navigation API call would look like for the exact same parameters as the above example.

1curl --location 'https://api.nextbillion.io/navigation/json?origin=38.94508068,-77.34270692&destination=39.31131584,-76.61936891&mode=car&key=<your_api_key>&avoid=toll|highway&overview=simplified'
1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "wp_hiA~}rorChjG}pb@ynBgjVypQyy@oxFg`TtvI_v^ioMwfRbd`@yqh@foF_w`@shHmo[rnSawj@{aP{wh@evEa}|@|g]g`v@xlj@oxj@ruJyor@j_a@}wLc_Kc~Row@yutDsl^syc@sgl@qqXwi[qq_@_{h@clKgen@in\\w`Zu~m@iuiCergA{h~AehuBgyw@wp`@wtqAwhnAiey@yaoB_fi@}iGqdQi_TkoYqgCe~W{jYapIlhL{}MoCi{MqtMutQuw@",
6 "distance": 100313.6,
7 "duration": 6894,
8 "start_location": {
9 "latitude": 38.945052,
10 "longitude": -77.342704
11 },
12 "end_location": {
13 "latitude": 39.311317,
14 "longitude": -76.619308
15 },
16 "legs": [
17 {
18 "distance": {

Visit Directions API | Navigation API documentation to know more about the available features.