Directions API

Introduction

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

  1. Find the most optimal route and ETAs between the origin and the destination.

  2. Get directions for different driving modes like car & truck.

  3. You can also add waypoints, which are coordinates along the route.

  4. Plan your trips in advance by setting departure_time to get best routes and ETAs

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

Directions Fast API

Request URL: https://api.nextbillion.io/directions/json?{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...

Sample Queries-Directions Fast

GET Request Example 1

Let’s look at a simple directions request with

  1. an origin and destination pair for a trip being made by a car

  2. a request for a simplified route geometry in the response

  3. steps set to true to get turn-by-turn information for the complete route

Request

  https://api.nextbillion.io/directions/json?origin=34.14169142,-118.11283644&destination=34.00419854,-118.08278668&mode=car&key=<your_api_key>&overview=simplified&steps=true

Response

1{
2   "status": "Ok",
3   "mode": "car",
4   "routes": [
5       {
6           "geometry": "qhkoE~}{oUo~@CmBcqBx\\oiAcE}wAjBa{Evf@_}AdXg]vKue@`@kiGrCaWzH}G`c@bVhmAt{AbrBns@`{@ty@`iBl\\ps@v@zmBx{@na@~dAjn@j}@~pAtgCzq@jZ`^xk@bC}LoMvU}[byAjg@`K",
7           "distance": 37101.3,
8           "duration": 1465.0,
9           "weight": 1465.0,
10           "start_location": {
11               "latitude": 34.14169,
12               "longitude": -118.11312
13           },
14           "end_location": {
15               "latitude": 34.0042,
16               "longitude": -118.08291
17           },
18           "legs": [
19               {
20                   "distance": {
21                       "value": 37101
22                   },
23                   "duration": {
24                       "value": 1465
25                   },
26                   "start_location": {
27                       "latitude": 34.14169,
28                       "longitude": -118.11312
29                   },
30                   "end_location": {
31                       "latitude": 34.0042,
32                       "longitude": -118.08291
33                   },
34                   "steps": [
35                       {
36                           "geometry": "qhkoE~}{oUE?q@?u@?]@q@?q@?iA@aA?mA?M?w@@]?]?{B@i@?S?I?M?W?A?g@?Q?{@@]?O?eF@C?oB?iA?C?_@?U?W?I?Y?q@?o@AY?Q?M?sA@g@?o@?UImACmAA",
37                           "start_location": {
38                               "latitude": 34.14169,
39                               "longitude": -118.11312
40                           },
41                           "end_location": {
42                               "latitude": 34.15185,
43                               "longitude": -118.1131
44                           },
45                           "distance": {
46                               "value": 1131
47                           },
48                           "duration": {
49                               "value": 143
50                           },
51                           "maneuver": {
52                               "voice_instruction": [],
53                               "bearing_before": 0,
54                               "bearing_after": 0,
55                               "coordinate": {
56                                   "latitude": 34.141688,
57                                   "longitude": -118.113117
58                               },
59                               "maneuver_type": "depart",
60                               "modifier": "right"
61                           }
62                       },
63                       {
64                           "geometry": "ahmoEz}{oUCa@",
65                           "start_location": {
66                               "latitude": 34.15185,
67                               "longitude": -118.1131
68                           },
69                           "end_location": {
70                               "latitude": 34.15187,
71                               "longitude": -118.11293
72                           },
73                           "distance": {
74                               "value": 15
75                           },
76                           "duration": {
77                               "value": 1
78                           },
79                           "maneuver": {
80                               "voice_instruction": [],
81                               "bearing_before": 0,
82                               "bearing_after": 80,
83                               "coordinate": {
84                                   "latitude": 34.151849,
85                                   "longitude": -118.113098
86                               },
87                               "maneuver_type": "turn",
88                               "modifier": "right"
89                           }
90                       },
91                       {
92                           "geometry": "ehmoEx|{oUAEEUE[AUCe@SeIMgEAa@GoCAa@W_@",
93                           "start_location": {
94                               "latitude": 34.15187,
95                               "longitude": -118.11293
96                           },
97                           "end_location": {
98                               "latitude": 34.15232,
99                               "longitude": -118.1085
100                           },
101                           "distance": {
102                               "value": 414
103                           },
104                           "duration": {
105                               "value": 23
106                           },
107                           "maneuver": {
108                               "voice_instruction": [],
109                               "bearing_before": 80,
110                               "bearing_after": 73,
111                               "coordinate": {
112                                   "latitude": 34.15187,
113                                   "longitude": -118.112928
114                               },
115                               "maneuver_type": "turn",
116                               "modifier": "slight left"
117                           }
118                       },
119                       {
120                           "geometry": "_kmoEba{oUGiH?]?yA?Q?W?gD?uDAoC?QAeC?_C?qB?}@AiIA{A?]?q@?K?i@?[?[?c@?s@AcD?WAcF?qA@Y?iA@W@YBe@?[@SBSHcA@K",
121                           "start_location": {
122                               "latitude": 34.15232,
123                               "longitude": -118.1085
124                           },
125                           "end_location": {
126                               "latitude": 34.15228,
127                               "longitude": -118.09378
128                           },
129                           "distance": {
130                               "value": 1356
131                           },
132                           "duration": {
133                               "value": 42
134                           },
135                           "maneuver": {
136                               "voice_instruction": [],
137                               "bearing_before": 47,
138                               "bearing_after": 87,
139                               "coordinate": {
140                                   "latitude": 34.152318,
141                                   "longitude": -118.108503
142                               },
143                               "maneuver_type": "merge",
144                               "modifier": "slight left"
145                           },
146                       },
147                       {
148                           "geometry": "wjmoEbexoU?{A@KJy@N}@P}@R}@Pq@XiAXw@Rm@b@kAPa@h@gATa@Vc@R]`A{A^i@X_@Xa@Xa@`AuAr@eA`AcBf@gAFQDIN_@b@mADMLe@BEH]HYNs@DQRiAPgAJaAPyBB_@Be@@[@W?[?sA?[Ao@CeBCsCCoDEqCE}DE{ACaAI}BAUI_BEu@C_@O_CO}BYqDCUKqAKoBIgBGqAEqAEcACqAEkBA}@AsC?}@?eB?]A{A?oDAsE?oDAqE@uC?cA?uE?}CAiF?oEAqB?uBAaDCqBAaB?sAAqAAqD?uBJaA?iA?oB?uBAiC?a@?[?a@?k@As@?Q@UAi@?K",
149                           "start_location": {
150                               "latitude": 34.15228,
151                               "longitude": -118.09378
152                           },
153                           "end_location": {
154                               "latitude": 34.14867,
155                               "longitude": -118.04892
156                           },
157                           "distance": {
158                               "value": 4289
159                           },
160                           "duration": {
161                               "value": 132
162                           },
163                           "maneuver": {
164                               "voice_instruction": [],
165                               "bearing_before": 98,
166                               "bearing_after": 88,
167                               "coordinate": {
168                                   "latitude": 34.152279,
169                                   "longitude": -118.093781
170                               },
171                               "maneuver_type": "fork",
172                               "modifier": "slight left"
173                           },
174                       },
175                       {
176                           "geometry": "etloEvlooUMsA?S?_DAqD?_DAyA?uD?sE?gCFsED}BJeDN_EJ{CBg@Bq@B}@T_GDkAF_BRiFJaDBe@RqA@K?GF{@?KH{@JeALy@BSBOJm@TcALk@HWX_AXy@J]",
177                           "start_location": {
178                               "latitude": 34.14867,
179                               "longitude": -118.04892
180                           },
181                           "end_location": {
182                               "latitude": 34.14709,
183                               "longitude": -118.02982
184                           },
185                           "distance": {
186                               "value": 1781
187                           },
188                           "duration": {
189                               "value": 52
190                           },
191                           "maneuver": {
192                               "voice_instruction": [],
193                               "bearing_before": 88,
194                               "bearing_after": 77,
195                               "coordinate": {
196                                   "latitude": 34.148666,
197                                   "longitude": -118.048916
198                               },
199                               "maneuver_type": "fork",
200                               "modifier": "slight left"
201                           },
202                       },
203                       {
204                           "geometry": "ijloEjukoUVmAJ[bAiCJWlAeD`@gAd@oA\\aAJW`@eAhAyCDKHUxAyD`AgC|@eCv@qBb@kATm@z@_CRg@\\_Az@}BHWlA_D\\}@Vm@R_@NYXi@\\i@^g@V[^e@p@q@p@q@Z]TSpBqBfCcCn@u@r@_AZg@Ta@JQTc@FO`@}@\\aA\\gAT}@H_@jBoIlAwFnByIPkAJ{@Fw@Di@Bm@@Y@W@U?U?_@?o@?mA?U?aA@{AAgDBeF?sB?cC?W?W?_A?wE@qD?w@?yC?sB@wB?yC?i@A]?W?e@@[?mC?iE?{@?qBAaF?c@?aA?i@?a@?qGAgI?}B?W@sI@oHNuA@eCD{GBcG",
205                           "start_location": {
206                               "latitude": 34.14709,
207                               "longitude": -118.02982
208                           },
209                           "end_location": {
210                               "latitude": 34.13528,
211                               "longitude": -117.97925
212                           },
213                           "distance": {
214                               "value": 5051
215                           },
216                           "duration": {
217                               "value": 157
218                           },
219                           "maneuver": {
220                               "voice_instruction": [],
221                               "bearing_before": 116,
222                               "bearing_after": 108,
223                               "coordinate": {
224                                   "latitude": 34.147086,
225                                   "longitude": -118.029821
226                               },
227                               "maneuver_type": "fork",
228                               "modifier": "slight left"
229                           },
230                       },
231                       {
232                           "geometry": "o`joEhyaoU@mA?y@@cA?[@[?c@?Y@]?Y?g@?{AA{AAw@CiAEwBEiBO}H?a@A_B?u@?E?]AiB?{A?g@?kAAo@?a@?oA?g@?eAAmB?mA?k@?u@?g@?s@?OAq@?m@?iA?cA?u@?{B",
233                           "start_location": {
234                               "latitude": 34.13528,
235                               "longitude": -117.97925
236                           },
237                           "end_location": {
238                               "latitude": 34.13547,
239                               "longitude": -117.96479
240                           },
241                           "distance": {
242                               "value": 1332
243                           },
244                           "duration": {
245                               "value": 42
246                           },
247                           "maneuver": {
248                               "voice_instruction": [],
249                               "bearing_before": 90,
250                               "bearing_after": 91,
251                               "coordinate": {
252                                   "latitude": 34.135284,
253                                   "longitude": -117.979247
254                               },
255                               "maneuver_type": "fork",
256                               "modifier": "slight right"
257                           },
258                       },
259                       {
260                           "geometry": "uajoE|~~nUT_ABOBg@D_AFw@HeAHeAFw@Fu@JaALoAD[DUDWDOFSHWFQHSLWHQJOJOLQJMNOPSTQLKXQJETMPIPGPGHAREHCPAXCXAV?d@@D@N@NBJ@H@JBHBJDJBHBHDHDHDJDz@l@bBfApAj@",
261                           "start_location": {
262                               "latitude": 34.13547,
263                               "longitude": -117.96479
264                           },
265                           "end_location": {
266                               "latitude": 34.13049,
267                               "longitude": -117.96058
268                           },
269                           "distance": {
270                               "value": 912
271                           },
272                           "duration": {
273                               "value": 34
274                           },
275                           "maneuver": {
276                               "voice_instruction": [],
277                               "bearing_before": 88,
278                               "bearing_after": 111,
279                               "coordinate": {
280                                   "latitude": 34.135471,
281                                   "longitude": -117.964786
282                               },
283                               "maneuver_type": "off ramp",
284                               "modifier": "slight right"
285                           }
286                       },
287                       {
288                           "geometry": "qbioErd~nUVRXRJHRNz@l@~@p@nA|@HFj@d@f@^LJ^^bAt@l@h@pArAxCdDjBrBl@n@l@p@tAvAj@n@f@h@h@h@~@`AhAlAzB`C|AbBz@|@j@l@l@n@f@h@hBnBxA|AbBfBZ^Z`@\\`@`@f@TXRXV`@\\d@Zd@PXR\\V`@v@vAh@bAvC|FtAnCx@xA`@t@RZRZ`@j@r@~@Zb@PN^`@^^`@^`@\\d@^TPPLRLXR\\TTNn@\\RHZNl@Xl@VXLj@Tb@PnBx@RHvAl@t@ZfAd@l@Vx@\\\\L`@Pf@T`@Nj@TXLTJNFVJFBHBHDPFTJPHTL`@N\\N`@Pp@Vx@\\h@Tf@RVL\\Nl@VTHTHHDXLTHTJjAh@d@R\\NZJp@XRF\\LTFz@XzA\\JB`AV\\HlCl@hCn@lAXbEbA`@HpAZTFTFf@Lz@R~@RnBb@p@P\\HPD^Jx@Rt@Vp@Vp@Zn@Zn@^n@`@j@d@j@d@h@f@LLRRf@n@JJV^n@z@JPFLHJLTJLHNJNJRDDBFJNHLRX^n@Xb@T\\NTJLPXRXRXTZNRTZb@h@PTRVb@h@NTNPZ\\VVJLt@x@TRf@h@^\\VXn@h@f@d@dA|@h@b@x@n@rBzA`@VLHb@Xz@h@n@^RJt@`@r@^TL\\Pn@ZXLf@Tj@VZL^Nj@Td@RTH\\JbBh@p@Rn@RXFTH\\H^Jf@Jr@PD?h@L`APb@FXFZDPDv@JlAN\\DfBPnBL\\B\\Bf@Bd@BjAB|@Br@@d@@~ADT@L@Z@ZBz@Fz@H`AHlAPf@FNDb@HZF^Ft@PPDTFTDFB`@JxBh@bAV~A`@`ATrAZtFtAj@PpCl@p@Nd@H`@F~@FX@n@Dl@Bh@@t@@j@?r@?\\ARCJA`@Cr@K^Cd@G|@MNA^EXCZCr@Gj@Gd@GJ?^CTAF?XAZ?t@?d@@t@D|AHXBZDXB`@Fb@HXFTHb@Lf@NPD",
289                           "start_location": {
290                               "latitude": 34.13049,
291                               "longitude": -117.96058
292                           },
293                           "end_location": {
294                               "latitude": 34.06192,
295                               "longitude": -118.00073
296                           },
297                           "distance": {
298                               "value": 8803
299                           },
300                           "duration": {
301                               "value": 278
302                           },
303                           "maneuver": {
304                               "voice_instruction": [],
305                               "bearing_before": 203,
306                               "bearing_after": 212,
307                               "coordinate": {
308                                   "latitude": 34.130489,
309                                   "longitude": -117.960582
310                               },
311                               "maneuver_type": "merge",
312                               "modifier": "slight left"
313                           },
314                       },
315                       {
316                           "geometry": "_v{nEp_foU^DX@NBTDtA\\FBhBf@HB`AVd@Ln@Nb@NPDf@Pj@PdA^p@V`Ab@|@^`D|AlAj@~CxA~@`@JFJDFBf@Vf@Rz@^HDFBRLD@\\R`@RlB|@tBbAn@XxI`ErCrAdAd@tBbAdHbDPJJJ^XRJ`Ab@~Ar@@@~Ar@l@VbAf@j@Xv@`@",
317                           "start_location": {
318                               "latitude": 34.06192,
319                               "longitude": -118.00073
320                           },
321                           "end_location": {
322                               "latitude": 34.04494,
323                               "longitude": -118.00966
324                           },
325                           "distance": {
326                               "value": 2065
327                           },
328                           "duration": {
329                               "value": 62
330                           },
331                           "maneuver": {
332                               "voice_instruction": [],
333                               "bearing_before": 198,
334                               "bearing_after": 185,
335                               "coordinate": {
336                                   "latitude": 34.061924,
337                                   "longitude": -118.000733
338                               },
339                               "maneuver_type": "fork",
340                               "modifier": "slight left"
341                           },
342                       },
343                       {
344                           "geometry": "{kxnEjwgoU\\Jl@Vr@d@j@`@d@b@d@`@f@f@`@b@v@~@bApAj@z@Xd@r@rAR`@^v@Vn@Pd@f@vA^nAXbAZbAz@xCr@bCp@bCbAnDpAjEv@rC^nAPj@Nd@Pf@`@dAZr@Tf@Zl@^r@Zh@^l@^f@v@fAJPV^Z`@V`@NRDD@B`BzBV\\d@n@Zv@h@r@TZ?@Z`@LPNVTXRZZb@X`@LRV\\LNJNJNLRNVDHNTNTFJFH",
345                           "start_location": {
346                               "latitude": 34.04494,
347                               "longitude": -118.00966
348                           },
349                           "end_location": {
350                               "latitude": 34.03389,
351                               "longitude": -118.02754
352                           },
353                           "distance": {
354                               "value": 2089
355                           },
356                           "duration": {
357                               "value": 61
358                           },
359                           "maneuver": {
360                               "voice_instruction": [],
361                               "bearing_before": 206,
362                               "bearing_after": 196,
363                               "coordinate": {
364                                   "latitude": 34.044939,
365                                   "longitude": -118.009662
366                               },
367                               "maneuver_type": "fork",
368                               "modifier": "slight left"
369                           },
370                       },
371                       {
372                           "geometry": "yfvnEbgkoUdA~@TXfA|AxArBx@hAjA`Bp@|@`AtAX`@`@l@Zh@^l@`@p@P\\T`@l@lAn@vA`@z@`@|@Td@P`@dBxDbAzBbBpDh@jAHRXj@v@dBBHBFZp@t@~ArAtCv@~ATb@z@zAjAzBjBnDhHhNnElIjFxJtAjClBlDlAtBT`@jA|Bf@bA^jAxClFVd@JPLTl@`Al@|@p@z@HJ",
373                           "start_location": {
374                               "latitude": 34.03389,
375                               "longitude": -118.02754
376                           },
377                           "end_location": {
378                               "latitude": 34.01718,
379                               "longitude": -118.05396
380                           },
381                           "distance": {
382                               "value": 3071
383                           },
384                           "duration": {
385                               "value": 89
386                           },
387                           "maneuver": {
388                               "voice_instruction": [],
389                               "bearing_before": 229,
390                               "bearing_after": 216,
391                               "coordinate": {
392                                   "latitude": 34.033893,
393                                   "longitude": -118.02754
394                               },
395                               "maneuver_type": "fork",
396                               "modifier": "slight left"
397                           },
398                       },
399                       {
400                           "geometry": "k~rnEflpoU~@p@VX^^b@^PNn@h@PN\\VZRZRVPRJl@^z@`@XLTJ~@`@|@X|@VXHh@Lb@JTDt@LjAPbBTz@JTD~@Nx@RZHb@NXJ~@`@h@Xl@^h@\\JHpAhAb@d@j@p@jGjIl@t@b@h@hAxADFf@dAFH",
401                           "start_location": {
402                               "latitude": 34.01718,
403                               "longitude": -118.05396
404                           },
405                           "end_location": {
406                               "latitude": 34.00614,
407                               "longitude": -118.06182
408                           },
409                           "distance": {
410                               "value": 1462
411                           },
412                           "duration": {
413                               "value": 44
414                           },
415                           "maneuver": {
416                               "voice_instruction": [],
417                               "bearing_before": 225,
418                               "bearing_after": 212,
419                               "coordinate": {
420                                   "latitude": 34.017176,
421                                   "longitude": -118.053961
422                               },
423                               "maneuver_type": "fork",
424                               "modifier": "slight left"
425                           },
426                       },
427                       {
428                           "geometry": "kypnEj}qoUh@tA^j@^n@X`@PXd@l@`AnA\\b@HJBFDDBFDDBDDFDDDD`@d@",
429                           "start_location": {
430                               "latitude": 34.00614,
431                               "longitude": -118.06182
432                           },
433                           "end_location": {
434                               "latitude": 34.00429,
435                               "longitude": -118.06434
436                           },
437                           "distance": {
438                               "value": 312
439                           },
440                           "duration": {
441                               "value": 13
442                           },
443                           "maneuver": {
444                               "voice_instruction": [],
445                               "bearing_before": 227,
446                               "bearing_after": 239,
447                               "coordinate": {
448                                   "latitude": 34.006144,
449                                   "longitude": -118.061815
450                               },
451                               "maneuver_type": "off ramp",
452                               "modifier": "slight right"
453                           }
454                       },
455                       {
456                           "geometry": "ympnEbmroUDFJRLR@DFJDFBHBJ?F?HAFAFABCDCFEDGDIBG@G?I?GCIEEGEEEGCIEGEOEQEIAIAO?OBYD_@@I@M",
457                           "start_location": {
458                               "latitude": 34.00429,
459                               "longitude": -118.06434
460                           },
461                           "end_location": {
462                               "latitude": 34.0046,
463                               "longitude": -118.06408
464                           },
465                           "distance": {
466                               "value": 225
467                           },
468                           "duration": {
469                               "value": 19
470                           },
471                           "maneuver": {
472                               "voice_instruction": [],
473                               "bearing_before": 220,
474                               "bearing_after": 233,
475                               "coordinate": {
476                                   "latitude": 34.004286,
477                                   "longitude": -118.064342
478                               },
479                               "maneuver_type": "turn",
480                               "modifier": "slight right"
481                           }
482                       },
483                       {
484                           "geometry": "wopnEnkroUDKR]FILWDEBIJMFIDGPYDGFCHA@ALSb@m@",
485                           "start_location": {
486                               "latitude": 34.0046,
487                               "longitude": -118.06408
488                           },
489                           "end_location": {
490                               "latitude": 34.00371,
491                               "longitude": -118.06292
492                           },
493                           "distance": {
494                               "value": 147
495                           },
496                           "duration": {
497                               "value": 22
498                           },
499                           "maneuver": {
500                               "voice_instruction": [],
501                               "bearing_before": 98,
502                               "bearing_after": 126,
503                               "coordinate": {
504                                   "latitude": 34.004596,
505                                   "longitude": -118.064076
506                               },
507                               "maneuver_type": "turn",
508                               "modifier": "straight"
509                           }
510                       },
511                       {
512                           "geometry": "ejpnEfdroUGIEGi@z@EBABABCREFQXEFGHKLCHEDMVGHS\\EJMVyAfCS\\EHYd@GLQ\\ADUb@GJYr@Wt@Ut@Qr@a@lBCLMh@I\\GXK^GXS~@CJAFEPEROp@IXMr@AJQv@CJIb@YnAETI\\GZGTCLOJCHGTOj@Id@CHeBlHgAnFo@dDi@|BOr@@XCNENKHERIXOj@I^ERCPUpAc@nB_@`B_AzDQbAI^IZS`AI`@",
513                           "start_location": {
514                               "latitude": 34.00371,
515                               "longitude": -118.06292
516                           },
517                           "end_location": {
518                               "latitude": 34.0106,
519                               "longitude": -118.08082
520                           },
521                           "distance": {
522                               "value": 1853
523                           },
524                           "duration": {
525                               "value": 144
526                           },
527                           "maneuver": {
528                               "voice_instruction": [],
529                               "bearing_before": 130,
530                               "bearing_after": 46,
531                               "coordinate": {
532                                   "latitude": 34.003711,
533                                   "longitude": -118.062915
534                               },
535                               "maneuver_type": "continue",
536                               "modifier": "uturn"
537                           }
538                       },
539                       {
540                           "geometry": "guqnEbtuoUK^VDJBB@`@Hz@P\\H^HNDv@NZHLBF@JBz@RF@zAZp@NPDn@N`@H~@T~@Vf@Lj@NlA\\b@J",
541                           "start_location": {
542                               "latitude": 34.0106,
543                               "longitude": -118.08082
544                           },
545                           "end_location": {
546                               "latitude": 34.00583,
547                               "longitude": -118.08257
548                           },
549                           "distance": {
550                               "value": 572
551                           },
552                           "duration": {
553                               "value": 62
554                           },
555                           "maneuver": {
556                               "voice_instruction": [],
557                               "bearing_before": 289,
558                               "bearing_after": 291,
559                               "coordinate": {
560                                   "latitude": 34.010602,
561                                   "longitude": -118.080815
562                               },
563                               "maneuver_type": "turn",
564                               "modifier": "left"
565                           },
566                       },
567                       {
568                           "geometry": "mwpnE`_voU?K@MB[",
569                           "start_location": {
570                               "latitude": 34.00583,
571                               "longitude": -118.08257
572                           },
573                           "end_location": {
574                               "latitude": 34.0058,
575                               "longitude": -118.0823
576                           },
577                           "distance": {
578                               "value": 25
579                           },
580                           "duration": {
581                               "value": 10
582                           },
583                           "maneuver": {
584                               "voice_instruction": [],
585                               "bearing_before": 196,
586                               "bearing_after": 94,
587                               "coordinate": {
588                                   "latitude": 34.005833,
589                                   "longitude": -118.082573
590                               },
591                               "maneuver_type": "turn",
592                               "modifier": "left"
593                           }
594                       },
595                       {
596                           "geometry": "gwpnEj}uoUj@ZVJr@R|Ct@ZFL?",
597                           "start_location": {
598                               "latitude": 34.0058,
599                               "longitude": -118.0823
600                           },
601                           "end_location": {
602                               "latitude": 34.0042,
603                               "longitude": -118.08291
604                           },
605                           "distance": {
606                               "value": 188
607                           },
608                           "duration": {
609                               "value": 24
610                           },
611                           "maneuver": {
612                               "voice_instruction": [],
613                               "bearing_before": 98,
614                               "bearing_after": 206,
615                               "coordinate": {
616                                   "latitude": 34.005803,
617                                   "longitude": -118.082297
618                               },
619                               "maneuver_type": "turn",
620                               "modifier": "right"
621                           }
622                       },
623                       {
624                           "geometry": "gmpnEdavoU",
625                           "start_location": {
626                               "latitude": 34.0042,
627                               "longitude": -118.08291
628                           },
629                           "end_location": {
630                               "latitude": 34.0042,
631                               "longitude": -118.08291
632                           },
633                           "distance": {
634                               "value": 0
635                           },
636                           "duration": {
637                               "value": 0
638                           },
639                           "maneuver": {
640                               "voice_instruction": [],
641                               "bearing_before": 180,
642                               "bearing_after": 0,
643                               "coordinate": {
644                                   "latitude": 34.004199,
645                                   "longitude": -118.082912
646                               },
647                               "maneuver_type": "arrive",
648                               "modifier": "left"
649                           }
650                       }
651                   ]
652               }
653           ]
654       }
655   ]
656}

Here is a visual representation of the above response

GET Request Example 2

Taking the next step to use further features offered in Directions API. For the same origin and destination, let’s request:

  1. full route geometry instead of simplified

  2. a waypoints to be added in the request along with approaches information

  3. to avoid highways in the returned route

  4. to remove steps information from the response

Request

https://api.nextbillion.io/directions/json?origin=34.14169142,-118.11283644&destination=34.00419854,-118.08278668&approaches=unrestricted;curb&avoid=highway&mode=car&key=<your_api_key>&waypoints=34.09442207,-117.92489791&overview=full

Response

1{
2   "status": "Ok",
3   "mode": "car",
4   "routes": [
5       {
6           "geometry": "qhkoE~}{oUP?HAv@?bBAdEAvD?nB?~A?AaB?uC?oE?sB@a@?kA@oF?iG?qE?gG?mB?qA@sDAoA?[?yA?s@|@@j@?t@@\\?tAA`@AlA??W?S?{@?Y?uB?_A?w@?U?c@?Q?m@@U?g@?[?WBe@?ODeABi@D[@YFaB?yB?YCoF?i@?_@A_A?M?K?u@Ai@?gA?gB?gBAkB?sC?o@?w@Ao@?w@?sCA_F?u@?Y?SAS?MCQAUCUAMCSAOAS?Y?WAu@?a@CmD?[@M@S@SDU@Q@K@EBY?Q?O?Q?k@Ci@@kC?wA?s@AoE?]?gB?}A?]?I@mH@e@@c@?Q?[@O@U@WBW@M@O@I@MBMBK@OBKBMBMLg@La@Pg@Xq@N_@JWHSHQHWFWFUH_@He@DWD[@KFu@@g@?O?Y?Q?w@?Y@c@AuA?c@AU?U?Y?aBAgBFM?c@@y@BcA@s@@q@Dc@@S?U@[?M?yAFo@Fe@?IDYB_@Fe@G[D]@G@GBGRi@DK@EFSRk@L]FQFOBGBEBC@CDGDKLQ@CPSPSLMHI@AFEBCDCVQHGNGXM^MHCTGLCD?ZETAXCPA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XNFLDr@PZHVHx@PfB\\vA^NB^JD?nBb@\\JrAXp@Nh@Jb@Hz@Pb@Jj@N~AZbATfATH@XFh@JD@b@JVDJBB@`@Hz@P\\H^HNDv@NZHLBF@JBz@RF@zAZp@NPDn@N`@H~@T~@Vf@Lj@NlA\\b@J?K@MB[Hw@VyBlAXpAVVHB@|Cl@e@pDEFIDE?",
7           "distance": 46029.2,
8           "duration": 3355.7,
9           "weight": 3355.7,
10           "legs": [
11               {
12                   "distance": {
13                       "value": 22399
14                   },
15                   "duration": {
16                       "value": 1746
17                   },
18                   "steps": []
19               },
20               {
21                   "distance": {
22                       "value": 23629
23                   },
24                   "duration": {
25                       "value": 1609
26                   },
27                   "steps": []
28               }
29           ]
30       }
31   ]
32}

And here is a visual representation of the above response. We can see a different route is suggested when a waypoint is added and the API is requested to avoid highway.

POST request Example

Let’s look at a Directions Fast POST method request with values for different parameters to configure a request

1curl --location --request POST ‘https://api.nextbillion.io/directions/json?key=<your_api_key>2--header 'Content-Type: application/json'
3--data '{
4   "origin": "34.14169142,-118.11283644",
5   "destination": "34.00419854,-118.08278668",
6   "mode": "car",
7   "overview": "simplified",
8   "geometry": "polyline6",
9   "avoid": "highway",
10   "alternative": true,
11   "altcount":2,
12   "waypoints": "34.09410170,-117.93187758|34.04547240,-117.96517223",
13   "approaches": "unrestricted;;curb",
14   "steps": true
15}'

Directions Flexible API

Request URL: https://api.nextbillion.io/directions/json?option=flexible&{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...

Sample Queries-Directions Flexible

GET Request Example 1

Using the same origin and destination pair from the example from Directions Fast, let's see how different routes are suggested by Directions Flexible for different configurations of parameters. Let’s start by creating a simple flexible request for

  1. a trip being made by a truck

  2. a specific departure_time

Request
https://api.nextbillion.io/directions/json?origin=34.14169142,-118.11283644&destination=34.00419854,-118.08278668&mode=truck&departrure_time=1683105152&option=flexible&key=<your_api_key>

Response

1{
2   "status": "Ok",
3   "mode": "truck",
4   "routes": [
5       {
6           "geometry": "qhkoE~}{oUE?q@?u@?]@q@?q@?iA@aA?mA?M?u@@_@?]?{B@i@?S?I?M?W?A?g@?Q?{@@]?O?eF@C?mB?kA?C?_@?U?W?I?Y?q@?o@AY?Q?M?sA@g@?o@?UImACmAACa@AEEUE[AUCg@ScIMgEAa@GoCAa@W_@GiH?]?yA?Q?W?iD?sDAoC?QAeC?_C?qB?}@AiIA{A?]?q@?K?i@?[?[?c@?s@AcD?WAeF?oA@Y?iA@W@YBe@?[@SBSHcA@KBSB]D]Fc@D]Ly@Ha@Hg@Jg@Li@H]H]HYLa@La@Z{@Zy@HQPa@Xi@Xe@bBsCZa@^k@Zc@b@k@n@_AZe@`@k@Zi@Xi@Xk@b@}@HSJUPe@Tq@Ri@FSDMPo@Ji@H]N}@Jq@NeAH_ADk@@MHw@@]@a@@aB?a@?U?_@?m@E}CEmECqCCoCAY?WWgJAWGiAAYCi@e@mGG{@C]MyAAUKmAEq@SsDKsCCk@EyA?EEeCA_AAqA?i@AkA?W?kA?[?U?U?}@AgDA}H?aG?mA?kS?yC?SAcGA{CAsAAoEC_F?c@Ac@?M?O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RFP?BDNJp@N`A@LD^BX@R@^@L?P@Z?l@Ct@K~AQtBO`BCXC^ALE`@E`@ATANATCr@?r@?r@Br@@JF`ABTZhBLn@H`@HXJXRl@@@Ph@NXDHDHHN\\d@\\f@Z^NRRTRPPPPN@@TN`@XHDVNXNJFLFJBLFp@P~@XZJRCv@^f@Xh@ZZRnAv@b@X~@l@d@X\\R\\RRLRLPJTHRHRJ\\LF?D@H?Z@R@J@L@VDTF\\JHBXHb@J~Dt@CRCj@Cf@Cp@Cj@Cn@C~@?LG`HMxKAv@?FATAdAAJ?JAJAPE\\E^CTEXUfBEXGZGNGNWb@ORx@tAFLhAbCABITMf@CTM~@WxBIv@j@ZVJr@R|Ct@ZFL?",
7           "distance": 35973.574,
8           "duration": 1690.291,
9           "start_location": {
10               "latitude": 34.14169,
11               "longitude": -118.11312
12           },
13           "end_location": {
14               "latitude": 34.0042,
15               "longitude": -118.08291
16           },
17           "legs": [
18               {
19                   "distance": {
20                       "value": 35973
21                   },
22                   "duration": {
23                       "value": 1690
24                   },
25                   "start_location": {
26                       "latitude": 34.14169,
27                       "longitude": -118.11312
28                   },
29                   "end_location": {
30                       "latitude": 34.0042,
31                       "longitude": -118.08291
32                   },
33                   "steps": [
34                       {
35                           "geometry": "qhkoE~}{oUE?q@?u@?]@q@?q@?iA@aA?mA?M?u@@_@?]?{B@i@?S?I?M?W?A?g@?Q?{@@]?O?eF@C?mB?kA?C?_@?U?W?I?Y?q@?o@AY?Q?M?sA@g@?o@?UImACmAA",
36                           "start_location": {
37                               "latitude": 34.14169,
38                               "longitude": -118.11312
39                           },
40                           "end_location": {
41                               "latitude": 34.15185,
42                               "longitude": -118.1131
43                           },
44                           "distance": {
45                               "value": 1129
46                           },
47                           "duration": {
48                               "value": 163
49                           }
50                       },
51                       {
52                           "geometry": "ahmoEz}{oUCa@",
53                           "start_location": {
54                               "latitude": 34.15185,
55                               "longitude": -118.1131
56                           },
57                           "end_location": {
58                               "latitude": 34.15187,
59                               "longitude": -118.11293
60                           },
61                           "distance": {
62                               "value": 16
63                           },
64                           "duration": {
65                               "value": 15
66                           }
67                       },
68                       {
69                           "geometry": "ehmoEx|{oUAEEUE[AUCg@ScIMgEAa@GoCAa@W_@GiH?]?yA?Q?W?iD?sDAoC?QAeC?_C?qB?}@AiIA{A?]?q@?K?i@?[?[?c@?s@AcD?WAeF?oA@Y?iA@W@YBe@?[@SBSHcA@K",
70                           "start_location": {
71                               "latitude": 34.15187,
72                               "longitude": -118.11293
73                           },
74                           "end_location": {
75                               "latitude": 34.15228,
76                               "longitude": -118.09378
77                           },
78                           "distance": {
79                               "value": 1771
80                           },
81                           "duration": {
82                               "value": 71
83                           }
84                       },
85                       {
86                           "geometry": "wjmoEbexoUBSB]D]Fc@D]Ly@Ha@Hg@Jg@Li@H]H]HYLa@La@Z{@Zy@HQPa@Xi@Xe@bBsCZa@^k@Zc@b@k@n@_AZe@`@k@Zi@Xi@Xk@b@}@HSJUPe@Tq@Ri@FSDMPo@Ji@H]N}@Jq@NeAH_ADk@@MHw@@]@a@@aB?a@?U?_@?m@E}CEmECqCCoCAY?WWgJAWGiAAYCi@e@mGG{@C]MyAAUKmAEq@SsDKsCCk@EyA?EEeCA_AAqA?i@AkA?W?kA?[?U?U?}@AgDA}H?aG?mA?kS?yC?SAcGA{CAsAAoEC_F?c@Ac@?M?O?]?kBA_B?I?iA?oB?uBAiC?a@?[?a@?k@As@?Q@UAi@?K",
87                           "start_location": {
88                               "latitude": 34.15228,
89                               "longitude": -118.09378
90                           },
91                           "end_location": {
92                               "latitude": 34.14867,
93                               "longitude": -118.04892
94                           },
95                           "distance": {
96                               "value": 4294
97                           },
98                           "duration": {
99                               "value": 176
100                           }
101                       },
102                       {
103                           "geometry": "etloEvlooU?c@?o@?i@?_@?[AQ?A?S?s@?i@?wAAiC?aA?E?}@?[?M?O?EA[?c@?e@?_@?e@?e@?m@?W?c@Ai@@]?a@?q@@g@@g@?m@@k@@k@@k@@]?W@W@g@DqA@_@@OBs@Bk@@c@Ba@@a@Be@Bo@DiADkABq@@U@W@Y@[Be@Bc@@e@@W@[Bm@Bc@Bq@DiABm@DeADgAHmCFwADiA@K?GF{@?KH{@JeALy@BSBOJm@TcALk@HWX_AX{@J[",
104                           "start_location": {
105                               "latitude": 34.14867,
106                               "longitude": -118.04892
107                           },
108                           "end_location": {
109                               "latitude": 34.14709,
110                               "longitude": -118.02982
111                           },
112                           "distance": {
113                               "value": 1781
114                           },
115                           "duration": {
116                               "value": 68
117                           }
118                       },
119                       {
120                           "geometry": "ijloEjukoUbCkGp@mB\\_AZy@\\}@Zw@FSf@qATk@Ri@To@JYFSTm@z@{BHSb@iAJ[Vo@`@eAXw@^aAVs@^}@La@Tm@v@qBJ[Tm@Tk@@G\\y@BGDM|@eCTm@Vq@^aA\\u@Zk@NY^i@b@o@j@q@z@}@TUNMZ[Z[PSj@g@JMRQj@k@z@w@z@}@h@m@BCd@m@^i@Zi@JSHON[JSDKDILYFOJWL]J[Nc@DSDI@KDQDOBKBKH_@H_@Ji@FYDOBQDQDQFSDS@IJe@Ry@FYFWH]Jg@H]H[Je@Jc@DQJa@Je@DUDSBEFWDWJg@Ja@Jg@DSF[FYD]DW@KBMBYBYDa@Ba@@[B]@[?O@U?U@UAaA@eA?Y?wC?U@}D?k@?s@?w@?eA?mB?_C?W?[?cC?m@?oA?o@?c@?i@?k@?gA?qA?a@?m@?s@?gA?c@Ac@@eA?_A?gA?e@?W@Y?Q?k@?eB?}E?{@?m@Aa@?{EAw@@Q?c@?s@Ac@@m@?s@?k@?i@?m@?}@?g@?mB?kA?oC?m@?e@?W?q@?{AAgA?{@?_@@aB?a@?oA@cB?k@@cA@eCD{GBcG",
121                           "start_location": {
122                               "latitude": 34.14709,
123                               "longitude": -118.02982
124                           },
125                           "end_location": {
126                               "latitude": 34.13528,
127                               "longitude": -117.97925
128                           },
129                           "distance": {
130                               "value": 5064
131                           },
132                           "duration": {
133                               "value": 203
134                           }
135                       },
136                       {
137                           "geometry": "o`joEhyaoU@mA?{@@aA?[@[?c@?Y@]?[?e@?{AA{AAw@CiAEwBEiBO}H?a@A_B?u@?E?_@?gBA{A?g@?kAAo@?a@?oA?g@?eAAmB?mA?k@?u@?g@?s@?OAq@?m@?iA?cA?u@?{B",
138                           "start_location": {
139                               "latitude": 34.13528,
140                               "longitude": -117.97925
141                           },
142                           "end_location": {
143                               "latitude": 34.13547,
144                               "longitude": -117.96479
145                           },
146                           "distance": {
147                               "value": 1332
148                           },
149                           "duration": {
150                               "value": 50
151                           }
152                       },
153                       {
154                           "geometry": "uajoE|~~nUT_ABOBg@F_ADw@HeAHeAFw@Fu@JcALmAD[DUDWDOFUHUFQHSLWHQJOJOLQJMNOPSTQLKXQJETMPIPGPGHAREHCPAXCXAV?d@@D@N@NBJ@H@JBHBJDJBHBHDHDHDJDz@l@bBfApAj@VRXRJHRNz@l@~@p@nA|@HFj@d@f@^LJ^^bAt@l@h@pArAxCdDjBrBl@n@l@p@tAvAj@n@f@h@h@h@~@`AhAlAzB`C|AbBz@|@j@l@l@n@f@h@hBnBxA|AbBfBZ^Z`@\\`@`@f@TXRXV`@\\d@Zd@PXT\\T`@v@vAh@bAvC|FtAnCx@xA`@t@RZRZ`@j@r@~@Zb@PN^`@^^`@^`@\\d@^TPPLRLXR\\TTNn@\\RHZNl@Xl@VXLj@Tb@PnBx@RHvAl@t@ZfAd@l@Vx@\\\\L`@Pf@T`@Nj@TXLTJNFVJFBHBHDPFTJPHTL`@N\\N`@Pp@Vx@\\h@Tf@RVL^Nj@VTHTHHDZLRHTJlAh@b@R\\NZJp@XRF\\LTF|@XxA\\JB`AV\\HlCl@hCn@lAXbEbA`@HpAZTFTFf@Lz@R~@RnBb@p@P\\HRD\\Jx@Rt@Vp@Vp@Zn@Zn@^n@`@j@d@l@d@f@d@LNRRf@n@JJV^n@z@JPFLHJLTJLHNJNJRDDDFHNHLRX^n@Xb@T\\NTJLPXRXRXTZNRTZb@h@PTRVb@h@NTNPZ\\VVJLt@x@TRf@h@^\\VXn@h@f@d@dA|@h@b@x@n@tBzA^VLHb@Xz@h@n@^RJt@`@r@^TL\\Pn@ZXLf@Tj@VZL^Nj@Td@RTH\\JbBh@p@Rn@RXFVHZH^Jf@Jr@PD?h@L`APb@FXFZDPDv@JlAN\\DfBPnBL\\B\\Bf@Bd@BjAB|@Br@@d@@~ADT@L@Z@ZBz@Fz@H`AHlAPf@FNDb@HZF^Ft@PPDTFTDFB`@JxBh@bAV~A`@`ATrAZtFtAj@PpCl@p@Nd@H`@F~@FZ@l@Dl@Bh@@t@@j@?r@?\\ARCJA`@Cr@K^Cd@G|@MNA^EXCZCr@Gj@Gd@GJ?^CTAF?XAZ?t@?d@@t@D|AHXBZDXB`@Fb@HXFTHb@Lf@NPD",
155                           "start_location": {
156                               "latitude": 34.13547,
157                               "longitude": -117.96479
158                           },
159                           "end_location": {
160                               "latitude": 34.06192,
161                               "longitude": -118.00073
162                           },
163                           "distance": {
164                               "value": 9718
165                           },
166                           "duration": {
167                               "value": 317
168                           }
169                       },
170                       {
171                           "geometry": "_v{nEp_foUp@RXHRD|A`@dBb@LDp@Rp@Pn@Nb@NlA\\j@Rl@Tf@PPJNFl@Vf@Tt@\\~@b@f@THDNHd@Rh@VtB`A|@b@TJNHHDJDPHTJj@X`A`@NHTJXNj@VbAd@rAn@zAr@~@b@bAd@z@^v@`@pAj@v@^TLPHj@VVJz@`@^Pf@VHDXL`@PHDp@Zb@Rd@Vp@XJDxAr@VJLF^PXLRJ`Ab@~Ar@@@~Ar@l@VbAf@j@Xv@`@",
172                           "start_location": {
173                               "latitude": 34.06192,
174                               "longitude": -118.00073
175                           },
176                           "end_location": {
177                               "latitude": 34.04494,
178                               "longitude": -118.00966
179                           },
180                           "distance": {
181                               "value": 2064
182                           },
183                           "duration": {
184                               "value": 69
185                           }
186                       },
187                       {
188                           "geometry": "{kxnEjwgoUb@V^TXRPLXR\\X\\X\\XXX\\ZXZTVVXPTVZZb@RXT^T\\T^Vd@Vd@Rd@Xl@Vn@Pb@\\|@J\\V|@ZbAPn@Ld@@DHTVx@Nf@f@bBh@rBt@bCf@hB`@vA^nARt@`@pANd@DNFVHVHVL`@J\\HXJXJZJVJVHTJVJVLXP\\LVNXNXLTPX\\f@j@x@PVLPLRNRNRb@l@LPRXFHJL^j@PTV\\TZb@j@JNV\\TZh@r@TZ?@Z`@LPNVTXRZZb@X`@LRV\\LNJNJNLRNVDHNTNTFJFH",
189                           "start_location": {
190                               "latitude": 34.04494,
191                               "longitude": -118.00966
192                           },
193                           "end_location": {
194                               "latitude": 34.03389,
195                               "longitude": -118.02754
196                           },
197                           "distance": {
198                               "value": 2090
199                           },
200                           "duration": {
201                               "value": 70
202                           }
203                       },
204                       {
205                           "geometry": "yfvnEbgkoUt@`A\\f@Xb@Zb@TXJN`@f@LPNTX^Z`@X`@`@j@\\b@T\\X^X`@FHNVZ`@Zf@RZBDxA`CDHHPd@z@fAzBt@dBP\\P`@P^DJhA`C\\v@JTd@dALXXl@^v@v@fBl@rARb@`@~@LVFPd@|@^z@n@tAFNp@tAx@bBR\\bCzEr@pAJRJRLVNXR\\NZP\\T`@^r@JTPZNXR`@R\\NXLTLVNVLVLTHNJRjAxBp@nAtAfCVf@h@bAb@t@P^bAnBvB~Dh@~@b@z@d@z@Vb@Zj@NX`@t@HLbAlB",
206                           "start_location": {
207                               "latitude": 34.03389,
208                               "longitude": -118.02754
209                           },
210                           "end_location": {
211                               "latitude": 34.01937,
212                               "longitude": -118.05071
213                           },
214                           "distance": {
215                               "value": 2683
216                           },
217                           "duration": {
218                               "value": 90
219                           }
220                       },
221                       {
222                           "geometry": "alsnE|wooUBb@DLpAxCPd@J\\FZBX@X?`@Ax@?d@?F?LBPDLFNJPFHDFBJHHDFJNLL",
223                           "start_location": {
224                               "latitude": 34.01937,
225                               "longitude": -118.05071
226                           },
227                           "end_location": {
228                               "latitude": 34.01825,
229                               "longitude": -118.05395
230                           },
231                           "distance": {
232                               "value": 337
233                           },
234                           "duration": {
235                               "value": 25
236                           }
237                       },
238                       {
239                           "geometry": "aesnEdlpoULPr@|@NLPNBBXNTLB@@@PAdAb@|@^b@RTLLHh@\\f@^^ZFRFLLNl@t@T`@JLb@p@|A`CX`@FHf@|@JNJTNXHTHPBLDNL\\J\\DRFP?BDNJp@N`A@LD^BX@R@^@L?P@Z?l@Ct@K~AQtBO`BCXC^ALE`@E`@ATANATCr@?r@?r@Br@@JF`ABTZhBLn@H`@HXJXRl@@@Ph@NXDHDHHN\\d@\\f@Z^NRRTRPPPPN@@TN`@XHDVNXNJFLFJBLFp@P~@XZJRCv@^f@Xh@ZZRnAv@b@X~@l@d@X\\R\\RRLRLPJTHRHRJ\\LF?D@H?Z@R@J@L@VDTF\\JHBXHb@J~Dt@",
240                           "start_location": {
241                               "latitude": 34.01825,
242                               "longitude": -118.05395
243                           },
244                           "end_location": {
245                               "latitude": 34.00523,
246                               "longitude": -118.07154
247                           },
248                           "distance": {
249                               "value": 2463
250                           },
251                           "duration": {
252                               "value": 196
253                           }
254                       },
255                       {
256                           "geometry": "uspnEbzsoUCRCj@Cf@Cp@Cj@Cn@C~@?LG`HMxKAv@?FATAdAAJ?JAJAPE\\E^CTEXUfBEXGZGNGNWb@OR",
257                           "start_location": {
258                               "latitude": 34.00523,
259                               "longitude": -118.07154
260                           },
261                           "end_location": {
262                               "latitude": 34.00611,
263                               "longitude": -118.07949
264                           },
265                           "distance": {
266                               "value": 750
267                           },
268                           "duration": {
269                               "value": 89
270                           }
271                       },
272                       {
273                           "geometry": "eypnExkuoUx@tAFLhAbC",
274                           "start_location": {
275                               "latitude": 34.00611,
276                               "longitude": -118.07949
277                           },
278                           "end_location": {
279                               "latitude": 34.00541,
280                               "longitude": -118.08065
281                           },
282                           "distance": {
283                               "value": 133
284                           },
285                           "duration": {
286                               "value": 19
287                           }
288                       },
289                       {
290                           "geometry": "ytpnE`suoUABITMf@CTM~@WxBIv@",
291                           "start_location": {
292                               "latitude": 34.00541,
293                               "longitude": -118.08065
294                           },
295                           "end_location": {
296                               "latitude": 34.0058,
297                               "longitude": -118.0823
298                           },
299                           "distance": {
300                               "value": 158
301                           },
302                           "duration": {
303                               "value": 36
304                           }
305                       },
306                       {
307                           "geometry": "gwpnEj}uoUj@ZVJr@R|Ct@ZFL?",
308                           "start_location": {
309                               "latitude": 34.0058,
310                               "longitude": -118.0823
311                           },
312                           "end_location": {
313                               "latitude": 34.0042,
314                               "longitude": -118.08291
315                           },
316                           "distance": {
317                               "value": 188
318                           },
319                           "duration": {
320                               "value": 27
321                           }
322                       },
323                       {
324                           "geometry": "gmpnEdavoU??",
325                           "start_location": {
326                               "latitude": 34.0042,
327                               "longitude": -118.08291
328                           },
329                           "end_location": {
330                               "latitude": 34.0042,
331                               "longitude": -118.08291
332                           },
333                           "distance": {
334                               "value": 0
335                           },
336                           "duration": {
337                               "value": 0
338                           }
339                       }
340                   ]
341               }
342           ]
343       }
344   ]
345}

Here is a visual representation of the above response

GET Request Example 2

In the next next step let’s request the route between same origin and destination but for

  1. different departure_time

  2. different truck parameters

  3. shortest route type

  4. avoiding highway

Request

https://api.nextbillion.io/directions/json?origin=34.14169142,-118.11283644&destination=34.00419854,-118.08278668&mode=truck&avoid=highway&departrure_time=1683220363&option=flexible&route_type=shortest&truck_size=220,200,400&key=<your_api_key>

Response

1{
2   "status": "Ok",
3   "mode": "truck",
4   "routes": [
5       {
6           "geometry": "qhkoE~}{oUP?HAv@?bBAdEAvD?nB?~A?AwF?oEZ?REZOLKLA\\Al@@N?dE@?cD?{@?{A?[?OAeA?{@?U?_A?}C?kHAiE?i@?aC@_C?wC?e@?cA?W?S?{@?Y?uB?_A?w@?U?c@?Q@m@?U?g@?[?WBe@?ODeABi@D[@YFaB?yB?YCoF?i@?_@A_A?Mp@GPCNAb@E|@IF?r@KhAOXGlAUz@SxBe@j@Ol@Ov@SZKd@OB?^Md@MVKNG`@MlCcATIlBu@\\OXKv@YHEh@SPGHEb@Q\\If@QHEP?`@MNGRGNEHCNEx@SZGXGTGf@MNE\\I`@KJCDCHKZGHAvC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T?R?\\?`A?x@Ax@?lBC^?r@?T?f@?dA?dA?x@?P?bCAv@?@?~@AL@D?N?d@@H@JBHWTw@La@FUDKLc@Pk@`@qAFODKd@}ADMZeAHURo@FORs@Pk@`@mABIH[ZaA\\eATs@r@{BDMLa@DQ`@kAPm@FO`AcDHUJ[DKPa@Zq@P]JQRYPST[Za@DCHKJKPOLM^YHGROJIBA^ULIJGPMPM`@WRMVQJGj@_@TMDEJEx@k@h@]ZUZSZUJIfAu@VQhA{@BCdAq@^Yf@_@PMPOFEDEv@u@NShBoBNO\\a@d@k@l@q@|@}@d@i@~@gAjA_Bb@o@BSVYNSrAwAtAqAPEHGNMBC`@a@RUTWJMb@k@HKLQRYTa@T]NWN[R_@P_@Vk@Xm@FQDIFOHUt@_CFOTu@J_@J_@FQPo@Lc@J_@Ni@VcAt@`@j@Zn@ZNFd@TfB~@|Av@^R^PZNbAf@dAh@`@RRJfAl@lCvAtAt@x@b@PJTNVPPJBBXRRPHHNNHHRTNNZ`@RTNPNRT^HLHLLVR`@LZjAbCzB~Eb@`ANZBHt@`Bt@~Af@x@JRj@z@V\\JLt@x@PPTT\\Vt@j@JFTN\\T^Pl@Xt@XNFLDr@PZHVFx@RfB\\vA\\ND^JD?nBb@\\JrAXp@Nh@Jb@Hz@Pb@Jj@N~AZbATfATH@XFh@JD@b@JVDJBB@`@Hz@P\\H^HNDv@NZHLBF@JBz@RF@zAZp@NPDn@N`@H~@T~@Vf@Lj@NlA\\b@J?K@MB[j@ZVJr@R|Ct@ZFL?",
7           "distance": 18572.605,
8           "duration": 1765.061,
9           "start_location": {
10               "latitude": 34.14169,
11               "longitude": -118.11312
12           },
13           "end_location": {
14               "latitude": 34.0042,
15               "longitude": -118.08291
16           },
17           "legs": [
18               {
19                   "distance": {
20                       "value": 18572
21                   },
22                   "duration": {
23                       "value": 1765
24                   },
25                   "start_location": {
26                       "latitude": 34.14169,
27                       "longitude": -118.11312
28                   },
29                   "end_location": {
30                       "latitude": 34.0042,
31                       "longitude": -118.08291
32                   },
33                   "steps": [
34                       {
35                           "geometry": "qhkoE~}{oUP?HAv@?bBAdEAvD?nB?~A?",
36                           "start_location": {
37                               "latitude": 34.14169,
38                               "longitude": -118.11312
39                           },
40                           "end_location": {
41                               "latitude": 34.13782,
42                               "longitude": -118.11309
43                           },
44                           "distance": {
45                               "value": 430
46                           },
47                           "duration": {
48                               "value": 40
49                           }
50                       },
51                       {
52                           "geometry": "kpjoEx}{oUAwF?oE",
53                           "start_location": {
54                               "latitude": 34.13782,
55                               "longitude": -118.11309
56                           },
57                           "end_location": {
58                               "latitude": 34.13783,
59                               "longitude": -118.11081
60                           },
61                           "distance": {
62                               "value": 210
63                           },
64                           "duration": {
65                               "value": 24
66                           }
67                       },
68                       {
69                           "geometry": "mpjoEpo{oUZ?REZOLKLA\\Al@@N?dE@",
70                           "start_location": {
71                               "latitude": 34.13783,
72                               "longitude": -118.11081
73                           },
74                           "end_location": {
75                               "latitude": 34.13586,
76                               "longitude": -118.11064
77                           },
78                           "distance": {
79                               "value": 222
80                           },
81                           "duration": {
82                               "value": 55
83                           }
84                       },
85                       {
86                           "geometry": "cdjoEnn{oU?cD?{@?{A?[?OAeA?{@?U?_A?}C?kHAiE?i@?aC@_C?wC?e@?cA?W?S?{@?Y?uB?_A?w@?U?c@?Q@m@?U?g@?[?WBe@?ODeABi@D[@YFaB?yB?YCoF?i@?_@A_A?M",
87                           "start_location": {
88                               "latitude": 34.13586,
89                               "longitude": -118.11064
90                           },
91                           "end_location": {
92                               "latitude": 34.13574,
93                               "longitude": -118.09436
94                           },
95                           "distance": {
96                               "value": 1498
97                           },
98                           "duration": {
99                               "value": 170
100                           }
101                       },
102                       {
103                           "geometry": "kcjoEvhxoUp@GPCNAb@E|@IF?r@KhAOXGlAUz@SxBe@j@Ol@Ov@SZKd@OB?^Md@MVKNG`@MlCcATIlBu@\\OXKv@YHEh@SPGHEb@Q\\If@QHEP?`@MNGRGNEHCNEx@SZGXGTGf@MNE\\I`@KJCDCHKZGHAvCk@PCVEn@KHAHAHAp@KJCLALAJAH?P?L?N@F@NBPBH@RFHDFBFBFBHDFDHDJHFFHFRRFHDDFFFFFDDDFDBBDBDBFDLHJFXH",
104                           "start_location": {
105                               "latitude": 34.13574,
106                               "longitude": -118.09436
107                           },
108                           "end_location": {
109                               "latitude": 34.12205,
110                               "longitude": -118.09125
111                           },
112                           "distance": {
113                               "value": 1612
114                           },
115                           "duration": {
116                               "value": 141
117                           }
118                       },
119                       {
120                           "geometry": "ymgoEhuwoUPBJ@RBN@P@T?v@?~@Ah@A\\?tACv@?p@AX?`@?\\?j@?|@A\\?b@Ar@?ZAr@?lBAlFC`@?nA?LAd@?^?f@?F?^?XAx@?R?X?@?^Al@?f@?^Ah@?^?n@AB?j@?V?H?t@AdBAbA?|AALAV?pA?xBA~@AbCAN?X?nBCbA?vBAdA?jAAp@?jAA`AAV?V?|@Ab@?P?^?d@Ax@?~@?n@?d@?vCA|@?bAAL?b@?N?xAAl@AP?tA?`@Av@?p@Aj@?l@?d@?`@?T?f@A~@?L?n@?pA?H?LApA?`@AH?J?R?Z?`@?b@?Z?Z?h@AX?n@?\\?RH\\A|@?~@?r@Ad@?t@A|@@z@?\\?`@Aj@?b@?TIN?RA`@?V?p@?x@?f@A|@?R?j@A\\?\\?p@?^AX?V?R?N?V?r@At@?Z?d@Az@?L?T?X?JA^?V?x@?~@AX?R?f@?V?Z?zAA|@?v@AlB?lBANA^?pB?X?dA?p@?nA?f@?NA^?N?`@?v@@t@AL?l@?L?\\?T?H?Z?F?rA?~@AN?|@?R?@?\\?l@?j@A~@?F?H?R?R?v@AZ?T?L?T?T?V?X?fA?VAF?NJJ?l@?R?F?N?NAZ?",
121                           "start_location": {
122                               "latitude": 34.12205,
123                               "longitude": -118.09125
124                           },
125                           "end_location": {
126                               "latitude": 34.07418,
127                               "longitude": -118.09076
128                           },
129                           "distance": {
130                               "value": 5327
131                           },
132                           "duration": {
133                               "value": 486
134                           }
135                       },
136                       {
137                           "geometry": "sb~nEfrwoUZ?Z?b@AjCGv@AlAA^?P?N?L@R?X@V?fAC^Ap@?j@Al@?h@?ZAF?L?d@ADEHET?^?`@Af@?t@?`@?h@?\\?X?P?l@?P?T?b@?L@b@Ar@AL?T?b@?j@CfA?XAj@?t@?\\AJ?^?x@?n@At@?dB?^?JA\\@J?d@?hAAH?p@?V?^?`@?f@@|@@`B@j@@vCBN?n@AT?tAAb@@J?TAf@?z@?R?p@?TApB?tAAbA?P?fA?n@?R?NAn@?X?v@?z@?T?P?f@?J?j@@p@?H?V?^?\\?bAAT?L?NJP?D?D?B?H?L?R?x@AN?F?D?V?Z?`@?^?v@?h@?vB?h@AT?R?\\?`A?x@Ax@?lBC^?r@?T?f@?dA?dA?x@?P?bCAv@?@?~@AL@D?N?d@@H@JB",
138                           "start_location": {
139                               "latitude": 34.07418,
140                               "longitude": -118.09076
141                           },
142                           "end_location": {
143                               "latitude": 34.04447,
144                               "longitude": -118.09056
145                           },
146                           "distance": {
147                               "value": 3307
148                           },
149                           "duration": {
150                               "value": 313
151                           }
152                       },
153                       {
154                           "geometry": "}hxnE~pwoUHWTw@La@FUDKLc@Pk@`@qAFODKd@}ADMZeAHURo@FORs@Pk@`@mABIH[ZaA\\eATs@r@{BDMLa@DQ`@kAPm@FO`AcDHUJ[DKPa@Zq@P]JQRYPST[Za@DCHKJKPOLM^YHGROJIBA^ULIJGPMPM`@WRMVQJGj@_@TMDEJEx@k@h@]ZUZSZUJIfAu@VQhA{@BCdAq@^Yf@_@PMPOFEDEv@u@NShBoBNO\\a@d@k@l@q@|@}@d@i@~@gAjA_Bb@o@BSVYNSrAwAtAqAPEHGNMBC`@a@RUTWJMb@k@HKLQRYTa@T]NWN[R_@P_@Vk@Xm@FQDIFOHUt@_CFOTu@J_@J_@FQPo@Lc@J_@Ni@VcA",
155                           "start_location": {
156                               "latitude": 34.04447,
157                               "longitude": -118.09056
158                           },
159                           "end_location": {
160                               "latitude": 34.02852,
161                               "longitude": -118.06809
162                           },
163                           "distance": {
164                               "value": 2801
165                           },
166                           "duration": {
167                               "value": 241
168                           }
169                       },
170                       {
171                           "geometry": "geunEpdsoUt@`@j@Zn@ZNFd@TfB~@|Av@^R^PZNbAf@dAh@`@RRJfAl@lCvAtAt@x@b@PJTNVPPJBBXRRPHHNNHHRTNNZ`@RTNPNRT^HLHLLVR`@LZjAbCzB~Eb@`ANZBHt@`Bt@~Af@x@JRj@z@V\\JLt@x@PPTT\\Vt@j@JFTN\\T^Pl@Xt@XNFLDr@PZHVFx@RfB\\vA\\ND^JD?nBb@\\JrAXp@Nh@Jb@Hz@Pb@Jj@N~AZbATfATH@XFh@JD@b@JVDJBB@`@Hz@P\\H^HNDv@NZHLBF@JBz@RF@zAZp@NPDn@N`@H~@T~@Vf@Lj@NlA\\b@J",
172                           "start_location": {
173                               "latitude": 34.02852,
174                               "longitude": -118.06809
175                           },
176                           "end_location": {
177                               "latitude": 34.00583,
178                               "longitude": -118.08257
179                           },
180                           "distance": {
181                               "value": 2951
182                           },
183                           "duration": {
184                               "value": 227
185                           }
186                       },
187                       {
188                           "geometry": "mwpnE`_voU?K@MB[",
189                           "start_location": {
190                               "latitude": 34.00583,
191                               "longitude": -118.08257
192                           },
193                           "end_location": {
194                               "latitude": 34.0058,
195                               "longitude": -118.0823
196                           },
197                           "distance": {
198                               "value": 26
199                           },
200                           "duration": {
201                               "value": 18
202                           }
203                       },
204                       {
205                           "geometry": "gwpnEj}uoUj@ZVJr@R|Ct@ZFL?",
206                           "start_location": {
207                               "latitude": 34.0058,
208                               "longitude": -118.0823
209                           },
210                           "end_location": {
211                               "latitude": 34.0042,
212                               "longitude": -118.08291
213                           },
214                           "distance": {
215                               "value": 188
216                           },
217                           "duration": {
218                               "value": 45
219                           }
220                       },
221                       {
222                           "geometry": "gmpnEdavoU??",
223                           "start_location": {
224                               "latitude": 34.0042,
225                               "longitude": -118.08291
226                           },
227                           "end_location": {
228                               "latitude": 34.0042,
229                               "longitude": -118.08291
230                           },
231                           "distance": {
232                               "value": 0
233                           },
234                           "duration": {
235                               "value": 0
236                           }
237                       }
238                   ]
239               }
240           ]
241       }
242   ]
243}

Following is a visual representation of the above response. Observe that choosing the shortest path and adding other configurations, changes the suggested route.

POST request Example

Let’s look at a Directions Flexible POST method request with values for different parameters to configure a request

1curl --location --request POST ‘https://api.nextbillion.io/directions/json?key=<your_api_key>&option=flexible’
2--header 'Content-Type: application/json'
3--data '{
4   "origin": "34.14169142,-118.11283644",
5   "destination": "34.00419854,-118.08278668",
6   "mode": "car",
7   "overview": "simplified",
8   "geometry": "polyline6",
9   "avoid": "highway",
10   "alternative": true,
11   "altcount":2,
12   "waypoints": "34.09410170,-117.93187758|34.04547240,-117.96517223",
13   "approaches": "unrestricted;;curb"
14}'

API Query Limits

  1. Maximum number of waypoints allowed in a GET request is 50 and in a POST request is 200.

  2. Maximum dimensions allowed for truck_size are 5000 cm for length, 5000 cm for width, 1000 cm for height.

  3. Maximum weight allowed for truck_weight (including the trailer and shipped goods) is 100,000 kg

  4. 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
200Normal success case.

Normal success case.

400Input validation failed.

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

401APIKEY not supplied or invalid.

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

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 a malformed hostname is used.

422Could not process the request.

Valid route could not be generated for the given parameters

429Too many requests.

QPM or API request count quota reached

500Internal Service error.

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

Get Started
Distance Matrix
DIDN'T FIND WHAT YOU LOOKING FOR?