Routes
GET /routes/depot/:depot_id
Returns the list of routes for a depot. Each route has his driver and vehicle assigned.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Path parameters:
depot_id(mandatory): The depot ID.
Query string parameters:
date(optional): An ISO8601 date. Default: the date for the last optimized route.
Example response:
[{
"route_id": "<results_routes_id_seq>",
"date": "2019-11-30T00:00:00Z",
"driver_id": "F004RFHT",
"total_distance": 300,
"total_time": 27000,
"category": "rookie",
"start_time": "08:00",
"working_hours": 8,
"lunch_break": 30,
"vehicle": {
"id": "43",
"payload": 600,
"cargo_volume": 2.40,
"type": "H1",
"brand": "Ford",
"model": "Transit",
"plate": "05-D-38104",
"max_speed": 100
}
}]
GET /routes/:route_id
This service returns a GeoJSON with the info of the route
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Path parameters:
route_id(mandatory): The unique route ID.
Query string parameters:
date(optional): An ISO8601 date. Default: the date for the last optimized route.geom_type(optional): Desired geometry type. Options:lines,pointsorall. Default:all. Caveats: lines means delivery routes and points is for delivery stop. Ifallis selected, the delivery's information will be in the point for saving response size.
Example request URL:
/routes/F004RFHT
Example request URL:
/routes/F004RFHT?date=2018-04-30
Example GeoJSON response:
{
"type": "FeatureCollection",
"properties": {
"depot_id": "2",
"route_id": "D2R14213",
"distance": 148.3,
"estimated_time": 6.4,
"break_time": 30,
"deliveries": 2,
"vehicle_id": "46",
"start_time": "2018-04-30T06:00:00Z"
},
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
-6.241607666015625,
53.40707596167943
],
[
-6.295166015625,
53.40871323837144
],
[
-6.361083984374999,
53.38496655811501
],
[
-6.384429931640624,
53.357928353175346
],
[
-6.376190185546874,
53.32513175791219
]
]
]
},
"properties": {
"sequence": 1,
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-6.376190185546874,
53.32513175791219
]
},
"properties": {
"sequence": 1,
"stops": [
{
"delivery_point_id": "3737FTSO",
"phone": "086 1234567",
"name": "John McClane",
"email": "john@broccoli.com",
"address_1": "address1",
"address_2": "address2",
"town": "Madrid",
"county": "Madrid",
"postal_code": null,
"service_time": "240",
"eta": "2018-04-30T12:50:00Z",
"deliveries": [
{
"id": "32205731",
"after_time": "11:30:00Z",
"before_time": null
},
{
"id": "32205799",
"after_time": null,
"before_time": "14:00:00Z"
}
]
}
]
}
},
{
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
-6.373014450073242,
53.32395266070672
],
[
-6.386575698852539,
53.33707468837724
],
[
-6.387777328491211,
53.3419431640244
],
[
-6.386661529541016,
53.34752841457297
],
[
-6.405544281005859,
53.34860438796217
],
[
-6.408634185791016,
53.34875809622955
],
[
-6.408805847167968,
53.34640117522908
]
]
]
},
"properties": {
"sequence": 2
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-6.408805847167968,
53.34640117522908
]
},
"properties": {
"sequence": 2,
"stops": [
{
"delivery_point_id": "8471POEUZ",
"phone": "086 1234567",
"name": "Lucy Gennaro",
"email": "lucy@broccoli.com",
"address_1": "Hill Business",
"address_2": "Complex Road 23",
"town": "Town",
"county": "Madrid",
"postal_code": null,
"service_time": "120",
"eta": "2018-04-30T14:12:00Z",
"deliveries": [
{
"id": "32205794",
"after_time": null,
"before_time": "17:00:00Z"
}
]
},
{
"delivery_point_id": "8471POEUZ",
"phone": "086 1234567",
"name": "Al Powell",
"email": "al@broccoli.com",
"address_1": "Hill Business",
"address_2": "Complex Road 23",
"town": "Town",
"county": "Madrid",
"postal_code": null,
"service_time": "180",
"eta": "2018-04-30T14:12:00Z",
"deliveries": [
{
"id": "32217795",
"after_time": null,
"before_time": null
}
]
}
]
}
}
]
}
GET /routes/depot/:depot_id/drivers
DEPRECATED
This service returns the list of drivers' IDs involved in the depot.
In order to fetch all the routes for a single depot you need to:
- Fetch all the drivers involved at the optimization with this service.
- Do a request to
/routes/driver/:driver_idper each driver obtained at step 1.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Path parameters:
depot_id(mandatory): The unique depot ID.
Query string parameters:
date(optional): An ISO8601 date. Default: the date for the last optimized route.
Example request URL:
/routes/depot/2
Example request URL:
/routes/depot/2?date=2018-01-30
Example response:
["F004RFHT", "D02JBYRNE", "D02PBELMONT"]
GET /routes/driver/:driver_id
DEPRECATED
This service returns a GeoJSON with the delivery routes and/or delivery stops for a driver in a given date.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Path parameters:
driver_id(mandatory): The unique driver ID.
Query string parameters:
date(optional): An ISO8601 date. Default: the date for the last optimized route.geom_type(optional): Desired geometry type. Options:lines,pointsorall. Default:all. Caveats: lines means delivery routes and points is for delivery stop. Ifallis selected, the delivery's information will be in the point for saving response size.
Example request URL:
/routes/driver/F004RFHT
Example request URL:
/routes/driver/F004RFHT?date=2018-04-30
Example GeoJSON response:
{
"type": "FeatureCollection",
"properties": {
"depot_id": "2",
"route_id": "D2R14213",
"distance": 148.3,
"estimated_time": 6.4,
"break_time": 30,
"deliveries": 2,
"vehicle_id": "46",
"start_time": "2018-04-30T06:00:00Z"
},
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
-6.241607666015625,
53.40707596167943
],
[
-6.295166015625,
53.40871323837144
],
[
-6.361083984374999,
53.38496655811501
],
[
-6.384429931640624,
53.357928353175346
],
[
-6.376190185546874,
53.32513175791219
]
]
]
},
"properties": {
"sequence": 1,
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-6.376190185546874,
53.32513175791219
]
},
"properties": {
"sequence": 1,
"stops": [
{
"delivery_point_id": "3737FTSO",
"phone": "086 1234567",
"name": "John McClane",
"email": "john@broccoli.com",
"address_1": "address1",
"address_2": "address2",
"town": "Madrid",
"county": "Madrid",
"postal_code": null,
"service_time": "240",
"eta": "2018-04-30T12:50:00Z",
"deliveries": [
{
"id": "32205731",
"after_time": "11:30:00Z",
"before_time": null
},
{
"id": "32205799",
"after_time": null,
"before_time": "14:00:00Z"
}
]
}
]
}
},
{
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
-6.373014450073242,
53.32395266070672
],
[
-6.386575698852539,
53.33707468837724
],
[
-6.387777328491211,
53.3419431640244
],
[
-6.386661529541016,
53.34752841457297
],
[
-6.405544281005859,
53.34860438796217
],
[
-6.408634185791016,
53.34875809622955
],
[
-6.408805847167968,
53.34640117522908
]
]
]
},
"properties": {
"sequence": 2
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-6.408805847167968,
53.34640117522908
]
},
"properties": {
"sequence": 2,
"stops": [
{
"delivery_point_id": "8471POEUZ",
"phone": "086 1234567",
"name": "Lucy Gennaro",
"email": "lucy@broccoli.com",
"address_1": "Hill Business",
"address_2": "Complex Road 23",
"town": "Town",
"county": "Madrid",
"postal_code": null,
"service_time": "120",
"eta": "2018-04-30T14:12:00Z",
"deliveries": [
{
"id": "32205794",
"after_time": null,
"before_time": "17:00:00Z"
}
]
},
{
"delivery_point_id": "8471POEUZ",
"phone": "086 1234567",
"name": "Al Powell",
"email": "al@broccoli.com",
"address_1": "Hill Business",
"address_2": "Complex Road 23",
"town": "Town",
"county": "Madrid",
"postal_code": null,
"service_time": "180",
"eta": "2018-04-30T14:12:00Z",
"deliveries": [
{
"id": "32217795",
"after_time": null,
"before_time": null
}
]
}
]
}
}
]
}
UPDATE /routes/:route_id/edit
This service updates a route adding new deliveries or removing them, creating a job in the optimization engine for calculating the resulting route. The response of this service is an object with information of that job. Also, when the job is complete, the service will notify the configured clients through a HTTP request.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Path parameters:
route_id(mandatory): The unique route ID.
Body parameters:
new_deliveries(mandatory): An array, can be empty, with the objects of the new deliveries to add. Each object is like:id(mandatory): The unique delivery number.delivery_point_id(mandatory). unique delivery point unique identifier.customer_phone(optional).customer_name(optional).customer_email(optional).address_1(*1).address_2(*1).town(*1).county(*1).postal_code(*1).lat(*2).lng(*2).service_time(optional): Seconds of service time.after_time(optional): The beginning of the time window. The format is an ISO8601 without date.before_time(optional): The ending of the time window. The format is an ISO8601 without date.remove_deliveries(mandatory): An array, can be empty, with the IDs as integers of the deliveries to remove.
Body parameters caveats:
A delivery without (*1) parameters needs all the (*2) ones, lat and lng, and vice versa. But the optimal behaviour is having both, (*1) and (*2).
Example request URL:
/routes/D2R14213/edit
Example body:
{
"new_deliveries": [
{
"id": "32205734",
"delivery_point_id": "3737FTSO",
"customer_phone": "086 1234567",
"customer_name": "John McClane",
"customer_email": "john@broccoli.com",
"address_1": "Airton Road",
"address_2": "Sarsfield House",
"town": "Town",
"county": "Madrid",
"postal_code": "null",
"lat": 53.294914,
"lng": -6.36592,
"service_time": null,
"after_time": null,
"before_time": "17:00:00Z"
}
],
"remove_deliveries": [
"32205794"
]
}
Example response:
{
"job_id": "95bbad3f-9678-4d35-abc9-d1acfd285a9d",
"created_at": "2018-01-30T10:26:42.285Z",
"updated_at": "2018-01-30T10:26:42.285Z",
"status": "pending"
}
GET /routes/job/:job_id
This service returns the status of a created job. Its possible statuses are:
pending: Job waiting to be executed.running: Indicates that the job is currently running.done: Job executed successfully.failed: Job executed but failed.
When the status of the job is done, the route with the new stop can be requested.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Path parameters:
job_id(mandatory): The unique job ID.
Example request URL:
/routes/job/95bbad3f-9678-4d35-abc9-d1acfd285a9d
Example response:
{
"job_id": "95bbad3f-9678-4d35-abc9-d1acfd285a9d",
"created_at": "2018-01-30T10:26:42.285Z",
"updated_at": "2018-01-30T10:28:33.021Z",
"status": "done"
}
GET /routes/depots
This service returns the status of all depots for each launch date.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Query parameters:
start(optional): Start timefinish(optional): Finish timedepots(optional): comma separated list of depots ids to filter.status(optional): comma separated list of statuses to filter: pending|running|completed|error.search(optional): text string to filter by depot name.page(optional): page number to fetch. Default to 0 (first page).page_size(optional): page size. Default to 20, maximum allowed value to 250.
Example response:
[{
"day": "2018-01-01",
"depot_id": 1,
"depot_name": "South",
"start": "2018-01-01T00:30:00:00Z",
"finish": "2018-01-01T00:40:00:00Z",
"status": "completed"
},
{
"day": "2018-01-01",
"depot_id": 2,
"depot_name": "South",
"status": "pending"
},
{
"day": "2018-01-01",
"depot_id": 2,
"depot_name": "South",
"status": "running",
"start": "2018-01-01T00:35:00:00Z"
},
{
"day": "2018-01-01",
"depot_id": 3,
"depot_name": "South",
"start": "2018-01-01T00:30:00:00Z",
"finish": "2018-01-01T00:40:00:00Z",
"status": "error",
"error_msg": "Error"
}]
POST /routes/matrix
This service computes the cost matrix for a set of coordinates. Cost matrix is 2D array with the following information by row:
- id_orig (integer): identifier for origin coordinates.
- id_dest (integer): identifier for destination coordinates.
- time (float): seconds from origin to destination.
- distance (float): meters from origin to destination.
Headers parameters:
Authorization(mandatory): User's token asBearer <token>.
Example body:
{
"coordinates": [
[<id>, <longitude>, <latitude>]
]
}
Example response:
[
[<id_orig>, <id_dest>, <time>, <distance>]
]