Avoid Tolls & Highways

Implement Using: Directions Fast API

To get a route between two points which does not go through a toll road or a highway we can make use of the avoid parameter of the Directions API. The avoid parameter can take multiple values in input and then suggests the best feasible route while avoiding the specified objects/roads. We configure:

  • origin & destination to to denote the starting and end locations of the trip
  • mode set to “car” to get a route which a car can take
  • avoid parameter specifying “toll” & “highway” as the criteria

Request

1curl --location 'https://api.nextbillion.io/directions/json?origin=34.03113938,-118.20745576&destination=34.02842053,-118.26701916&mode=car&key=<your_api_key>&avoid=toll|highway' \
2--header 'Content-Type: application/json'

Response

1{
2 "status": "Ok",
3 "routes": [...]
4}