Trip statistics and distance
This API provides information about mileage, trips, and parkings of a vehicle for a specified time period.
How to get data
Method
GET
Request address
To get the data, use the address: https://<server_address>/api/api.php?
Request parameters
-
cmd=distance — API command to get mileage data
-
imei — unique identifier of the vehicle/device
-
start — start time of data collection (Unix timestamp)
-
stop — end time of data collection (Unix timestamp)
-
node — node number where the command should be executed
Example request
https://<server_address>/api/api.php?cmd=distance&imei=7157153151020&start=1676926800&stop=1677013200&node=1
|
Response
{
"code":0,
"msg":"OK",
"distance":{
"duration":48513,
"length":637.3039,
"parking_time":11548,
"parking_count":11,
"max_speed":96,
"avg_speed":66,
"trips_cnt":1,
"trips_ts":1676964676,
"trips_te":1677013189,
"parkings":[
{"agent_id":36830,"ts":1676964691,"te":1676965159,"lat":"59.807117","lon":"30.16806","length":"0.055916477"},
{"agent_id":36830,"ts":1676965990,"te":1676966589,"lat":"59.808876","lon":"30.167131","length":"6.7342625"}
],
"tracks":[],
"trips_time":48513,
"trips_driving":36965,
"startlat":"59.806779",
"startlon":"30.167737",
"stoplat":"56.258973",
"stoplon":"36.862156"
}
}
|
In response to the API request, the following is returned:
-
code — result code (0 = success, other values = error)
-
msg — server message
-
distance — object containing trip and mileage data:
-
length — total mileage (km)
-
duration — duration from the start of the first trip to the end of the last trip (seconds)
-
trips_cnt — number of trips
-
trips_ts — start time of the first trip (Unix timestamp)
-
trips_te — end time of the last trip (Unix timestamp)
-
trips_time — total trip time (seconds)
-
trips_driving — driving time without stops (seconds)
-
max_speed — maximum speed (km/h)
-
avg_speed — average speed (km/h)
-
parking_count — number of parkings
-
parking_time — total parking duration (seconds)
-
parkings — array of parking details:
-
agent_id — agent identifier
-
ts — parking start time (Unix timestamp)
-
te — parking end time (Unix timestamp)
-
lat — parking latitude
-
lon — parking longitude
-
length — parking distance (km)
-
tracks — array of trip tracks (if available)
-
startlat, startlon — coordinates of the start of the first trip
-
stoplat, stoplon — coordinates of the end of the last trip