Skip to main content

Receiving Events

Use this method to interact with SmartRoad events.

Request information

The external client must initiate a request to the API_GLOSAV_EVENTS database function to receive events. A request for data must be made as follows:

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

Description of additional (optional) request address parameters

ParameterParameter typeDescription
namestringDetector name. You can specify multiple names, separated by commas without spaces: "name_1", "name 5", "name-9". DEPRECATED - undesired parameter
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
from
to
stringDefines 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)
intervalintHow many last seconds to select events for? The default value is 300 seconds. It does not matter if the from and to parameters are specified.
project_idstringRequired parameter. ID of the project for whose detectors you want to obtain statistics.
sensor_idstringUnique detector identifier. It is allowed to specify multiple identifiers separated by commas.
RECOMMENDED
  • Request data every N seconds, since the event coordinates may change (the X and Y coordinates of the event may change if the object moves while the event is being recorded);

  • View already registered events, since after the event expires, its end_time parameter – the end time of the event – can be updated.

Receiving data

When a correct request is received, the System generates a response message in JSON format. By default, (if additional parameters are not specified in the request address), the generated message contains data on events for the last 300 seconds.

Examples of response messages:

  1. Example 1: Object in scope
{
"message_id": "839jfd70-f4kb-0be2-7l1f-1n6y1t3eb7e5",
"time_zone": "Europe/Moscow",
"message_data": [
{
"sensor_id": "2cg1gec8-rf1t-4eqc-8re8-18eg8a6g68h0",
"name": "Test",
"connected": "false",
"lane_direction": [
0,
0,
0,
1,
1,
1
],
"data": [
{
"row": 1,
"events_id": "962635c9-12ad-4e8e-ae9b-860df642733d",
"sensor_id": "2cg1gec8-rf1t-4eqc-8re8-18eg8a6g68h0680b",
"projects_id": "fcff27v4-cqe4-4gdm-8eg1-na1a1d0sdav1",
"start_time": "2024-10-28T10:37:38.639383+03:00",
"end_time": "2024-10-28T10:37:38.639383+03:00",
"type": 1,
"level": 0,
"code": 509,
"description": [
{
"lang": "ru",
"name": "Мд"
},
{
"lang": "en",
"name": "Snail"
},
{
"lang": "es",
"name": "Caracol"
}
],
"unit": "LOW_SPEED",
"val": "24.30",
"measure_line": null,
"lane": 0,
"zone": 0,
"direction": -1,
"obj_id": 102,
"obj_class": 1,
"obj_length": 4.5,
"obj_speed": 24.3,
"heading": 179.39,
"point_x": 56.88,
"point_y": -9.12,
"close_type": 0,
"param_data": null
}
]
}
]
}
  1. Example 2: Misdirection
{
"row": 23,
"events_id": "09ca6b2b-1824-4d3b-8ec8-d3f2f63b72ba",
"sensor_id": "37d9eb0c-0b8c-4af8-90c7-f95a0355a903",
"projects_id": "9d2ce49d-eea9-4210-ad65-49d1ee62d6ca",
"start_time": "2024-03-06T13:08:49.9+00:00",
"end_time": "2024-03-06T13:08:49.9+00:00",
"type": 2,
"level": 0,
"code": 2001,
"description": [
{
"lang": "ru",
"name": "Wrong direction"
},
{
"long": "and",
"name": "wrong direction"
},
{
"long": "it",
"name": "wrong direction"
}
],
"unit": "WWD",
"val": "-3.222486",
"measure_line": null,
"lane": 3,
"zone": 0,
"direction": 0,
"obj_id": 35,
"obj_class": 1,
"obj_length": 4.5,
"obj_speed": 7.96,
"heading": -3.22,
"point_x": 78.27,
"point_y": 0.08,
"close_type": 0
}

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
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. The numbers in the array are transmitted in the order of the stripes, counting from the leftmost one
dataarrayNested data array
rowintResponse line number
events_idstringEvent ID
sensor_idstringDetector identifier
projects_idstringThe project identifier
start_timestringEvent start time and date, in ISO 8601 format (0000-00-00T00:00:00+00:00)
end_timestringEvent end time and date, in ISO 8601 format format (0000-00-00T00:00:00+00:00)
typeintEvent type. Possible values:
- 1 – Speed events
- 2 – Traffic events
- 9 – Others events
Corresponds to the event rule settings in the System
levelintEvent category. Possible values:
- 0 – Information event
- 1 – Warning event
- 2 – Critical event
Corresponds to the event rule settings in the System
codeintEvent code. Event codes are specified by the user when creating events. Changing the event code on the System does not affect events recorded before the change
descriptionarrayA nested array containing the event name in Russian, English and Spanish. Parameters passed in the array:
- lang – language
- name – event name
unitstringA unit of measurement. Possible values:
- KMH – Kilometers per hour
- MPS - Meters per second
- PEDESTRIAN – Pedestrian detected
- PLACE – Object in the area of definition
- STOP – Stopping the vehicle
- WWD - Wrong Direction
valfloating point numberEvent parameter value. For logical events - 1, for measurable events - the corresponding numerical value. For example, for speeding, the first measured numeric value that satisfies the event rule
measure_linestringAlways null
laneintLane number, counted starting from zero, from left to right
zoneintIndex of the zone through which an object becomes a PVR. Zones are created in Road Management section
directionintLane direction:
- -1: to detector
- 1: from detector
- 0: both ways
obj_idintObject ID. Detectors track objects by assigning numbers to them from the moment the object is identified in the visibility area until it leaves it. The pool of numbers is rotated cyclically
obj_classintObject class number, according to user-specified classification. Class numbering starts from 0. If the detector could not determine the vehicle class, then the value is set to -1
obj_lengthintLength of the object in meters. The value is used to determine the class of the object
obj_speedintObject speed in km/h
headingintDirection of movement (angle of movement to the detector in °)
point_xintDistance in meters along the X axis
point_yintY axis distance in meters
close_typeintClosure type:
- 0 – Automatic
- 1 – Manual
- NULL – Not closed