Routing API: Optimize Daily Routes

Comments Comments Off on Routing API: Optimize Daily Routes by 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 Description
key Headlight API Key. Required parameter.
optimize If optimize=false, the scheduled deliveries will be returned without any changes. If optimize=true, the routes will be optimized and changes saved to the Headlight database. Optional parameter (default:true)
date Scheduled delivery date in yyyy-mm-dd format (e.g. ). Optional parameter (default:today)
vehicle Apply optimization to a specific vehicle id (e.g. vehicle=1-1) where {‘start’ : ‘1’, ‘route’ : ‘1’). Optional parameter (default:optimize all vehicle ids for specified date)
sequence_start Starting sequence number for the optimized routes. Optional parameter (default:1)
sequence_increment Increment sequence numbers after the starting sequence number. Optional parameter (default:1)
filename Name of optimized routes file saved to the Headlight Dropbox (.csv format). Optional parameter (default: )

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.