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

  • 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
  • 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{
2 "totalCount": 46,
3 "data": {
4 "vehicles": "[...]"
5 }
6}

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:

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

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

docs-image

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.

docs-image

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 = [];

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 = [];

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{
3 "result": {
4 "code": 0,
5 "summary": "{...}",
6 "unassigned": "[...]",
7 "routes": "[...]"
8 },
9 "status": "Ok",
10 "message": ""
11}

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.

1https://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.

docs-image