Skip to main content

Statistical data

This function is used for getting information related to statistics

Request information

The external system must initiate a request to the API_SENSOR_STATISTICS database function to obtain statistics data. A request for data must be made as follows:

url_smartroad/api/integration/stat?login=user_login&password=user_password&project_id=project_id

To ensure data filtering, it is allowed to use the additional query parameters listed in next table, which are indicated after writing the & symbol.

Description of additional request address parameters

ParameterParameter typeDescription
from
to
interval
string
string
int
Defines the time period and grouping interval for which the data is requested:
- from – interval start date (inclusive) in ISO 8601 format (YYYY-MM-DD HH:MM: SS)
- to – interval end date (inclusive) in ISO 8601 format (YYYY-MM-DD HH:MM: SS)
- interval – time interval for data grouping, c. If the "interval" parameter is passed in the request, then the value will be used in the calculation. For example, if the value of the interval parameter is 60, then a statistical calculation will be performed for each minute minute of the time range
interval (without from and to)intThe time interval (in seconds) for which historical data is requested, starting from the time of request. The default is 30 seconds.
namestringThe name of the detector from which data is requested. It is allowed to specify multiple names separated by commas. DEPRECATED - undesired parameter
sensor_idstringUnique detector identifier. It is allowed to specify multiple identifiers separated by commas
project_idstringRequired parameter. ID of the project for whose detectors you want to obtain statistics.
time_zonestringTime zone. The recording format is TZ identifiers. Instead of the slash character, you can use the underscore “_”. By default, the parameter value from the user profile is substituted. Example: Europe/Moscow

Receiving data

When a correct request is received, the System generates a response message in JSON format.

Example of a response message:

{
"message_id": "3e3d1708-d6dd-3742-d8c3-c179b99c758f",
"time_zone": "Europe/Moscow",
"excluded_sensors": [
"vr346hdb-fge5-ntsh-vege-dsgvg5467rfh",
"4kgk69vr-nlor-mldy-d4ib-gjypdjmldrtd",
"fwefw56v-f36v-v34l-adqc-dgg536bjk754"
],
"message_data": [
{
"sensor_id": "2ca11ec8-ef1f-4eac-89e8-18ee8b64680b",
"name": "Virtual",
"connected": false,
"lane_direction": [
0,
0

],
"direction": 1,
"data": [
{
"lanes": [
{
"lane": 0,
"volume": 0,
"class_0": 0,
"class_1": 0,
"class_2": 0,
"class_3": 0,
"class_4": 0,
"class_5": 0,
"gap_avg": 0,
"gap_sum": 0,
"speed_avg": 0,
"headway_avg": 0,
"headway_sum": 0,
"speed85_avg": 0,
"occupancy_per": "0000-00-00 00:00:00",
"occupancy_prc": 0,
"occupancy_sum": 0
},
{
"lane": 1,
"volume": 0,
"class_0": 0,
"class_1": 0,
"class_2": 0,
"class_3": 0,
"class_4": 0,
"class_5": 0,
"gap_avg": 0,
"gap_sum": 0,
"speed_avg": 0,
"headway_avg": 0,
"headway_sum": 0,
"speed85_avg": 0,
"occupancy_per": "0000-00-00 00:00:00",
"occupancy_prc": 0,
"occupancy_sum": 0
}
],
"range_end": "2024-10-02T11:37:16+03:00",
"range_start": "2024-10-02T11:36:46+03:00",
"range_value": 1
}
]
}
]
}

Description of response message parameters

ParameterParameter typeDescription
message_idstringMessage ID
time_zonestringTime zone. The recording format is TZ identifiers. Instead of the slash character, you can use the underscore “_”. By default, the parameter value from the user profile is substituted. Example: Europe/Moscow
message_dataarrayNested data array
sensor_idstringDetector identifier
excluded_sensorsstringIdentifiers of detectors for which data cannot be obtained due to incorrect configuration
namestringDetector name
connectedbooleanDetector connection status, possible values: true / false
lane_directionarray of integersLane direction:
- 0 – moving to the zero kilometer of the road;
- 1 – movement from the zero kilometer of the road;
- 2 – two-way traffic.
directionintDetector installation direction:
- 0 - to the zero kilometer of the road
- 1 - from the zero kilometer of the road
dataarrayNested array of elements
lanesarrayNested array of elements
laneintLane number. The stripes are counted starting from zero, from left to right. For TMS.11 series detectors, the band number is not transmitted. Meaning -1 means no parameter value
volumeintNumber of recorded vehicles
class_XintThe number of recorded vehicles of a certain class depending on the length of the vehicle. The number of classes and vehicle length parameters for each class are determined in the System settings
gap_avgintAverage traffic interval for the period, measured between the front bumper of the first vehicle and the rear bumper of the second vehicle, p.
gap_sumintThe final driving interval for the period, measured between the front bumper of the first vehicle and the rear bumper of the second vehicle, p
speed_avgintAverage speed, km/h
headway_avgintAverage traffic interval, measured between the rear bumper of the first vehicle and the rear bumper of the second vehicle, p
headway_sumintThe final driving interval, measured between the rear bumper of the first vehicle and the rear bumper of the second vehicle, p.
speed85_avgintAverage speed of 85% of traffic flow, km/h.
occupancy_perstringLane congestion in a given period, total time
occupancy_prcintLane congestion in a given period, percentage
occupancy_sumintTraffic lane congestion in a given period, s
range_endstringEnd of the interval, in the format 2023-01-26T00:30:00+00:00
range_startstringBeginning of the statistics selection period, in format 2023-01-26T00:30:00+00:00
range_valueintInterval number in range