Route Report API

Introduction

NextBillion.ai’s Route Report API is a useful service to get a comprehensive report of a trip. Users can provide the geometry of the desired route or trip and then get details like duration, distance covered during the trip - broken down by state, country, road class along with maximum speeds on the road segments forming the route. The service also informs if the route has any tolls, bridges, tunnels or roundabout maneuvers along it. The service is useful for comparing routes, computing drive mileage and estimating associated metrics as per your business needs.

A valid Route Report request can be submitted using an HTTPS POST method containing the desired route geometry and its encoding type through a request body.


POST

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


Request Parameters

Loading..

Request Body

Loading..

Response Schema

Loading..

Sample Query

Let’s request a report and other stats for a trip in Indiana state by providing a sample route geometry.

Request

1
curl --location 'https://api.nextbillion.io/route_report?key=<your_api_key>&option=flexible' \
2
--header 'Content-Type: application/json' \
3
--data-raw '{
4
5
"original_shape": "_ujrFjvkeOiBhCKNUX??c@n@yBxCgE|F??_ErFg@t@??[b@U\\SXK@aBvB_@f@wBvCyApBC@k@n@A@g@f@UTEP??]XA?@b@?p@?X??A\\E`@E`@c@jCYfCM`A??gDdV??mBrNWtB]dDKhAM`BM|AIpAElAG~AElBClB?BClE?@@nCBbO@zSDzS@tE?^?h@?rB@tB@`D???l@@|QBpQ??Jj`@@hQ??D|I@xI???X?bK?pACrC?TEjAGbBEv@KtB?@Ep@GfAk@xG?@CRMjAQrAQfAQfAWtAAFYzA??YvA[xAc@~Am@lCi@xBw@jD_B|G_CxJcAjEu@dD]pA_AzDg@rBi@lBUz@Mh@y@pC?@uGdSM\\GPOf@Qp@??Mb@w@fDIb@i@dCa@xBu@jE}DxTeCfN?@cApF[zB[rB]tCObBGh@K~AW`EAj@GxG??A~@AnA?@GhI?fC?@?^?pD?nE?`@?zB?^?f@?xG?rB@`@?n@?bC?h@AN??GnACb@??MpBMzB??Q|B??Ir@In@ERCV?@EP{@jF?@{AnJ??Kj@yBlNu@nEsAhHoC`N}@hE??g@|BmArFq@zCy@xD[vA]`BOz@Y`BQvAKv@Gt@Gb@Ev@G`@KjBIvAY~HYxIQtE??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@bH?`CGvL~I@~@B~@?pB?lBAtG@`FFrHCtGDnDBzB?fD@rB@|B@xABlFBlA@zI?xFDxFDrNBtNDR?dF@|BBJ?J?J?xAB|B@pC@|ABtAAtBAfCKxAG|ACvBKnBKbAEvAIzFQnBElAGhCOxBGzCIpBKjCIvGWp@C"
5
],
6
"mileage": [
7
{
8
"summary": {
9
"state": {
10
"United States|Indiana": 20042
11
},
12
"country": {
13
"United States": 20042
14
}
15
},
16
"segment": {
17
"state": [
18
{
19
"offset": 0,
20
"length": 264,
21
"distance": 20042,
22
"value": "United States|Indiana"
23
}
24
],
25
"country": [
26
{
27
"offset": 0,
28
"length": 264,
29
"distance": 20042,
30
"value": "United States"
31
}
32
]
33
}
34
}
35
],
36
"road_summary": [
37
{
38
"summary": {
39
"has_toll": false,
40
"has_bridge": false,
41
"has_tunnel": false,
42
"has_roundabout": false,
43
"duration": 941.255,
44
"distance": 20042.502,
45
"road_class": {
46
"primary": 1002,
47
"secondary": 14595,
48
"tertiary": 4445
49
}
50
},
51
"segment": {
52
"road_class": [
53
{
54
"offset": 0,
55
"length": 23,
56
"distance": 1002,
57
"value": "primary"
58
},
59
{
60
"offset": 23,
61
"length": 190,
62
"distance": 14595,
63
"value": "secondary"
64
},
65
{
66
"offset": 210,
67
"length": 51,
68
"distance": 4445,
69
"value": "tertiary"
70
}
71
],
72
"max_speed": [
73
{
74
"offset": 0,
75
"length": 23,
76
"distance": 1002,
77
"value": 72
78
},
79
{
80
"offset": 23,
81
"length": 95,
82
"distance": 7585,
83
"value": 88
84
},
85
{
86
"offset": 115,
87
"length": 9,
88
"distance": 545,
89
"value": 64
90
},
91
{
92
"offset": 120,
93
"length": 26,
94
"distance": 1118,
95
"value": 48
96
},
97
{
98
"offset": 144,
99
"length": 111,
100
"distance": 9792,
101
"value": 88
102
}
103
]
104
}
105
}
106
]
107
}

API Query Limits

  • Route geometries generated from sources other than NextBillion.ai services, are not supported in this version.

  • Using geometries generated from “Fast” NextBillion.ai services might lead to discrepancies in distance and duration results in Route Report’s output. It is recommended to source route geometries from “Flexible” Nextbillion.ai services.

  • 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.