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
Parameter | Parameter type | Description |
---|---|---|
name | string | Detector name. You can specify multiple names, separated by commas without spaces: "name_1", "name 5", "name-9". DEPRECATED - undesired parameter |
time_zone | string | Time 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 | string | 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 | int | How 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_id | string | Required parameter. ID of the project for whose detectors you want to obtain statistics. |
sensor_id | string | Unique detector identifier. It is allowed to specify multiple identifiers separated by commas. |
-
Request data every
N
seconds, since the event coordinates may change (theX
andY
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:
- 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
}
]
}
]
}
- 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
Parameter | Parameter Type | Description |
---|---|---|
message_id | string | Message ID |
time_zone | string | Time 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_data | array | Nested data array |
sensor_id | string | Detector identifier |
name | string | Detector name |
connected | boolean | Detector connection status, possible values: true / false |
lane_direction | Array of integers | Lane 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 |
data | array | Nested data array |
row | int | Response line number |
events_id | string | Event ID |
sensor_id | string | Detector identifier |
projects_id | string | The project identifier |
start_time | string | Event start time and date, in ISO 8601 format (0000-00-00T00:00:00+00:00) |
end_time | string | Event end time and date, in ISO 8601 format format (0000-00-00T00:00:00+00:00) |
type | int | Event type. Possible values: - 1 – Speed events - 2 – Traffic events - 9 – Others events Corresponds to the event rule settings in the System |
level | int | Event category. Possible values: - 0 – Information event - 1 – Warning event - 2 – Critical event Corresponds to the event rule settings in the System |
code | int | Event 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 |
description | array | A nested array containing the event name in Russian, English and Spanish. Parameters passed in the array: - lang – language - nam e – event name |
unit | string | A 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 |
val | floating point number | Event 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_line | string | Always null |
lane | int | Lane number, counted starting from zero, from left to right |
zone | int | Index of the zone through which an object becomes a PVR. Zones are created in Road Management section |
direction | int | Lane direction: - -1 : to detector - 1 : from detector - 0 : both ways |
obj_id | int | Object 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_class | int | Object 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_length | int | Length of the object in meters. The value is used to determine the class of the object |
obj_speed | int | Object speed in km/h |
heading | int | Direction of movement (angle of movement to the detector in °) |
point_x | int | Distance in meters along the X axis |
point_y | int | Y axis distance in meters |
close_type | int | Closure type: - 0 – Automatic - 1 – Manual - NULL – Not closed |