RouteXL API

The RouteXL API provides programmatic access to optimize multiple stop itineraries. Upload locations, get distance tables and the optimized order of stops. In the route optimization time windows are supported. Responses are in JSON.

  • The API requires username and password using Basic Authentication over HTTPS. Register your account at: https://www.routexl.com/register
  • Locations must be latitude and longitude coordinates. The API does not provide geocoding of addresses.
  • The maximum number of locations per request is 10. Upgrade your account on the public website to increase the maximum accordingly.
  • The number of allowed requests per day is “unlimited” (fair-use policy), but you can make only one call at a time.
  • The API is provided as-is, without guarantee or warranty of any kind, and is still under active development. We do not advise usage in high-profile production environments.

Overview

Base-URL: https://api.routexl.com/

GET status – gets status of the API
POST distances – creates distances matrix
POST tour – creates new optimized route
Response – HTTP status codes
Examples – cURL & PHP connector class

GET status

Get status of API server, its load and the load of the solvers.

Input

(string) (optional)
String to repeat in the output (for testing purposes).

Example:
https://api.routexl.com/status/Hello+world

Output

id (string)
System name and version

datetime (string)
Timestamp of the server (for testing purposes).

load (integer)
CPU load 0-100 of the API server. String “N/a” if not available.

solver (array)
Array of solvers servers, their name and CPU load 0-100, and the selected solver with the lowest load (for load balancing).

echo (string)
Returns your string (for testing purposes).

max_locations (integer)
The maximum number of locations you are allowed with the username given.

Example:
{"id":"RouteXL API 1.3","datetime":"2015-01-23 10:22:45","load":5,"solvers":{"Server2 live":1000,"WS2611@WBC":75,"Server3@Amazon":35,"selected":{"server":"Server3@Amazon","load":35}},"echo":"Hello world","max_locations":10}

POST distances

Create a distance matrix for locations.

Input

locations (json array)
Array of locations in json. Required fields for each location are the name or address, and its gps coordinates in lat and lng.

maxDistance (integer) (optional)
Maximum distance in meters. If the estimated distance between two points as the crow flies is larger, the leg will not be routed. The API will then estimate a value without actual routing.

Example:
locations=[{"address":"The Hague, The Netherlands","lat":"52.05429","lng":"4.248618"},{"address":"The Hague, The Netherlands","lat":"52.076892","lng":"4.26975"},{"address":"Uden, The Netherlands","lat":"51.669946","lng":"5.61852"},{"address":"Sint-Oedenrode, The Netherlands","lat":"51.589548","lng":"5.432482"}]

Output

count (integer)
The number of locations that were received (for testing).

distances (json array)
Array of distances. Each distance holds the indices of two points, the distance in meters and duration in seconds, and a boolean router. The indicates if the leg is indeed calculated by the router. If not routed, the distance and duration were estimated as the crow flies.

Example:
{"count":4,"distances":{"0":{"from":0,"to":1,"distance":3850,"duration":305,"router":true},"1":{"from":0,"to":2,"distance":134646,"duration":5399,"router":true},"2":{"from":0,"to":3,"distance":128881,"duration":5443,"router":true},"3":{"from":1,"to":2,"distance":133251,"duration":5266,"router":true},"4":{"from":1,"to":3,"distance":127486,"duration":5310,"router":true},"5":{"from":2,"to":1,"distance":134764,"duration":5366,"router":true},"6":{"from":2,"to":3,"distance":23361,"duration":1173,"router":true}},"maxDistance":false,"skipValues":false,"solver":"WS2611@WBC"}



POST tour

Post new set of addresses, creating a new tour. For now, this immediately returns an optimized tour, the fastest route. In future, it wil return the tour ID for CRUD referal.

Input

locations (json array)
Array of locations in json.

Required fields for each location are the name/address, and its gps coordinates in lat/lng. The first element is used as departure, the last as final arrival. If you need to start and finish at the same location, you’ll need to add it twice in the array.

Optionally, each location can have a servicetime, expressed in minutes. This is the waiting or processing time at the location, the time delay between arrival and departure.
Note: if no servicetime is given, the system default of 5 minutes is used.

Optionally, each location can have restrictions. This can be used for time windows and pickup & delivery. Restrictions is an array with optional integers ready, due, before and after:

ready: earliest time the location may be visited (minutes, greater than 0).
due: latest time the location must be visited (minutes, greater than 0).
before: index number of the location that is the delivery point for this location.
after: index number of the location that is the pickup point for this location.

Some notes on restrictions:
– Ready and due times are relative. A route starts at 0 minutes. E.g. if you start driving at 8:00AM and a location needs to be visited before 9:00AM, use due: 60.
– Index numbers for before and after need to be the array index of the locations array, counting from 0. Do not use the name/address field.

skipOptimisation (bool) (optional)
This will prevent the API to optimize the route. The locations are returned in same order as is, but arrival times and cumulative distances are calculated. Note: if you do not want this behaviour, do not set this parameter to false, but just delete it completely from your request.

Example:
locations=[{"address":"The Hague, The Netherlands","lat":"52.05429","lng":"4.248618"},{"address":"The Hague, The Netherlands","lat":"52.076892","lng":"4.26975"},{"address":"Uden, The Netherlands","lat":"51.669946","lng":"5.61852"},{"address":"Sint-Oedenrode, The Netherlands","lat":"51.589548","lng":"5.432482"}]

Output

id (alfanumeric)
The unique ID for the tour that may be used for CRUD referal (in future).

count (integer)
The number of locations that were received (for testing).

feasible (boolean)
Indicates if the restrictions are met. If the route meets all requirements from the input, the route is feasible (true). If one or more restrictions do not hold, the route is not feasible (false). Infeasible routes are unreliable and should not be used.

route (array of waypoints)
The optimized tour holding the fastest route. Waypoints are returned in an array in the optimized order. Start and finish are first and last locations from the input.

Each waypoint returns the name as a string, the arrival time in minutes (integer) and the cumulative distance in kilometers (float).

Note: if skipOptimisation was set true, the route is not optimized. Waypoints are returned in the same order as the input, but the feasibility is checked and both arrival times and cumulative distances are available.

Example:
{"id":"4T4446Pj","count":4,"feasible":true,"route":{"0":{"name":"The Hague, The Netherlands","arrival":0,"distance":0},"1":{"name":"The Hague, The Netherlands","arrival":5,"distance":3.9},"2":{"name":"Uden, The Netherlands","arrival":93,"distance":137.1},"3":{"name":"Sint-Oedenrode, The Netherlands","arrival":112,"distance":160.5}}}



Response

The API may respond with the following HTTP status codes:

  • 401: Authentication problem
  • 403: Too many locations for your subscription
  • 409: No input or no locations found
  • 429: Another route in progress
  • 204: No distance matrix, tour or route was found

Examples

Get an unoptimized route using cURL:

curl \
--url https://api.routexl.com/tour/ \
--user <username>:<password> \
--data 'locations=[{"address":"1","lat":"52.05429","lng":"4.248618"},{"address":"2","lat":"52.076892","lng":"4.26975"},{"address":"3","lat":"51.669946","lng":"5.61852"},{"address":"4","lat":"51.589548","lng":"5.432482"}]&skipOptimisation=true'

There are more examples with code for PHP and Javascript on GitHub, and user contributed C# .NET API Snippets on the support forums.