Netradyne Integration with NextBillion.ai’s Route Optimization API

Introduction

The integration of Netradyne's technology with NextBillion.ai's Route Optimization API is a significant step forward in the field of fleet management and road safety. Netradyne, known for its emphasis on driver safety, fleet efficiency, and data-driven insights, analyzes driver behavior and road conditions using advanced AI algorithms and real-time monitoring.

The Route Optimization API from NextBillion.ai provides businesses with a practical way to plan routes accurately, saving time and money while ensuring customer satisfaction. It includes real-time tracking and detailed analytics to monitor and improve fleet operations.

This integration combines the strengths of Netradyne and NextBillion.ai and provides businesses with a competitive advantage in the field. It simplifies and improves their daily operations by combining safety, efficiency, and innovation.

Prerequisites

To successfully integrate Netradyne with NextBillion.ai, ensure you have the following prerequisites in place:

  1. Netradyne's Authorization and Tenant Unique Name

  2. NextBillion.ai's API key: Obtain an API key from NextBillion.ai, which serves as the authentication mechanism for accessing their services and data. This key is essential for secure and authorized communication between your systems and NextBillion.ai's APIs.

Integration Steps

Generate Access Token

  1. Generate Access token of Netradyne using the POST request. More details on the REST API requests can be found here

    1https://api.netradyne.com/driveri/v1/auth/token
  2. Verify Basic CRUD Operations: Finally, verify that basic CRUD (Create, Read, Update, Delete) operations are functioning as expected using the generated access token.

Pull List of Vehicles from Netradyne

Retrieve the list of vehicles from the Netradyne platform using the following API request.

Sample API Request

1# Fetch vehicles from Netradyne
2curl --location 'https://api.netradyne.com/driveri/v1/tenants/N546980211724797/vehicles' \
3--header 'Accept-Language: en-US' \
4--header 'Authorization: Bearer <access_token>'

Sample API Response

1"totalCount": 46,
2  "data": {
3    "vehicles": [
4      {
5        "vin": "195192",
6        "vehicleNumber": "195192",
7        "licensePlateNumber": "string",
8        "regdDate": 1694385610954,
9        "status": 1,
10        "tenantUniqueName": "N546980211724797",
11        "updatedOn": 1694385610948,
12        "vehicleDetails": {
13          "class": "Unknown",
14          "gVM": "52000 lb"
15        },
16        "batteryToMasterSwitchDisconnected": 0
17      },
18      {
19        "vin": "123456789",
20        "vehicleNumber": "2345",
21        "licensePlateNumber": "4567890",
22        "regdDate": 1668727922881,
23        "status": 1,
24        "tenantUniqueName": "N546980211724797",
25        "updatedOn": 1668727922883,
26        "vehicleDetails": {
27          "class": "CLASS1"
28        },
29        "batteryToMasterSwitchDisconnected": 2
30      },
31      {
32        "vin": "1J4HA6H1XAL130149",
33        "vehicleNumber": "Vista430",
34        "licensePlateNumber": "TBD",
35        "regdDate": 1681235423863,
36        "status": 1,
37        "deviceId": "3633015376",
38        "camera": {
39          "id": "3633015376"
40        },
41        "tenantUniqueName": "N546980211724797",
42        "updatedOn": 1691015788503,
43        "vehicleDetails": {
44          "class": "CLASS6",
45          "gVM": "22000 lb"
46        },
47        "batteryToMasterSwitchDisconnected": 1
48      },
49      {
50        "vin": "5TBBT54117S452443",
51        "vehicleNumber": "IMUTestRandy",
52        "licensePlateNumber": "u8002s",
53        "regdDate": 1647339413982,
54        "status": 1,
55        "deviceId": "264015804",
56        "camera": {
57          "id": "264015804"
58        },
59        "tenantUniqueName": "N546980211724797",
60        "updatedOn": 1685115792723,
61        "vehicleDetails": {
62          "class": "CLASS2",
63          "gVM": "10001 lb"
64        },
65        "batteryToMasterSwitchDisconnected": 2
66      },
67      {
68        "vin": "5YJ3E1EA4LF611371",
69        "vehicleNumber": "KFCModel3",
70        "licensePlateNumber": "Temp",
71        "regdDate": 1666802973800,
72        "status": 1,
73        "tenantUniqueName": "N546980211724797",
74        "updatedOn": 1692993365292,
75        "vehicleDetails": {
76          "class": "CLASS1",
77          "gVM": "5000 lb"
78        },
79        "batteryToMasterSwitchDisconnected": 2
80      },
81      {
82        "vin": "101844",
83        "vehicleNumber": "101844",
84        "licensePlateNumber": "CXAA123",
85        "regdDate": 1694106162207,
86        "status": 1,
87        "tenantUniqueName": "N546980211724797",
88        "updatedOn": 1694106162194,
89        "vehicleDetails": {
90          "class": "Unknown",
91          "gVM": "52000 lb"
92        },
93        "batteryToMasterSwitchDisconnected": 0
94      },
95      {
96        "vin": "0",
97        "vehicleNumber": "580-130199",
98        "licensePlateNumber": "2374484",
99        "regdDate": 1694110935281,
100        "status": 1,
101        "tenantUniqueName": "N546980211724797",
102        "updatedOn": 1694110935272,
103        "vehicleDetails": {
104          "class": "Unknown"
105        },
106        "batteryToMasterSwitchDisconnected": 2
107      },
108      {
109        "vin": "1000",
110        "vehicleNumber": "827-1000",
111        "licensePlateNumber": "CJ28557",
112        "regdDate": 1694110935318,
113        "status": 1,
114        "tenantUniqueName": "N546980211724797",
115        "updatedOn": 1694110935272,
116        "vehicleDetails": {
117          "class": "Unknown"
118        },
119        "batteryToMasterSwitchDisconnected": 2
120      },
121      {
122        "vin": "101845",
123        "vehicleNumber": "115-101845",
124        "licensePlateNumber": "C85252A",
125        "regdDate": 1694110935326,
126        "status": 1,
127        "tenantUniqueName": "N546980211724797",
128        "updatedOn": 1694110935272,
129        "vehicleDetails": {
130          "class": "Unknown"
131        },
132        "batteryToMasterSwitchDisconnected": 2
133      },
134      {
135        "vin": "146660",
136        "vehicleNumber": "115-146660",
137        "licensePlateNumber": "C07232F",
138        "regdDate": 1694110935328,
139        "status": 1,
140        "tenantUniqueName": "N546980211724797",
141        "updatedOn": 1694110935272,
142        "vehicleDetails": {
143          "class": "Unknown"
144        },
145        "batteryToMasterSwitchDisconnected": 2
146      },
147      {
148        "vin": "147451",
149        "vehicleNumber": "115-147451",
150        "licensePlateNumber": "C07234F",
151        "regdDate": 1694110935329,
152        "status": 1,
153        "tenantUniqueName": "N546980211724797",
154        "updatedOn": 1694110935272,
155        "vehicleDetails": {
156          "class": "Unknown"
157        },
158        "batteryToMasterSwitchDisconnected": 2
159      },
160      {
161        "vin": "157463",
162        "vehicleNumber": "729-01",
163        "licensePlateNumber": "2385576",
164        "regdDate": 1694110935330,
165        "status": 1,
166        "tenantUniqueName": "N546980211724797",
167        "updatedOn": 1694110935272,
168        "vehicleDetails": {
169          "class": "Unknown"
170        },
171        "batteryToMasterSwitchDisconnected": 2
172      },
173      {
174        "vin": "170364",
175        "vehicleNumber": "595-170364",
176        "licensePlateNumber": "None",
177        "regdDate": 1694110935333,
178        "status": 1,
179        "tenantUniqueName": "N546980211724797",
180        "updatedOn": 1694110935272,
181        "vehicleDetails": {
182          "class": "Unknown"
183        },
184        "batteryToMasterSwitchDisconnected": 2
185      },
186      {
187        "vin": "192071",
188        "vehicleNumber": "656-192071",
189        "licensePlateNumber": "12345",
190        "regdDate": 1694110935335,
191        "status": 1,
192        "tenantUniqueName": "N546980211724797",
193        "updatedOn": 1694110935272,
194        "vehicleDetails": {
195          "class": "Unknown"
196        },
197        "batteryToMasterSwitchDisconnected": 2
198      },
199      {
200        "vin": "193627",
201        "vehicleNumber": "113-12",
202        "licensePlateNumber": "V009DU",
203        "regdDate": 1694110935336,
204        "status": 1,
205        "tenantUniqueName": "N546980211724797",
206        "updatedOn": 1694110935272,
207        "vehicleDetails": {
208          "class": "Unknown"
209        },
210        "batteryToMasterSwitchDisconnected": 2
211      },
212      {
213        "vin": "195189",
214        "vehicleNumber": "767-909",
215        "licensePlateNumber": "B77085V",
216        "regdDate": 1694110935337,
217        "status": 1,
218        "tenantUniqueName": "N546980211724797",
219        "updatedOn": 1694110935272,
220        "vehicleDetails": {
221          "class": "Unknown"
222        },
223        "batteryToMasterSwitchDisconnected": 2
224      },
225      {
226        "vin": "2",
227        "vehicleNumber": "650-560",
228        "licensePlateNumber": "QTN600",
229        "regdDate": 1694110935339,
230        "status": 1,
231        "tenantUniqueName": "N546980211724797",
232        "updatedOn": 1694110935272,
233        "vehicleDetails": {
234          "class": "Unknown"
235        },
236        "batteryToMasterSwitchDisconnected": 2
237      },
238      {
239        "vin": "23",
240        "vehicleNumber": "848-01",
241        "licensePlateNumber": "96089V1",
242        "regdDate": 1694110935341,
243        "status": 1,
244        "tenantUniqueName": "N546980211724797",
245        "updatedOn": 1694110935272,
246        "vehicleDetails": {
247          "class": "Unknown"
248        },
249        "batteryToMasterSwitchDisconnected": 2
250      },
251      {
252        "vin": "5302023",
253        "vehicleNumber": "650-674",
254        "licensePlateNumber": "BHQ735",
255        "regdDate": 1694110935342,
256        "status": 1,
257        "tenantUniqueName": "N546980211724797",
258        "updatedOn": 1694110935272,
259        "vehicleDetails": {
260          "class": "Unknown"
261        },
262        "batteryToMasterSwitchDisconnected": 2
263      },
264      {
265        "vin": "602",
266        "vehicleNumber": "10-602",
267        "licensePlateNumber": "02860H1",
268        "regdDate": 1694110935344,
269        "status": 1,
270        "tenantUniqueName": "N546980211724797",
271        "updatedOn": 1694110935272,
272        "vehicleDetails": {
273          "class": "Unknown"
274        },
275        "batteryToMasterSwitchDisconnected": 2
276      },
277      {
278        "vin": "638098",
279        "vehicleNumber": "115-638098",
280        "licensePlateNumber": "B54314W",
281        "regdDate": 1694110935347,
282        "status": 1,
283        "tenantUniqueName": "N546980211724797",
284        "updatedOn": 1694110935272,
285        "vehicleDetails": {
286          "class": "Unknown"
287        },
288        "batteryToMasterSwitchDisconnected": 2
289      },
290      {
291        "vin": "638102",
292        "vehicleNumber": "115-638102",
293        "licensePlateNumber": "B54318W",
294        "regdDate": 1694110935348,
295        "status": 1,
296        "tenantUniqueName": "N546980211724797",
297        "updatedOn": 1694110935272,
298        "vehicleDetails": {
299          "class": "Unknown"
300        },
301        "batteryToMasterSwitchDisconnected": 2
302      },
303      {
304        "vin": "638103",
305        "vehicleNumber": "115-638103",
306        "licensePlateNumber": "B54319W",
307        "regdDate": 1694110935350,
308        "status": 1,
309        "tenantUniqueName": "N546980211724797",
310        "updatedOn": 1694110935272,
311        "vehicleDetails": {
312          "class": "Unknown"
313        },
314        "batteryToMasterSwitchDisconnected": 2
315      },
316      {
317        "vin": "638107",
318        "vehicleNumber": "564-08",
319        "licensePlateNumber": "87060L1",
320        "regdDate": 1694110935352,
321        "status": 1,
322        "tenantUniqueName": "N546980211724797",
323        "updatedOn": 1694110935272,
324        "vehicleDetails": {
325          "class": "Unknown"
326        },
327        "batteryToMasterSwitchDisconnected": 2
328      },
329      {
330        "vin": "676202",
331        "vehicleNumber": "1487-676202",
332        "licensePlateNumber": "B97217Y",
333        "regdDate": 1694110935356,
334        "status": 1,
335        "tenantUniqueName": "N546980211724797",
336        "updatedOn": 1694110935272,
337        "vehicleDetails": {
338          "class": "Unknown"
339        },
340        "batteryToMasterSwitchDisconnected": 2
341      },
342      {
343        "vin": "827991",
344        "vehicleNumber": "827-887",
345        "licensePlateNumber": "CD85881",
346        "regdDate": 1694110935358,
347        "status": 1,
348        "tenantUniqueName": "N546980211724797",
349        "updatedOn": 1694110935272,
350        "vehicleDetails": {
351          "class": "Unknown"
352        },
353        "batteryToMasterSwitchDisconnected": 2
354      },
355      {
356        "vin": "846-3631",
357        "vehicleNumber": "564-16",
358        "licensePlateNumber": "42876K1",
359        "regdDate": 1694110935361,
360        "status": 1,
361        "tenantUniqueName": "N546980211724797",
362        "updatedOn": 1694110935272,
363        "vehicleDetails": {
364          "class": "Unknown"
365        },
366        "batteryToMasterSwitchDisconnected": 2
367      },
368      {
369        "vin": "8463035",
370        "vehicleNumber": "767-47",
371        "licensePlateNumber": "C58881E",
372        "regdDate": 1694110935363,
373        "status": 1,
374        "tenantUniqueName": "N546980211724797",
375        "updatedOn": 1694110935272,
376        "vehicleDetails": {
377          "class": "Unknown"
378        },
379        "batteryToMasterSwitchDisconnected": 2
380      },
381      {
382        "vin": "915-2304",
383        "vehicleNumber": "25-9152304",
384        "licensePlateNumber": "B78438U",
385        "regdDate": 1694110935364,
386        "status": 1,
387        "tenantUniqueName": "N546980211724797",
388        "updatedOn": 1694110935272,
389        "vehicleDetails": {
390          "class": "Unknown"
391        },
392        "batteryToMasterSwitchDisconnected": 2
393      },
394      {
395        "vin": "999998",
396        "vehicleNumber": "767-336",
397        "licensePlateNumber": "C24427A",
398        "regdDate": 1694110935366,
399        "status": 1,
400        "tenantUniqueName": "N546980211724797",
401        "updatedOn": 1694110935272,
402        "vehicleDetails": {
403          "class": "Unknown"
404        },
405        "batteryToMasterSwitchDisconnected": 2
406      },
407      {
408        "vin": "999999",
409        "vehicleNumber": "767-104",
410        "licensePlateNumber": "B54321W",
411        "regdDate": 1694110935367,
412        "status": 1,
413        "tenantUniqueName": "N546980211724797",
414        "updatedOn": 1694110935272,
415        "vehicleDetails": {
416          "class": "Unknown"
417        },
418        "batteryToMasterSwitchDisconnected": 2
419      },
420      {
421        "vin": "101844555",
422        "vehicleNumber": "115-101844",
423        "licensePlateNumber": "C85214A",
424        "regdDate": 1694110935369,
425        "status": 1,
426        "tenantUniqueName": "N546980211724797",
427        "updatedOn": 1694110935272,
428        "vehicleDetails": {
429          "class": "Unknown"
430        },
431        "batteryToMasterSwitchDisconnected": 2
432      },
433      {
434        "vin": "170365",
435        "vehicleNumber": "595-170365",
436        "licensePlateNumber": "None222233",
437        "regdDate": 1694110935370,
438        "status": 1,
439        "tenantUniqueName": "N546980211724797",
440        "updatedOn": 1694110935272,
441        "vehicleDetails": {
442          "class": "Unknown"
443        },
444        "batteryToMasterSwitchDisconnected": 2
445      },
446      {
447        "vin": "170367",
448        "vehicleNumber": "595-170367",
449        "licensePlateNumber": "None2222",
450        "regdDate": 1694110935371,
451        "status": 1,
452        "tenantUniqueName": "N546980211724797",
453        "updatedOn": 1694110935272,
454        "vehicleDetails": {
455          "class": "Unknown"
456        },
457        "batteryToMasterSwitchDisconnected": 2
458      },
459      {
460        "vin": "170368",
461        "vehicleNumber": "595-170368",
462        "licensePlateNumber": "111111",
463        "regdDate": 1694110935373,
464        "status": 1,
465        "tenantUniqueName": "N546980211724797",
466        "updatedOn": 1694110935272,
467        "vehicleDetails": {
468          "class": "Unknown"
469        },
470        "batteryToMasterSwitchDisconnected": 2
471      },
472      {
473        "vin": "JM287",
474        "vehicleNumber": "580-130599",
475        "licensePlateNumber": "2374485",
476        "regdDate": 1694110935374,
477        "status": 1,
478        "tenantUniqueName": "N546980211724797",
479        "updatedOn": 1694110935272,
480        "vehicleDetails": {
481          "class": "Unknown"
482        },
483        "batteryToMasterSwitchDisconnected": 2
484      },
485      {
486        "vin": "638094",
487        "vehicleNumber": "1665-638094",
488        "licensePlateNumber": "B49906W",
489        "regdDate": 1694110935346,
490        "status": 1,
491        "tenantUniqueName": "N546980211724797",
492        "updatedOn": 1694110935272,
493        "vehicleDetails": {
494          "class": "Unknown"
495        },
496        "batteryToMasterSwitchDisconnected": 2
497      },
498      {
499        "vin": "170051",
500        "vehicleNumber": "115-170051",
501        "licensePlateNumber": "C98272G",
502        "regdDate": 1694110935332,
503        "status": 1,
504        "tenantUniqueName": "N546980211724797",
505        "updatedOn": 1694110935272,
506        "vehicleDetails": {
507          "class": "Unknown"
508        },
509        "batteryToMasterSwitchDisconnected": 2
510      },
511      {
512        "vin": "1FTFW1ET7DKF98945",
513        "vehicleNumber": "TESLA-MODEL-S",
514        "licensePlateNumber": "JBOND007",
515        "regdDate": 1661454087687,
516        "status": 1,
517        "tenantUniqueName": "N546980211724797",
518        "updatedOn": 1692993273687,
519        "vehicleDetails": {
520          "class": "CLASS1",
521          "gVM": "5000 lb"
522        },
523        "batteryToMasterSwitchDisconnected": 2
524      },
525      {
526        "vin": "157465",
527        "vehicleNumber": "157465",
528        "licensePlateNumber": "W643NP",
529        "regdDate": 1694119695305,
530        "status": 1,
531        "tenantUniqueName": "N546980211724797",
532        "updatedOn": 1694119695290,
533        "vehicleDetails": {
534          "class": "Unknown",
535          "gVM": "52000 lb"
536        },
537        "batteryToMasterSwitchDisconnected": 0
538      },
539      {
540        "vin": "1002",
541        "vehicleNumber": "1002",
542        "licensePlateNumber": "CJ28559",
543        "regdDate": 1694123204992,
544        "status": 1,
545        "tenantUniqueName": "N546980211724797",
546        "updatedOn": 1694123204982,
547        "vehicleDetails": {
548          "class": "Unknown",
549          "gVM": "52000 lb"
550        },
551        "batteryToMasterSwitchDisconnected": 0
552      },
553      {
554        "vin": "164577",
555        "vehicleNumber": "164577",
556        "licensePlateNumber": "2385582",
557        "regdDate": 1694124996237,
558        "status": 1,
559        "tenantUniqueName": "N546980211724797",
560        "updatedOn": 1694124996219,
561        "vehicleDetails": {
562          "class": "Unknown",
563          "gVM": "52000 lb"
564        },
565        "batteryToMasterSwitchDisconnected": 0
566      },
567      {
568        "vin": "203605",
569        "vehicleNumber": "203605",
570        "licensePlateNumber": "123",
571        "regdDate": 1694212437903,
572        "status": 1,
573        "tenantUniqueName": "N546980211724797",
574        "updatedOn": 1694212437896,
575        "vehicleDetails": {
576          "class": "Unknown",
577          "gVM": "52000 lb"
578        },
579        "batteryToMasterSwitchDisconnected": 0
580      },
581      {
582        "vin": "137283",
583        "vehicleNumber": "137283",
584        "licensePlateNumber": "C54133E",
585        "regdDate": 1694127005625,
586        "status": 1,
587        "tenantUniqueName": "N546980211724797",
588        "updatedOn": 1694127005617,
589        "vehicleDetails": {
590          "class": "Unknown",
591          "gVM": "52000 lb"
592        },
593        "batteryToMasterSwitchDisconnected": 0
594      },
595      {
596        "vin": "116039",
597        "vehicleNumber": "116039",
598        "licensePlateNumber": "C70707B",
599        "regdDate": 1694135020850,
600        "status": 1,
601        "tenantUniqueName": "N546980211724797",
602        "updatedOn": 1694135020840,
603        "vehicleDetails": {
604          "class": "Unknown",
605          "gVM": "52000 lb"
606        },
607        "batteryToMasterSwitchDisconnected": 0
608      },
609      {
610        "vin": "JHMCP26748C047713",
611        "vehicleNumber": "KFCAccord",
612        "licensePlateNumber": "6DKM149",
613        "regdDate": 1647339375272,
614        "status": 1,
615        "deviceId": "264094871",
616        "camera": {
617          "id": "264094871"
618        },
619        "tenantUniqueName": "N546980211724797",
620        "updatedOn": 1695061928041,
621        "vehicleDetails": {
622          "class": "CLASS1",
623          "gVM": "5000 lb"
624        },
625        "batteryToMasterSwitchDisconnected": 2
626      }
627    ]
628}

This API response includes essential information about each vehicle, such as VIN (Vehicle Identification Number), vehicle number, license plate number, registration date, status, and additional details about the vehicle's class, gross vehicle weight (gVM), and battery status.

Delivery Records Integration

The delivery records will be linked to the jobs parameter within NextBillion.ai's Route Optimization API. To facilitate testing and integration, we have generated a set of random jobs that can be employed for route optimization evaluation. However, for real-world scenarios, users have the flexibility to substitute these random jobs with their specific delivery addresses or job data.

Here are the key steps involved in this process:

  1. Download Sample CSV File: We provide a sample CSV file containing randomly generated job data. You can download this file to understand the format and structure required for the job data.

  2. Upload Job Data in CSV Format: After customizing your job data in CSV format, you can upload it into the system. This step ensures that your specific delivery addresses or job details are seamlessly integrated and optimized using NextBillion's Route Optimization API.

Configuration of Additional Parameters

In our technical integration process, apart from the core parameters, there are additional settings that play a crucial role in fine-tuning the route optimization. These settings allow for a more comprehensive and customized optimization process. Here's how to configure these parameters:

  1. Driver's Shift Start and End Time: Define the start and end times of the driver's shift within the application. This sets the timeframe during which the route optimization should take place, ensuring alignment with the driver's working hours.

  2. Start and End Vehicle Locations: Specify the initial and final locations for the vehicle. Typically, this corresponds to the vehicle's departure point (e.g., the warehouse) and its return location after completing deliveries. These locations serve as critical reference points for route calculation.

  3. Service Time: The service time represents the duration required by the delivery executive to fulfill each order. Accurate service time input is essential for realistic route optimization.

Once all these parameters are correctly configured to match your specific operational requirements, you're ready to proceed.

Integration with Route Optimization API

After successfully pulling the necessary data from Netradyne, integrate the fetched data with Route Optimization using the following API endpoint.

Map the fetched Netradyne data to the respective API parameters. Configure optimization settings such as shift start and end time, service time, and start and end location coordinates.

1let vehicles = [];
2let shifts = [];
3let starts = [];
4let ends = [];
5let veh_attr = [];
6let stop_attr = [];
7let vehicle_index = 1;
8let shiftStart = (new Date(dtShiftStart2.value).getTime()/1000);
9let shiftEnd = (new Date(dtShiftEnd2.value).getTime()/1000);
10
11// START NBAI PROBLEM BUILD
12let locations = [];
13let jobs = [];
14let shipments = [];
15vehicles = [];
16veh_attr = [];
17stop_attr = [];
18// sequence through all stops and create job array while
19// also creating the indexed list of locations 
20let location_index = 0;
21let location = [];
22addressess.data.forEach(planstop => {
23    let from = new Date(planstop.from).getTime() / 1000;
24  let to = new Date(planstop.to).getTime() / 1000;
25
26      let job = {
27        id: parseInt(planstop.ID),
28        description: planstop.Dropoff,
29        location_index: location_index++,
30        service: numberInput1.value,
31        priority: 0,
32        time_windows: [[from,to]]
33      }
34      location.push(`${planstop.dropoff_latitude},${planstop.dropoff_longitude}`);
35
36      jobs.push(job);
37  
38});
39
40// Add shift start/stop location to location index
41location.push(`${txtVehicleStartPosition2.value}`);
42location.push(`${txtVehicleEndPosition2.value}`);
43location_index += 1;
44let veh_fixed_cost = 0;
45tblVehicles.data.forEach( (v,idx) => {
46  let breaks = [];
47  let vehicle = {
48    id: vehicle_index++,
49    start_index: location_index,
50    time_window: [shiftStart, shiftEnd],
51    max_tasks: 25,
52    costs: {
53      fixed: veh_fixed_cost
54    }
55  };
56    vehicles.push(vehicle);
57    veh_fixed_cost += 0;
58});
59
60locations = {
61  id: 12,
62  description: 'Netradyne Test',
63  location: location
64};
65
66let options = {
67  routing: {
68    mode: "car"
69  }
70};
71
72localStorage.setValue('vehiclesNBAI', vehicles);
73localStorage.setValue('shipmentsNBAI', shipments);
74localStorage.setValue('jobsNBAI', jobs);
75localStorage.setValue('locationsNBAI', locations);
76localStorage.setValue('nbaiOptions', options);
77localStorage.setValue('nbaiVRPResult', null);
78nbaiOptimizationRun.trigger();

Follow these steps to achieve a successful integration:

Step 1: Define Data Structures

Begin by setting up the necessary data structures to facilitate the integration. These include arrays and variables for vehicles, shifts, start and end locations, vehicle attributes, and stop attributes.

1let vehicles = [];
2let shifts = [];
3let starts = [];
4let ends = [];
5let veh_attr = [];
6let stop_attr = [];

Step 2: Configure Optimization Settings

Specify optimization settings to tailor the routing process to your specific needs. These settings typically include shift start and end times, service times, and the coordinates of start and end locations.

1let shiftStart = (new Date(dtShiftStart2.value).getTime() / 1000);
2let shiftEnd = (new Date(dtShiftEnd2.value).getTime() / 1000);

Step 3: Prepare Data for Route Optimization

Assemble the data required for route optimization. This involves creating arrays for locations, jobs, and shipments. Additionally, you'll populate the vehicle and job attributes as needed.

1let locations = [];
2let jobs = [];
3let shipments = [];
4vehicles = [];
5veh_attr = [];
6stop_attr = [];
7// sequence through all stops and create job array while
8// also creating the indexed list of locations 
9let location_index = 0;
10let location = [];
11addressess.data.forEach(planstop => {
12    let from = new Date(planstop.from).getTime() / 1000;
13  let to = new Date(planstop.to).getTime() / 1000;
14
15      let job = {
16        id: parseInt(planstop.ID),
17        description: planstop.Dropoff,
18        location_index: location_index++,
19        service: numberInput1.value,
20        priority: 0,
21        time_windows: [[from,to]]
22      }
23      location.push(`${planstop.dropoff_latitude},${planstop.dropoff_longitude}`);
24
25      jobs.push(job);
26  
27});
28
29// Add shift start/stop location to location index
30location.push(`${txtVehicleStartPosition2.value}`);
31location.push(`${txtVehicleEndPosition2.value}`);
32location_index += 1;
33let veh_fixed_cost = 0;
34tblVehicles.data.forEach( (v,idx) => {
35  let breaks = [];
36  let vehicle = {
37    id: vehicle_index++,
38    start_index: location_index,
39    time_window: [shiftStart, shiftEnd],
40    max_tasks: 25,
41    costs: {
42      fixed: veh_fixed_cost
43    }
44  };
45    vehicles.push(vehicle);
46    veh_fixed_cost += 0;
47});
48
49locations = {
50  id: 12,
51  description: 'Netradyne Test',
52  location: location
53};
54
55let options = {
56  routing: {
57    mode: "car"
58  }
59};

Step 4: Store Data and Trigger Optimization

Store the prepared data structures in local storage for future reference and initiate the route optimization process.

1localStorage.setValue('vehiclesNBAI', vehicles);
2localStorage.setValue('shipmentsNBAI', shipments);
3localStorage.setValue('jobsNBAI', jobs);
4localStorage.setValue('locationsNBAI', locations);
5localStorage.setValue('nbaiOptions', options);
6localStorage.setValue('nbaiVRPResult', null);
7
8nbaiOptimizationRun.trigger();

By following these steps, you can effectively connect and integrate Netradyne data with the Route Optimization API, ensuring efficient routing and resource allocation for your tasks or deliveries.

Create Jobs with Route Optimization API

The following API request sends data to NextBillion.ai’s Route Optimization API to create optimization jobs based on certain parameters. The response confirms the creation of jobs.

POST API Request

1curl --request POST \
2    --url https://api.nextbillion.io/optimization/v2?key={{localStorage.values.apiKey}}

POST API Response

1{
2  "id": "cb35dbf1c45e6b86309e3bea880afb39",
3  "message": "Optimization job created",
4  "status": "Ok"
5}

Retrieving Optimized Route Result

To obtain the optimized route results after initiating a route optimization job, you can utilize the provided GET query. This query enables you to fetch the optimized route details from the Route Optimization API.

GET Query

1https://api.nextbillion.io/optimization/v2/result?id={{nbaiOptimizationRun.data.id}}&key={{localStorage.values.apiKey}}

In the above URL, two query parameters are used:

id: This parameter specifies the unique identifier associated with the optimization job. It is obtained from the nbaiOptimizationRun.data.id variable. key: The localStorage.values.apiKey variable provides the API key necessary for authentication.

Example JSON Response

Upon making the GET request, the API will respond with a JSON object containing the optimized route details. Here's an example of what the JSON response may look like.

1{
2	"result": {
3		"code": 0,
4		"summary": {
5			"cost": 18288,
6			"routes": 7,
7			"unassigned": 3,
8			"setup": 0,
9			"service": 2640,
10			"duration": 18288,
11			"waiting_time": 7583,
12			"priority": 0,
13			"distance": 234183.2
14		},
15		"unassigned": [
16			{
17				"id": 13,
18				"type": "job",
19				"location": [
20					33.81422221,
21					-118.324702
22				]
23			},
24			{
25				"id": 18,
26				"type": "job",
27				"location": [
28					33.85713183,
29					-118.1848631
30				]
31			},
32			{
33				"id": 7,
34				"type": "job",
35				"location": [
36					34.11127624,
37					-118.310787
38				]
39			}
40		],
41		"routes": [
42			{
43				"vehicle": 17,
44				"cost": 53,
45				"steps": [
46					{
47						"type": "start",
48						"arrival": 1696599907,
49						"duration": 0,
50						"service": 0,
51						"waiting_time": 0,
52						"location": [
53							33.908,
54							-118.309
55						],
56						"location_index": 26
57					},
58					{
59						"type": "job",
60						"arrival": 1696599960,
61						"duration": 53,
62						"service": 120,
63						"waiting_time": 0,
64						"location": [
65							33.90833078,
66							-118.3091601
67						],
68						"location_index": 0,
69						"id": 1,
70						"description": "13528 South Western Avenue, Gardena, CA 90249, United States"
71					},
72					{
73						"type": "end",
74						"arrival": 1696600080,
75						"duration": 53,
76						"service": 0,
77						"waiting_time": 0,
78						"location": [
79							33.90833078,
80							-118.3091601
81						],
82						"location_index": 0
83					}
84				],
85				"service": 120,
86				"duration": 53,
87				"waiting_time": 0,
88				"priority": 0,
89				"distance": 253,
90				"geometry": "ys}mEffbqU?V[?Q?K?GEKGg@?_@?O?iAA?L?Nt@?x@?F?h@ADC??"
91			},
92			{
93				"vehicle": 3,
94				"cost": 3934,
95				"steps": [
96					{
97						"type": "start",
98						"arrival": 1696585241,
99						"duration": 0,
100						"service": 0,
101						"waiting_time": 0,
102						"location": [
103							33.908,
104							-118.309
105						],
106						"location_index": 26
107					},
108					{
109						"type": "job",
110						"arrival": 1696586940,
111						"duration": 1699,
112						"service": 120,
113						"waiting_time": 0,
114						"location": [
115							34.08885568,
116							-118.2424434
117						],
118						"location_index": 20,
119						"id": 21,
120						"description": "Elysian Park, Los Angeles, CA 90026, United States"
121					},
122					{
123						"type": "job",
124						"arrival": 1696589295,
125						"duration": 3934,
126						"service": 120,
127						"waiting_time": 0,
128						"location": [
129							34.13764673,
130							-118.3233027
131						],
132						"location_index": 24,
133						"id": 25,
134						"description": "4008 Mount Lee Drive, Los Angeles, CA 90068, United States"
135					},
136					{
137						"type": "end",
138						"arrival": 1696589415,
139						"duration": 3934,
140						"service": 0,
141						"waiting_time": 0,
142						"location": [
143							34.13764673,
144							-118.3233027
145						],
146						"location_index": 24
147					}
148				],
149				"service": 240,
150				"duration": 3934,
151				"waiting_time": 0,
152				"priority": 0,
153				"distance": 42968.1,
154				"geometry": "ys}mEffbqU?V[?Q?K?GEKGg@?_@?O?iAAkA@gA?_A@QJ_BAaA?{@A{@BLNp@FVHt@D`A????"
155			},
156			{
157				"vehicle": 4,
158				"cost": 3554,
159				"steps": [
160					{
161						"type": "start",
162						"arrival": 1696593012,
163						"duration": 0,
164						"service": 0,
165						"waiting_time": 0,
166						"location": [
167							33.908,
168							-118.309
169						],
170						"location_index": 26
171					},
172					{
173						"type": "job",
174						"arrival": 1696594040,
175						"duration": 1028,
176						"service": 120,
177						"waiting_time": 0,
178						"location": [
179							33.86482007,
180							-118.1456644
181						],
182						"location_index": 16,
183						"id": 17,
184						"description": "6025 Castana Avenue, Lakewood, CA 90712, United States"
185					},
186					{
187						"type": "job",
188						"arrival": 1696594980,
189						"duration": 1848,
190						"service": 120,
191						"waiting_time": 0,
192						"location": [
193							33.8436929,
194							-118.0226021
195						],
196						"location_index": 15,
197						"id": 16,
198						"description": "6272 San Lorenzo Drive, Buena Park, CA 90620, United States"
199					},
200					{
201						"type": "job",
202						"arrival": 1696596217,
203						"duration": 2965,
204						"service": 120,
205						"waiting_time": 3023,
206						"location": [
207							34.00815079,
208							-118.0675167
209						],
210						"location_index": 2,
211						"id": 3,
212						"description": "4431 Abbeywood Avenue, Pico Rivera, CA 90660, United States"
213					},
214					{
215						"type": "job",
216						"arrival": 1696599949,
217						"duration": 3554,
218						"service": 120,
219						"waiting_time": 311,
220						"location": [
221							34.01040855,
222							-117.9928211
223						],
224						"location_index": 22,
225						"id": 23,
226						"description": "1631 Doverfield Avenue, Hacienda Heights, CA 91745, United States"
227					},
228					{
229						"type": "end",
230						"arrival": 1696600380,
231						"duration": 3554,
232						"service": 0,
233						"waiting_time": 0,
234						"location": [
235							34.01040855,
236							-117.9928211
237						],
238						"location_index": 22
239					}
240				],
241				"service": 480,
242				"duration": 3554,
243				"waiting_time": 3334,
244				"priority": 0,
245				"distance": 73739.6,
246				"geometry": "ys}mEffbqU?Vf@?rA?H?fA@jA?J?\\?\\?V?Z?X?N?d@?p@?X?R?zA`@|@d@f@VXNfAh@JFf@XXLLLTDLBX?dAA??"
247			},
248			{
249				"vehicle": 5,
250				"cost": 4607,
251				"steps": [
252					{
253						"type": "start",
254						"arrival": 1696592821,
255						"duration": 0,
256						"service": 0,
257						"waiting_time": 0,
258						"location": [
259							33.908,
260							-118.309
261						],
262						"location_index": 26
263					},
264					{
265						"type": "job",
266						"arrival": 1696593297,
267						"duration": 476,
268						"service": 120,
269						"waiting_time": 0,
270						"location": [
271							33.94764688,
272							-118.3161763
273						],
274						"location_index": 7,
275						"id": 8,
276						"description": "9724 Haas Avenue, Los Angeles, CA 90047, United States"
277					},
278					{
279						"type": "job",
280						"arrival": 1696594560,
281						"duration": 1619,
282						"service": 120,
283						"waiting_time": 0,
284						"location": [
285							34.01314638,
286							-118.3507868
287						],
288						"location_index": 5,
289						"id": 6,
290						"description": "4534 Pinafore Street, Los Angeles, CA 90008, United States"
291					},
292					{
293						"type": "job",
294						"arrival": 1696595554,
295						"duration": 2493,
296						"service": 120,
297						"waiting_time": 0,
298						"location": [
299							34.05322352,
300							-118.3056606
301						],
302						"location_index": 1,
303						"id": 2,
304						"description": "975 South Hobart Boulevard, Los Angeles, CA 90006, United States"
305					},
306					{
307						"type": "job",
308						"arrival": 1696596243,
309						"duration": 3062,
310						"service": 120,
311						"waiting_time": 0,
312						"location": [
313							34.06801078,
314							-118.2863727
315						],
316						"location_index": 9,
317						"id": 10,
318						"description": "320 South Virgil Avenue, Los Angeles, CA 90020, United States"
319					},
320					{
321						"type": "job",
322						"arrival": 1696597211,
323						"duration": 3910,
324						"service": 120,
325						"waiting_time": 0,
326						"location": [
327							34.09750474,
328							-118.2193071
329						],
330						"location_index": 23,
331						"id": 24,
332						"description": "930 West Avenue 37, Los Angeles, CA 90065, United States"
333					},
334					{
335						"type": "job",
336						"arrival": 1696598028,
337						"duration": 4607,
338						"service": 120,
339						"waiting_time": 2892,
340						"location": [
341							34.06147571,
342							-118.2119934
343						],
344						"location_index": 21,
345						"id": 22,
346						"description": "1201 North Mission Road, Los Angeles, CA 90033, United States"
347					},
348					{
349						"type": "end",
350						"arrival": 1696601040,
351						"duration": 4607,
352						"service": 0,
353						"waiting_time": 0,
354						"location": [
355							34.06147571,
356							-118.2119934
357						],
358						"location_index": 21
359					}
360				],
361				"service": 720,
362				"duration": 4607,
363				"waiting_time": 2892,
364				"priority": 0,
365				"distance": 44744.7,
366				"geometry": "ys}mEffbqU?V[?Q?K?GEKGg@?_@?O?iAAkA@gA?_A@QJ_BAaA?{@A{@??BADcAjDWr@A@??"
367			},
368			{
369				"vehicle": 15,
370				"cost": 145,
371				"steps": [
372					{
373						"type": "start",
374						"arrival": 1696584215,
375						"duration": 0,
376						"service": 0,
377						"waiting_time": 0,
378						"location": [
379							33.908,
380							-118.309
381						],
382						"location_index": 26
383					},
384					{
385						"type": "job",
386						"arrival": 1696584360,
387						"duration": 145,
388						"service": 120,
389						"waiting_time": 0,
390						"location": [
391							33.90365408,
392							-118.3107476
393						],
394						"location_index": 4,
395						"id": 5,
396						"description": "1859 West Rosecrans Avenue, Gardena, CA 90249, United States"
397					},
398					{
399						"type": "end",
400						"arrival": 1696584480,
401						"duration": 145,
402						"service": 0,
403						"waiting_time": 0,
404						"location": [
405							33.90365408,
406							-118.3107476
407						],
408						"location_index": 4
409					}
410				],
411				"service": 120,
412				"duration": 145,
413				"waiting_time": 0,
414				"priority": 0,
415				"distance": 987.3,
416				"geometry": "ys}mEffbqU?Vf@?rA?H?fA@jA?J?\\?\\?V?Z?X?N?d@?p@?X?R?zA?lA?V?T@z@?T?T?d@?H?Z@LHB@P?b@?P?Z?X?X?N?LKT?@~@Cl@@x@?~@?X?h@M?w@?_F?EACE??"
417			},
418			{
419				"vehicle": 8,
420				"cost": 3089,
421				"steps": [
422					{
423						"type": "start",
424						"arrival": 1696598553,
425						"duration": 0,
426						"service": 0,
427						"waiting_time": 0,
428						"location": [
429							33.908,
430							-118.309
431						],
432						"location_index": 26
433					},
434					{
435						"type": "job",
436						"arrival": 1696598940,
437						"duration": 387,
438						"service": 120,
439						"waiting_time": 0,
440						"location": [
441							33.93002508,
442							-118.3037142
443						],
444						"location_index": 14,
445						"id": 15,
446						"description": "1509 West Imperial Highway, Los Angeles, CA 90047, United States"
447					},
448					{
449						"type": "job",
450						"arrival": 1696599294,
451						"duration": 621,
452						"service": 120,
453						"waiting_time": 0,
454						"location": [
455							33.92595279,
456							-118.2962582
457						],
458						"location_index": 10,
459						"id": 11,
460						"description": "11817 South Budlong Avenue, Los Angeles, CA 90044, United States"
461					},
462					{
463						"type": "job",
464						"arrival": 1696599979,
465						"duration": 1186,
466						"service": 120,
467						"waiting_time": 0,
468						"location": [
469							33.96276795,
470							-118.2864459
471						],
472						"location_index": 3,
473						"id": 4,
474						"description": "727 West 84th Street, Los Angeles, CA 90044, United States"
475					},
476					{
477						"type": "job",
478						"arrival": 1696600920,
479						"duration": 2007,
480						"service": 120,
481						"waiting_time": 0,
482						"location": [
483							34.00942629,
484							-118.3184051
485						],
486						"location_index": 13,
487						"id": 14,
488						"description": "4139 Arlington Avenue, Los Angeles, CA 90008, United States"
489					},
490					{
491						"type": "job",
492						"arrival": 1696602122,
493						"duration": 3089,
494						"service": 120,
495						"waiting_time": 0,
496						"location": [
497							34.07865234,
498							-118.334726
499						],
500						"location_index": 19,
501						"id": 20,
502						"description": "6176 Oakwood Avenue, Los Angeles, CA 90004, United States"
503					},
504					{
505						"type": "end",
506						"arrival": 1696602242,
507						"duration": 3089,
508						"service": 0,
509						"waiting_time": 0,
510						"location": [
511							34.07865234,
512							-118.334726
513						],
514						"location_index": 19
515					}
516				],
517				"service": 600,
518				"duration": 3089,
519				"waiting_time": 0,
520				"priority": 0,
521				"distance": 29415.3,
522				"geometry": "ys}mEffbqU?V[?Q?K?GEKGg@?_@?O?iAAkA@gA?_A@QJ_BAaA?{@A{@?WAq@@{@?q@@}ACoGEsE??"
523			},
524			{
525				"vehicle": 24,
526				"cost": 2906,
527				"steps": [
528					{
529						"type": "start",
530						"arrival": 1696584417,
531						"duration": 0,
532						"service": 0,
533						"waiting_time": 0,
534						"location": [
535							33.908,
536							-118.309
537						],
538						"location_index": 26
539					},
540					{
541						"type": "job",
542						"arrival": 1696585666,
543						"duration": 1249,
544						"service": 120,
545						"waiting_time": 0,
546						"location": [
547							33.93384956,
548							-118.1132939
549						],
550						"location_index": 11,
551						"id": 12,
552						"description": "10835 Casanes Avenue, Downey, CA 90241, United States"
553					},
554					{
555						"type": "job",
556						"arrival": 1696586640,
557						"duration": 2103,
558						"service": 120,
559						"waiting_time": 0,
560						"location": [
561							33.98898095,
562							-118.1579664
563						],
564						"location_index": 18,
565						"id": 19,
566						"description": "4593 Alexander Street, Los Angeles, CA 90040, United States"
567					},
568					{
569						"type": "job",
570						"arrival": 1696587563,
571						"duration": 2906,
572						"service": 120,
573						"waiting_time": 1357,
574						"location": [
575							33.975499,
576							-118.2147567
577						],
578						"location_index": 8,
579						"id": 9,
580						"description": "6939 Arbutus Avenue, Huntington Park, CA 90255, United States"
581					},
582					{
583						"type": "end",
584						"arrival": 1696589040,
585						"duration": 2906,
586						"service": 0,
587						"waiting_time": 0,
588						"location": [
589							33.975499,
590							-118.2147567
591						],
592						"location_index": 8
593					}
594				],
595				"service": 360,
596				"duration": 2906,
597				"waiting_time": 1357,
598				"priority": 0,
599				"distance": 42075.2,
600				"geometry": "ys}mEffbqU?V[?Q?K?GEKGg@?_@?O?iAAkA@gA?_A@QJ_BAaA?{@A{@?|ACGzAKxBSdErCApAA??"
601			}
602		]
603	},
604	"status": "Ok",
605	"message": ""
606}

Accessing Optimized Routes in NextBillion.ai’s Optimizer

To visualize and analyze the optimized routes generated by NextBillion's Optimizer, you can use the following URL.

https://playground.nextbillion.ai/optimization-tester?apiKey={{localStorage.values.apiKey}}&requestID={{nbaiOptimizationRun.data.id}}

The above URL will take you to NextBillion's Optimizer interface where you can explore and interact with the optimized route results associated with your specific request ID and API key. This provides a convenient way to gain insights into your optimized routes for enhanced decision-making and resource management.

Get Started
DIDN'T FIND WHAT YOU LOOKING FOR?