Routes with multiple stops

Implement Using: Directions Fast API

In this example, we will configure a request with multiple waypoints or stops that need to be made before the final destination. We will add 3 location coordinates which should be visited before the route ends at the destination location. To accomplish this we configure:

  • origin to denote the starting point of the trip
  • waypoints with location coordinates of 3 stops
  • destination to denote the end point of the trip
  • mode set to “car” to get a route which a car can take

Request

1curl --location 'https://api.nextbillion.io/directions/json?origin=34.06179645,-118.28182218&destination=34.01815592,-118.24560423&mode=car&key=<your_api_key>&waypoints=34.05004809,-118.25490318|34.03748485,-118.24975388|34.02888816,-118.24129738' \
2--header 'Content-Type: application/json'

Response

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

Following is a visual representation of the above route on a map. We can observe that the route passes through all the given stops before arriving at the destination.

docs-image