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.

  • 该API需要使用基本身份验证的用户名和密码通过HTTPS. 注册您的帐户。: https://www.routexl.nl/register
  • 位置必须纬度和经度坐标. API不提供地址的地理编码.
  • 每个请求的位置的最大数目是10. 升级 在公共网站上您的帐户,相应地增加最大.
  • The number of allowed requests per day is “;unlimited”; (合理使用政策), 但你可以在同一时间做只有一个呼叫.
  • 提供的API原样, 没有任何形式的担保或保证, 并仍在积极发展. 我们不建议在高调的生产环境中的使用.

概观

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 of API server, its load and the load of the solvers.

输入

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

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

产量

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距离

Create a distance matrix for locations.

输入

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

产量

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

输入

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

产量

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



响应

The API may respond with the following HTTP status codes:

  • 401: 身份验证问题
  • 403: 您的订阅太多的地方
  • 409: 没有输入或没有找到位置
  • 429: 正在进行中的另一条路线
  • 204: 没有距离矩阵, 旅游或路由被发现

例子

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