Optimization API

Introduction

Nextbillion.ai Optimization API computes and returns an optimized route between an origin and destination which have multiple stop points in between. With NextBillion.ai's Route Optimization API you get.

  1. Optimized routing between way points

  2. Highly accurate ETAs with customized routes

  3. Roundtrip optimization with customized destinations

A list of all parameters is specified in the next section.

Parameters

Loading...

Response Schema

Loading...

Query Limits

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.

Examples

Sample API Request

{{base_url}}/optimization/json?coordinates=41.35544869444527,2.0747669962025292|41.37498154684205,2.103705 4530396886|41.38772862000152,2.1311887061315526&destination=last&key={{api_key}}&mode=4w&source=first& roundtrip=false&with_geometry=true

For the above example, here are the parameters we have used-

  1. We have set 3 coordinates separated by pipe symbol.

  2. We have set the destination property equal to last. This means that the last coordinate in our given list will be treated as the destination.

  3. The source property is set to first, so the first coordinate pair in the coordinates object will be treated as the source.

  4. We have set mode as 4w which will return a route pertaining to 4 wheelers only.

  5. The roundtrip property is set to false, so there will be no roundtrip returned.

  6. By setting the with_geometry property as true, we will ensure that the route geometry is returned for each leg of the journey.

Sample API Response

1{
2  "code": "Ok",
3  "waypoints": [
4    {
5      "name": "",
6      "location": {
7        "latitude": 41.35544869444527,
8        "longitude": 2.0747669962025292
9      },
10      "trips_index": 0,
11      "waypoint_index": 0
12    },
13    {
14      "name": "",
15      "location": {
16        "latitude": 41.37498154684205,
17        "longitude": 2.1037054530396886
18      },
19      "trips_index": 0,
20      "waypoint_index": 1
21    },
22    {
23      "name": "",
24      "location": {
25        "latitude": 41.38772862000152,
26        "longitude": 2.1311887061315526
27      },
28      "trips_index": 0,
29      "waypoint_index": 2
30    }
31  ],
32  "trips": [
33    {
34      "geometry": "sjc{mA_hs}BtDcGlHkMrEgIpD}H~A}[email protected][email protected][email protected]@_JK{[email protected]{[email protected]@ VuYTcYNsJXqG|@wLdC}[email protected]@[email protected]^@[email protected]^[email protected]@|@[email protected]@[email protected]@[email protected]{@ [[email protected]@[email protected]{Hy`@[email protected]}D{LoEgNqJeZ}Ii\\cM}[email protected]@[email protected]@eF{[email protected] cF{@[email protected]{LhD}[email protected]`[email protected]~ApAbBhB~ArBlA|[email protected]|EiBfDyHtGeEnD{ElCuDjAa F~AwD`[email protected]{@[email protected]{@^}A\\[email protected][email protected]{@[email protected][email protected] [email protected]}[email protected]{G}AaASiB]}[email protected][email protected][email protected] [email protected]_NgCiJgBkZcGqUcFsMkCaB]kAW{KwByA[[email protected]{JoD}QaHuEaCmNqHyOsIkM{IwGsF_WyRyH _Hg[}WyJeJ_[kV}LkIaEaCwG{DiN}[email protected]}@][email protected][[email protected]{A{[email protected]_LaEuKwD_Jy C{LaFmLoF{KyFwHcEgIeEiFoCkGoEoYcTeB{[email protected][email protected]@[email protected]@[email protected]|@\\yMt @[email protected]{F?eFzDu}ATgIHuINqH`@aMb`@e]tZkXdNoMfBuAvI}GbJwI|@^[email protected][email protected]|BUbCoBjA{[email protected]@iBa [email protected]@?cCVkA|@[email protected]~ACnCwJtIiLpKeUbS{[email protected]@yG|FQzI?bDQ|[email protected]@jQaB| [email protected]@iAt`@[email protected]@^kA^[email protected]{[email protected]}A}@gBeA}AsA_CiCiByBqAiBgAqA}@[email protected]}@[email protected] @yBkDyEiH{FwJiEoHcHsHkB}CeBuCwIoNsE}GqDmFmFyHcEaF}[email protected]{FqGmEaGeEwFsJqM{[email protected]@{AyB iG}@yC_A}[email protected]}B}@[email protected]@oFgAoHmA}HkB}[email protected]@[email protected]@}[email protected]@[email protected]@{CwA[[email protected] [email protected]@sNaCuF_BmCqA{[email protected]{@[email protected]@[email protected]@[email protected][email protected][oBiAkBsH{[email protected]{D_SsC{[email protected]{ [email protected][[email protected]{@yDmC}NmC{[email protected]_AeGeAwF][email protected][email protected]@iFm [email protected]{AqJYgBaDgT{AcIaEwX_CkU|DqZ^[email protected][email protected][email protected]{GmFq [email protected]}[email protected]{[email protected]@eESwA_A}FwEuVwB}[email protected]@sF}[email protected]_BuI [email protected]@oBaLU{A}[email protected]_DcScEyW`ZaK|WcJ|[email protected]@_FeFi^wCg[kQzN",
35      "legs": [
36        {
37          "distance": 4777.4,
38          "duration": 561.1064897726275,
39          "summary": "Carretera del Hospitalet, Ronda de Dalt",
40          "steps": [
41            {
42              "distance": 547.3,
43              "duration": 64.28048349574225,
44              "geometry": "sjc{mA_hs}BtDcGlHkMrEgIpD}H~A}[email protected][email protected][email protected]@_JK{[email protected]{LHwGAkF[email protected]@V uYTcYNsJXqG|@wLdC}PhAmEbB_ExDaIzPmK"
45            },
46            {
47              "distance": 23.4,
48              "duration": 2.7483342112193836,
49              "geometry": "}fa{mAq|~}[email protected]@[email protected]^@[email protected]^[email protected]@"
50            },
51            {
52              "distance": 21,
53              "duration": 2.4664537792994468,
54              "geometry": "e{`{mAuz~}B|@[email protected]"
55            },
56            {
57              "distance": 872.7,
58              "duration": 102.49877205688702,
59              "geometry": "gx`{mA}[email protected]@[email protected]@{@[[email protected]@[email protected]{Hy`@[email protected]}D{LoEgNqJeZ}Ii\\cM} [email protected]@[email protected]@eF{[email protected]{@[email protected]{L"
60            },
61            {
62              "distance": 77,
63              "duration": 9.043663857431305,
64              "geometry": "ksg{mAckq~BhD}[email protected]"
65            },
66            {
67              "distance": 252.5,
68              "duration": 29.656170441576684,
69              "geometry": "ikf{mA{`r~B`[email protected]~ApAbBhB~ArBlA|[email protected]|EiBfDyHtGeEnD{ElCuDjAaF~ AwD`[email protected]{@[email protected]{@^"
70            },
71            {
72              "distance": 1817.2,
73              "duration": 213.4304670353788,
74              "geometry": "kng{mAcln~B}A\\[email protected][email protected]{@[email protected][email protected] @yHuAwJuBwFkAgHeBcJuB}[email protected]{G}AaASiB]}[email protected][email protected][email protected]@K iSmEeNsC_NgCiJgBkZcGqUcFsMkCaB]kAW{KwByA[[email protected]{JoD}QaHuEaCmNqHyOsIkM{IwGsF_WyRyH_Hg[}Wy JeJ_[kV}LkIaEaCwG{DiN}[email protected]}@][email protected][qUiGeMkCcAQ"
75            },
76            {
77              "distance": 364.5,
78              "duration": 42.810590597840395,
79              "geometry": "mue|[email protected]{A{[email protected]_LaEuKwD_JyC{LaFmLoF{KyFwHcEgIeEiFoCkGoEoYcTeB{AwEcF_BmB yAkBaAiCsAwDYsB"
80            },
81            {
82              "distance": 91.7,
83              "duration": 10.770181502940918,
84              "geometry": "qgk|mAcd}[email protected][email protected]"
85            },
86            {
87              "distance": 327.1,
88              "duration": 38.41795386708805,
89              "geometry": "_{l|mAe`}[email protected]@[email protected]@oYlDc|@\\[email protected]"
90            },
91            {
92              "distance": 211.7,
93              "duration": 24.864203098937757,
94              "geometry": "qil|[email protected]{F?eFzDu}ATgIHuINqH`@aM"
95            },
96            {
97              "distance": 171.3,
98              "duration": 20.11921582828549,
99              "geometry": "s_l|mA{qi_Cb`@e]tZkXdNoMfBuA"
100            },
101            {
102              "distance": 0,
103              "duration": 0,
104              "geometry": "kpi|mAszk_C"
105            }
106          ]
107        },
108        {
109          "distance": 4335.4,
110          "duration": 509.1935102273724,
111          "summary": "Avinguda Diagonal, Avenida Diagonal",
112          "steps": [
113            {
114              "distance": 47,
115              "duration": 5.520158458432095,
116              "geometry": "kpi|mAszk_CvI}GbJwI"
117            },
118            {
119              "distance": 44.2,
120              "duration": 5.191297954525503,
121              "geometry": "ozh|mAinl_C|@^[email protected][email protected]|BUbCoBjA{CRqD?gA"
122            },
123            {
124              "distance": 55.5,
125              "duration": 6.518484988148538,
126              "geometry": "}ih|mAi}[email protected]@[email protected]@?cCVkA|@[email protected]~ACnC"
127            },
128            {
129              "distance": 208.1,
130              "duration": 24.44138245105785,
131              "geometry": "i~h|mAmul_CwJtIiLpKeUbS{[email protected]@"
132            },
133            {
134              "distance": 233.4,
135              "duration": 27.412872004213853,
136              "geometry": "m~k|mAu|i_CyG|FQzI?bDQ|CIvFOvCUnIuEf_BUzFEtAOdH"
137            },
138            {
139              "distance": 247.5,
140              "duration": 29.06891954174348,
141              "geometry": "}ql|[email protected]@jQaB|[email protected]@iAt`@"
142            },
143            {
144              "distance": 367.3,
145              "duration": 43.13945110174699,
146              "geometry": "k~l|mAg|[email protected]@^kA^[email protected]{[email protected]}A}@gBeA}AsA_CiCiByBqAiBgAqA}@[email protected]} @[email protected]@yBkDyEiH{FwJiEoHcHsHkB}CeBuCwIoNsE}GqDmFmFyHcEaF}CoD"
147            },
148            {
149              "distance": 688,
150              "duration": 80.80572381704854,
151              "geometry": "syq|[email protected]{FqGmEaGeEwFsJqM{[email protected]@{AyBiG}@yC_A}[email protected]}B}@[email protected]@o FgAoHmA}HkB}[email protected]@[email protected]@}[email protected]@[email protected]@{CwA[[email protected]@[email protected]_BmCqA{[email protected] {@[email protected]@[email protected]@[email protected][email protected][oBiAkBsH{[email protected]{D_SsC{[email protected]{[email protected][[email protected]"
152            },
153            {
154              "distance": 274.2,
155              "duration": 32.20483934685278,
156              "geometry": "gvx|mAyro_C{@yDmC}NmC{[email protected]_AeGeAwF][email protected][email protected]"
157            },
158            {
159              "distance": 366.1,
160              "duration": 42.99851088578703,
161              "geometry": "emz|[email protected][email protected]{AqJYgBaDgT{AcIaEwX_CkU"
162            },
163            {
164              "distance": 805.1,
165              "duration": 94.55913989114212,
166              "geometry": "qm||mA{u}_C|DqZ^[email protected][email protected][email protected]{GmFqZoE_WmB [email protected]"
167            },
168            {
169              "distance": 291,
170              "duration": 34.17800237029233,
171              "geometry": "so`}mA{po`CuB}[email protected]{[email protected]@eESwA_A}FwEuVwB}[email protected]"
172            },
173            {
174              "distance": 407.6,
175              "duration": 47.8726933544026,
176              "geometry": "qcb}mAo_v`[email protected]}[email protected][email protected]@oBaLU{A}[email protected]_DcScEyW"
177            },
178            {
179              "distance": 169.3,
180              "duration": 19.88431546835221,
181              "geometry": "_md}mAq`_aC`ZaK|WcJ|[email protected]"
182            },
183            {
184              "distance": 92.2,
185              "duration": 10.828906592924238,
186              "geometry": "asa}mA}i`[email protected]_FeFi^wCg["
187            },
188            {
189              "distance": 39,
190              "duration": 4.580557018698973,
191              "geometry": "s`b}mAolbaCkQzN"
192            },
193            {
194              "distance": 0,
195              "duration": 0,
196              "geometry": "_sb}mAs|aaC"
197            }
198          ]
199        }
200      ],
201      "duration": 1070.3,
202      "distance": 9112.8
203    }
204  ]
205}

API Error Codes

Response CodeDescriptionAdditional Notes
200Normal success case.Normal success case.
400Input validation failed.Such as missing parameter or parameter with invalid value type (for example value cannot be parsed into number).
401APIKEY not supplied or invalid.-
403APIKEY 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.
404Requested host/path not found.This error occurs when there is a malformed host name used.
422Could not process the request.There is an underlying map issue which prevents the processing of the request.
429Too many requests.QPM reached or something like distance matrix size quota reached.
500Internal Service error.There was an internal issue with Nextbillion.ai services. You can reach out to [email protected] for an explanation.
Snap To Roads
Optimization MVRP
DIDN'T FIND WHAT YOU LOOKING FOR?