Skip to content

Quickstart

1. Auth

If you don't have an account already, Sign Up for one or reach out to us at info@tarotanalytics.com

Then, get your Access Token:

auth_req.sh
URL='https://api.route.optimiser.app/api/auth/token'
HEADERS='Content-Type: application/json'
BODY='{
        "email": "your_email_address",
        "password": "your_password"
}'

RESP=$(curl "$URL" -H "$HEADERS" --data "$BODY")

# jq is a command line utility for parsing JSON
# you can install it with `apt install jq` or equivalent.
# The idea is just to get the `access_token` from the JSON response.
TOKEN=$(echo $RESP | jq -r .access_token)
auth_req.py
import requests

url = 'https://api.route.optimiser.app/api/auth/token'
headers = {'Content-Type': 'application/json'}
body = {
    'email': 'your_email_address',
    'password': 'your_password',
}

r = requests.post(url, headers=headers, json=body)

token = r.json()['access_token']

2. Request Body

Second, let's prepare a JSON request body made up of Jobs, Drivers and Settings representing your routing problem:

ex1.json
{
  "drivers": [
    {
      "uid": "drvid1",
      "shift_start": 8,
      "shift_end": 17,
      "start": {"lat": -33.867798, "lon": 151.166256},
      "end": "start"
    }
  ],
  "jobs": [
    {
      "uid": "uid1",
      "duration": 2,
      "location": {"lat": -33.849489, "lon": 151.127482}
    },
    {
      "uid": "uid2",
      "duration": 2,
      "location": {"lat": -33.880661, "lon": 151.183096}
    },
    {
      "uid": "uid3",
      "duration": 2,
      "location": {"lat": -33.913168, "lon": 151.262267}
    }
  ],
  "settings": {}
}
wget https://opt.route.optimiser.app/v2/docs/static/ex1.json

Learn More...

3. Optimise

You can access the Route Optimisation API by sending a POST request to the Synchronous Route Optimisation API endpoint. For longer optimizations, try the Asynchronous Route Optimisation API (Post and Poll pattern).

optimise_req.sh
TOKEN={your_tarot_routing_token}
curl https://opt.route.optimiser.app/v2/vrp \
      -H "Authorization: Bearer $TOKEN" \
      -H "Content-Type: application/json" \
      --data "@ex1.json"
optimise_req.py
import json, requests

token = 'Your Tarot Routing Token'

with open('ex1.json') as f:
   body = json.load(f)

r = requests.post(
   url='https://opt.route.optimiser.app/v2/vrp',
   headers={'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token},
   json=body,
)

Learn More...

4. Response

A few seconds later, you'll receive a response:

resp1.json
{
    "runs": [
        {
            "driver": {
                "uid": "drvid1",
                "shift_start": "08:00:00",
                "shift_end": "17:00:00",
                "run": 1,
                "seq": 0,
                "location": {
                    "lon": 151.166256,
                    "lat": -33.867798
                },
                "end_location": {
                    "lon": 151.166256,
                    "lat": -33.867798
                }
            },
            "jobs": [
                {
                    "uid": "uid1",
                    "duration": 120,
                    "eta": "08:09:45",
                    "etd": "08:11:45",
                    "run": 1,
                    "seq": 1,
                    "location": {
                        "lon": 151.127482,
                        "lat": -33.849489
                    }
                },
                {
                    "uid": "uid2",
                    "duration": 120,
                    "eta": "08:24:12",
                    "etd": "08:26:12",
                    "run": 1,
                    "seq": 2,
                    "location": {
                        "lon": 151.183096,
                        "lat": -33.880661
                    }
                },
                {
                    "uid": "uid3",
                    "duration": 120,
                    "eta": "08:42:32",
                    "etd": "08:44:32",
                    "run": 1,
                    "seq": 3,
                    "location": {
                        "lon": 151.262267,
                        "lat": -33.913168
                    }
                }
            ]
        }
    ],
    "unserved_jobs": []
}

The runs element is a list of Runs. The first Object in each Run is the Driver. All Subsequent objects in that Run are the Jobs.

Any Jobs listed in unserved_jobs were not able to be served with the Drivers provided.

Learn More...

Next Steps

Route Optimisation is complex, but we try to make it as easy as possible to just get to the parts you need!

  1. Have a quick read of Route Optimisation Concepts to get familiar with terminology.
  2. Learn How to Express Constraints to the Route Optimisation API — including multi-shift, pickup delivery, later than, and parking duration.