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.

  • Die API erfordert Benutzernamen und Kennwort mit Standardauthentifizierung über HTTPS. Registrieren Sie Ihr Konto bei: https://www.routexl.nl/register
  • Standorte müssen Breiten- und Längengrade werden. Die API bietet keine Geokodierung von Adressen.
  • Die maximale Anzahl der Stellen pro Anfrage 10. Upgrade Ihr Konto auf der öffentlichen Website die maximale entsprechend erhöhen.
  • The number of allowed requests per day is “;unlimited "; (Fair-Use-Politik), Sie können jedoch nur einen Anruf zu einem Zeitpunkt machen.
  • Die API ist als Service-, ohne Garantie oder Gewährleistung jeglicher Art, und ist immer noch in aktiver Entwicklung. Wir haben nicht den Einsatz in High-Profil Produktionsumgebungen raten.

Überblick

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

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.

Eingang

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

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

Ausgabe

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 Entfernungen

Create a distance matrix for locations.

Eingang

locations (json array)
Array of locations in json. Required fields for each location are the name/address, and its gps coordinates in lat/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 realistic value without actual routing.

skipValues (bool) (optional)
If true, the result will not return the distance matrix itself. This is useful when preparing the API for multiple routes to come later. Distances will be saved in the router cache.

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"}]

Ausgabe

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.

Eingang

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 pickup point for this location.
after: index number of the location that is the delivery 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.

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"}]

Ausgabe

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).

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}}}



Antwort

The API may respond with the following HTTP status codes:

  • 401: Authentifizierungsproblem
  • 403: Zu viele Standorte für Ihr Abonnement
  • 409: Keine Eingabe oder keine Positionen gefunden
  • 429: Ein anderer Weg in Arbeit
  • 204: Kein Distanzmatrix, Tour oder Route gefunden wurde

Beispiele

Get an unoptimized route using cURL:

curl \
--url https://api.routexl.nl/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.