Directions API

Introduction

Nextbillion.ai’s Directions API is a service that computes a route between two places. With the Directions API, you can:

  • Find the most optimal route and ETAs between the origin and the destination.
  • Get directions for different driving modes like car & truck.
  • You can also add waypoints, which are coordinates along the route.
  • Plan your trips in advance by setting departure_time to get best routes and ETAs
  • Get different routes based on different truck dimensions and weight.

The Directions API has 2 versions to cater to different business needs. First, is the Fast version which would return the route and related information in real time. Second, is the Flexible version which offers truck routing and time-based routing features in addition to those available in the Fast version. We will be talking about both these services below

Also check out NextBillion's Road Editor API for easy manipulation and custom updates to road network data, enhancing the utility of Directions API response in meeting your business needs

Directions Fast API

GET

https://api.nextbillion.io/directions/json?key={your_api_key}


The Directions Fast API gets the directions in real time for trips starting at current time. The routes returned through this service have the traffic conditions factored in to avoid any delays under usual circumstances.

Directions Fast API service can take input using both HTTPS GET and POST requests. Request URL, parameters and response schema are exactly the same for both methods. However, an important difference between these two input methods is in the maximum number of waypoints that can be added to the input. We will cover them below.

GET Request

To utilize the Directions API and obtain route information, a GET request is made with the required parameters: key, origin, and destination. To customize the request, additional parameters such as waypoints, mode and avoid can be included based on the user's preferences.

Please note that the maximum number of waypoints allowed in a GET request is 50.

Request Parameters

Loading..

POST Request

The parameters and their properties for the Directions Fast POST version are the same as listed in the Request Parameter section. The key is passed as a request parameter and the rest of the parameters should be included in the Request Body. An example of a POST request is added in the Sample Queries-Directions Fast section below.

Please note that the maximum number of waypoints allowed in a POST request is 200.

Response Schema

Loading..

Directions Flexible API

GET

https://api.nextbillion.io/directions/json?option=flexible&key={your_api_key}


The Directions Flexible API offers customizable features for determining routes accurately. It can serve requests for truck specific routing, time based routing, choosing between fastest and shortest route types and also offers to return segment-wise speed limits of the route suggested. The traffic conditions are also factored in, to avoid delays under usual circumstances.

To use the Directions Flexible API service please set the option parameter to flexible. Please note some request and response parameters available in the Fast version are not available in Flexible version and vice-versa.

The Flexible version also supports both HTTPS GET and POST methods. Request URL, parameters and response schemas are exactly the same for both methods. However, an important difference between these two input methods is in the maximum number of waypoints that can be added to the input. We will cover them below.

GET Request

To utilize the Directions Flexible API and obtain route information, a GET request is made with the required parameters: key, origin, destination and option. To customize the request, additional parameters such as waypoints, mode and avoid can be included based on the user's preferences.

Please note that the maximum number of waypoints allowed in a GET request is 50.

Request Parameters

Loading..

POST Request

The parameters and their properties for the Directions Flexible POST version are the same as listed in the Request Parameter section. The key and option are passed as query parameters and the rest of the parameters should be included in the Request Body. An example for a POST request is added in the Sample Queries - Directions Flexible section below.

Response Schema

Loading..

API Query Limits

  • Following are the maximum number of waypoints allowed in a single request:
    • Directions Fast
      • 50 when using HTTPS GET
      • 200 when using HTTPS POST
    • Directions Flexible have a limit of 50 waypoints when irrespective of the HTTPS method used.
  • Maximum dimensions allowed for truck_size are 5000 cm for length, 5000 cm for width, 1000 cm for height.
  • Maximum weight allowed for truck_weight (including the trailer and shipped goods) is 100,000 kg
  • NextBillion.ai allows a maximum rate limit of 6000 queries per minute or 100 queries/second for continuous requests.
    Note: We can increase the quota if needed, on request. Contact [email protected] for more details.

API Error Codes

Response CodeDescriptionAdditional Notes
200

Normal success case.

Normal success case.

400

Input validation failed.

There is a missing or an invalid parameter or a parameter with an invalid value type is added to the request.

401

APIKEY not supplied or invalid.

This error occurs when the wrong API key is passed in the request or the key is missing altogether

403

APIKEY is valid but does not have access to requested resources.

You might be querying for a geographical region which is not valid for your account, or requesting a service which is not enabled for you.

404

Requested host/path not found.

This error occurs when a malformed hostname is used.

413

Request entity too large

This error is caused when the length of input request URI or the request body is too large. Please modify the request. Reach out to [email protected] if the issue still persists.

422

Could not process the request.

Valid route could not be generated for the given parameters

429

Too many requests.

QPM or API request count quota reached

500

Internal Service error.

There was an internal issue with NextBillion.ai services. You can reach out to [email protected] for an explanation.

© 2024 NextBillion.ai all rights reserved.