Routing API: Optimize Daily Routes

Comments Comments Off by MobileIQ on June 8, 2015

This allows 3rd party applications to use Headlight to optimize daily routes and retrieve the results. The billing system, CRM or driver handheld devices can be updated with the optimized routes before the routes are run in the morning.

It’s a convenient way to automate the process of optimizing routes every day.

Endpoint

The endpoint is https://applications.gomobileiq.com/routes/optimize

Parameters Default Description
key Headlight API Key
date today Scheduled delivery date in yyyymmdd format
optimize false If optimize=false, the scheduled deliveries will be returned without any changes. If optimize=true, the routes will be optimized
sequence_start 1 Starting sequence number for the optimized routes
sequence_increment 1 Increment for sequence numbers after the starting sequence number
filename Name of output file in CSV format which will be saved in the Headlight Dropbox

API Key

The unique API key for your Headlight accounts can be found under Setup | API Key.
api_key

Example URL

This will return all deliveries scheduled for Jan. 6, 2017 without optimizing the routes.

https://applications.gomobileiq.com/routes/optimize?key=a31817854f6ef8477fb139d860ab315b0f8aba54&date=20170106

Example PHP script

// This will optimize all deliveries scheduled for Jan. 6, 2017
// and save the results to the Headlight Dropbox.

$url = 'https://applications.gomobileiq.com/routes/optimize';
$key = 'a31817854f6ef8477fb139d860ab315b0f8aba54';
$date = '20170106';
$optimize = true;
$filename = $date . '_optimized_routes.csv';

$curl_data = array(
	'key' 	  => $key,
	'date'	  => $date,
        'optimize'   => $optimize,
	'filename'   => $filename,
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($curl_data));
curl_exec($handle);

Example JSON output

{
   "success":true,
   "results":"",
   "optimized_routes":[
      {
         "id":"MIQ-A",
         "stops":5,
         "route":[
            {
               "id":"130465",
               "start":"MIQ",
               "route":"A",
               "day":"1",
               "sequence":"1"
            },
            {
               "id":"130458",
               "start":"MIQ",
               "route":"A",
               "day":"1",
               "sequence":"2"
            },
            {
               "id":"130457",
               "start":"MIQ",
               "route":"A",
               "day":"1",
               "sequence":"3"
            },
            {
               "id":"130467",
               "start":"MIQ",
               "route":"A",
               "day":"1",
               "sequence":"4"
            },
            {
               "id":"130466",
               "start":"MIQ",
               "route":"A",
               "day":"1",
               "sequence":"5"
            }
         ]
      }
   ]
}

Tags:

Comments are closed.