Vehicle Trips
Action: "get_vehicle_trips"
Use this API to fetch vehicle trips. The API will respond with completed trips and current trip if there is a current trip for the vehicle.
The active trip will be missing the end time and location.
Request Parameters:
| Parameter Name | Type | Mandatory/Optional/Conditional | Description |
|---|---|---|---|
| vehicle_id | bigint | Conditional | Traffilog unique vehicle id. At least one of the following inputs need to be provided:’vehicle_id’/’license_number’/’driver_id’ |
| license_number | string | Conditional | Vehicle license number. At least one of the following inputs need to be provided:’vehicle_id’/’license_number’/’driver_id’. |
| driver_id | bigint | Conditional | Fetch the trips for a specific driver. If only driver id is provided the response may include trips of more than 1 vehicle. If driver id is provided together with vehicle_id or license_number the response will only includes trip for this vehicle with the driver id. |
| from_date | DATE | Optional | Start date. if no date is provided the response will include the trips for the current day. Format :YYYY-MM-DD |
| to_date | DATE | Optional | END date. If no date is provided the response will include the trips for the current day. Format :YYYY-MM-DD |
Request Example:
Example for a request for specific license and date range
{
"action": {
"name": "get\_vehicle\_trips",
"parameters": \[{
"vehicle\_id": "-1",
"license\_number": "1017119",
"from\_date": "2016-12-27",
"to\_date": "2016-12-28"
}\],
"session\_token": "<<session token>>"
}
}
Example for a request for specific vehicle id with no date range provided
{
"action": {
"name": "get\_vehicle\_trips",
"parameters": \[{
"vehicle\_id": "134535",
"license\_number": "",
"from\_date": "",
"to\_date": ""
}\],
"session\_token": "<<session token>>"
}
}
Response Parameters:
| Parameter Name | Type | Occurrences | Description |
|---|---|---|---|
| vehicle_id | big integer | 1..1 | Traffilog unique id for the vehicle |
| license_number | string | 1..1 | Vehicle license number |
| driver_id | big integer | 0..1 | Driver id , will be provided only if a driver was authenticated |
| start_time | DateTime | 1..1 | Trip start time YYYY-MM-DDTHH:MM:SS |
| end_time | DateTime | 1..1 | Trip end time YYYY-MM-DDTHH:MM:SS |
| start_location | string | 0..1 | Start location of the trip |
| end_location | string | 0..1 | End location of the trip |
| drive_id | big integer | 1..1 | Traffilog unique drive id |
| distance | real | 0..1 | Trip total distance |
| start_latitude | real | 1..1 | |
| start_longitude | real | 1..1 | |
| end_latitude | real | 1..1 | |
| end_longitude | real | 1..1 |
Response Example:
{
"response": {
"properties": {
"action\_name": "get\_vehicle\_trips",
"data": \[{
"vehicle\_id": "134535",
"license\_number": "123RTR56",
"driver\_id": "",
"start\_time": "2016-12-27T17:12:26",
"end\_time": "2016-12-27T17:16:46",
"start\_location": "Hyldegårdsvej 11D, 23 Charlottenlund, Denmark",
"end\_location": "Rosavej 1A, 2930 Klampenborg, Denmark",
"drive\_id": "111222333",
"distance": "01.77",
"start\_latitude": "55.7610283",
"start\_longtitude": "12.5758896",
"end\_latitude": "55.7664948",
"end\_longtitude": "12.5939608"
}, {
"vehicle\_id": "134535",
"driver\_id": "",
"start\_time": "2016-12-27T17:38:55",
"end\_time": "2016-12-27T17:39:56",
"start\_location": "Emiliekildevej 25, Klampenborg, Denmark",
"end\_location": "Emiliekildevej 13B, Klampenborg, Denmark",
"drive\_id": "1423",
"distance": "00.24",
"start\_latitude": "55.7688713",
"start\_longtitude": "12.5903263",
"end\_latitude": "55.7698326",
"end\_longtitude": "12.5928764"
}\],
"action\_value": "0",
"description": "",
"session\_token": "4c6f65c3eeb347434273054197"
}
}
}
Action Values:
| action_value | description |
|---|---|
| 0 | success |
| 1 | Inputs parameters are not valid. one of the mandatory/conditional inputs was not provided. |
| 2 | The User not allowed for the vehicle/driver or no such vehicle/driver. |
| 999 | general error |