These docs are for v1.7.0. Click to read the latest docs for v1.11.

This will get you on the road in no time.

Send our API the addresses of your visits and your fleet. We will return the optimal allocation and order in which you should visit them. Simple and straightforward!

The following is a tiny example of one vehicle and three visits in Vancouver.

curl https://routific.com/demo.json | \
curl https://api.routific.com/v1/vrp \
      -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1MzEzZDZiYTNiMDBkMzA4MDA2ZTliOGEiLCJpYXQiOjEzOTM4MDkwODJ9.PR5qTHsqPogeIIe0NyH2oheaGR-SJXDsxPTcUQNq90E" \
      -d @-
var request = require('request');
var data = require('demo.json');
var options = {
    url: 'https://api.routific.com/v1/vrp',
    json: data,
    headers: {
        'Authorization': 'bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1MzEzZDZiYTNiMDBkMzA4MDA2ZTliOGEiLCJpYXQiOjEzOTM4MDkwODJ9.PR5qTHsqPogeIIe0NyH2oheaGR-SJXDsxPTcUQNq90E'
    }
};
function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        // ... Do stuff
        console.log(body);
    }
    else {
        // ... Handle error
        console.log(response.statusCode + ': ' + body.error);
    }
}
request.post(options, callback);
# gem install routific

require 'routific'
require 'json'

# Fetch the demo data and parse it to JSON
# https://routific.com/demo.json
file = File.read 'demo.json'
data = JSON.parse file

# Set the Routific API token
demo_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1MzEzZDZiYTNiMDBkMzA4MDA2ZTliOGEiLCJpYXQiOjEzOTM4MDkwODJ9.PR5qTHsqPogeIIe0NyH2oheaGR-SJXDsxPTcUQNq90E'
Routific.set_token demo_token 

# Instantiate a new Routific instance
routific = Routific.new

# Set the visits
data["visits"].each do |id, visit|
  routific.set_visit id, visit
end

# Set the fleet
data["fleet"].each do |id, vehicle|
  routific.set_vehicle id, vehicle
end

# Get the route
route = routific.get_route

This example is populated with a demo token, so you can copy and paste the above for a working example. Sign up for an account to get your API access token.

The contents of the JSON input and output are shown to the right.

👍

Time formats

All examples in this documentation uses the hh:mm time formats with a 24-hour military notation. Our API also supports UNIX times, which would make dealing with routing across multiple timezones easier.

UNIX time values are defined as number of seconds since epoch time in UTC (00:00:00, January 1st, 1970).

When the input uses UNIX time formats, the output will also returned in UNIX time. When the input is in hh:mm format, so will the output.

{
  "visits": {
    "order_1": {
      "location": {
        "name": "6800 Cambie",
        "lat": 49.227107,
        "lng": -123.1163085
      },
      "start": "9:00",
      "end": "12:00",
      "duration": 10
    },
    "order_2": {
      "location": {
        "name": "3780 Arbutus",
        "lat": 49.2474624,
        "lng": -123.1532338
      },
      "start": "9:00",
      "end": "12:00",
      "duration": 10
    },
    "order_3": {
      "location": {
        "name": "800 Robson",
        "lat": 49.2819229,
        "lng": -123.1211844
      },
      "start": "8:00",
      "end": "9:00",
      "duration": 10
    }
  },
  "fleet": {
    "vehicle_1": {
      "start_location": {
        "id": "depot",
        "name": "800 Kingsway",
        "lat": 49.2553636,
        "lng": -123.0873365
      },
      "end_location": {
        "id": "depot",
        "name": "800 Kingsway",
        "lat": 49.2553636,
        "lng": -123.0873365
      },
      "shift_start": "8:00",
      "shift_end": "12:00"
    }
  }
}
{
  "status": "success",
  "total_travel_time": 31.983334,
  "total_idle_time": 0,
  "num_unserved": 0,
  "unserved": null,
  "solution": {
    "vehicle_1": [
      {
        "location_id": "depot",
        "location_name": "800 Kingsway",
        "arrival_time": "08:00"
      },
      {
        "location_id": "order_3",
        "location_name": "800 Robson",
        "arrival_time": "08:10",
        "finish_time": "08:20"
      },
      {
        "location_id": "order_2",
        "location_name": "3780 Arbutus",
        "arrival_time": "08:29",
        "finish_time": "09:10"
      },
      {
        "location_id": "order_1",
        "location_name": "6800 Cambie",
        "arrival_time": "09:19",
        "finish_time": "09:29"
      },
      {
        "location_id": "depot",
        "location_name": "800 Kingsway",
        "arrival_time": "09:39"
      }
    ]
  }
}