API

To use APIs you need to get a user key. The latter is an randomly generated alphanumeric value that must be inserted as last part of each API request. You can find your user key by editing your user profile.

Click on the top right image with you user name and select Profile

Profile

Then you will see you profile page, here click on the Edit Profile button.

Profile Page

Fine, you API key is the alphanumeric string in the red box!

Edit Profile Page

For the sake of simplicity, in the following example we will suppose that the key has value "mykey".

If you don't have an API Key ask for a key to the Administration of you AI-DashPRO!

General Information

Name URL Method Parameters Description
Info /dashboard/api/info/key GET Retrieves all the informations about event types, devices and sensors
Name URL Method Description
Devices List /dashboard/api/devices/key GET Retrives the list of all the devices the user is allowed to see

Example Request URL:/dashboard/api/devices/mykey/

Output

{"devices":[{"device_id":"1","device_name":"ai_bio","device_address":"000918530b07","device_address_ip":"195.120.98.134"}, {"device_id":"2","device_name":"ai_heat","device_address":"00166cc2265f","device_address_ip":"195.120.98.134"}, {"device_id":"3","device_name":"ai_people","device_address":"00166cc22654","device_address_ip":"195.120.98.134"}, {"device_id":"4","device_name":"aula_23","device_address":"00166cc60423","device_address_ip":"193.205.162.162"}, {"device_id":"5","device_name":"aula_h_1","device_address":"00166cc6043a","device_address_ip":"193.205.162.162"}, {"device_id":"6","device_name":"aula_h_2","device_address":"00166cc60424","device_address_ip":"193.205.162.162"}, {"device_id":"7","device_name":"aula_h_3","device_address":"00166cb06c2b","device_address_ip":"193.205.162.162"}, {"device_id":"8","device_name":"aula_h_4","device_address":"00166cc6043b","device_address_ip":"193.205.162.162"}, {"device_id":"9","device_name":"aula_h_5","device_address":"00166cc60439","device_address_ip":"193.205.162.162"}, {"device_id":"10","device_name":"aula_h_6","device_address":"00166cc60428","device_address_ip":"193.205.162.162"}]}

Devices

Name URL Method Description
Device Information /dashboard/api/devices/deviceid/key GET Retrives the device with the given id

Example

Request URL:/dashboard/api/devices/1/mykey/

Output

{"device_id":"1","device_name":"ai_bio","device_address":"000918530b07","device_address_ip":"195.120.98.134"}

Sensors

Name URL Method Description
Sensor Information /dashboard/api/devices/deviceid/sensors/key GET Retrives the sensors of the device with the given id

Example

Request URL:/dashboard/api/devices/3/sensors/mykey/

Output

{"sensors":[ {"id_source":"3","sensor_id":182,"sensor_name":"Ingresso","event_type":14,"event_type_name":"Counting","points":[]}, {"id_source":"3","sensor_id":183,"sensor_name":"Uscita","event_type":14,"event_type_name":"Counting","points":[]} ]}
Name URL Method Description
Sensor Information /dashboard/api/devices/deviceid/sensors/sensorid/key GET Retrives the sensors with the given id

Example

Request URL:/dashboard/api/devices/3/sensors/183/mykey/

Output

{"id_source":"3","sensor_id":183,"sensor_name":"Uscita","event_type":14,"event_type_name":"Counting","points":[]}

Events

Name URL Method Description
Events /dashboard/api/devices/deviceid/sensors/sensorid/events/key GET Retrives, single or aggregated event in a given time interval

Example

Request URL:/dashboard/api/devices/3/sensors/183/events/mykey/?queryString

Query String Parameter

Name Type Mandatory Description Allowed Values
type Integer X Event Type Identifier
begin Timestamp Begin Timestamp for the events Unix Timestamp Format
end Timestamp End Timestamp for the events Unix Timestamp Format. If not specified is the current timestamp.
timestamp_format String Output Format of the provided timestamp Unix Timestamp Format (Null or not specified). For aggregated only.
%d/%m/%Y %H:%M
%d/%m/%Y %H:%M:%S
%Y-%m-%d %H:%M:%S
%Y-%m-%dT%H:%M:%S
%Y-%m-%dT%H:%M:%S%z
aggregation_mode String Begin Timestamp for the events "byminute", "byhour", "byday", "bymonth"
aggregation_field String Begin Timestamp for the events Name of the parameter to be used for the aggregation
limit Integer Maximum number of events retrieved (default: 100)
all_events Integer Begin Timestamp for the events
offset Integer Begin Timestamp for the events Offset used for paginated requests

Example: List Events Request

Request URL:/dashboard/api/devices/15/sensors/202/events/mykey/?type=14&all_events

{"events": [{"message": "Sterile_Zone", "event_id": 15640357, "timestamp": 1546431091, "sterile_zone_type": "INTRUSION", "sensor_id": 202, "media_ids": [10794585, 10794586, 10794587, 10794588, 10794589, 10794590, 10794591, 10794592, 10794593, 10794594, 10794595], "event_type": "Sterile_Zone", "description": "Sterile_Zone", "device_id": 15, "media_paths": ["/media/events/corridoio_sede/Corridoio/20190102/121131_2_0.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_1.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_2.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_3.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_4.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_5.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_6.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_7.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_8.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_9.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_10.jpg"]},

{"message": "SterileZone", "eventid": 15640237, "timestamp": 1546431042, "sterilezonetype": "INTRUSION", "sensorid": 202, "mediaids": [10794523, 10794524, 10794525, 10794526, 10794528, 10794529, 10794530, 10794531, 10794532, 10794533], "eventtype": "SterileZone", "description": "SterileZone", "deviceid": 15, "mediapaths": ["/media/events/corridoiosede/Corridoio/20190102/12104220.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104221.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104222.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104223.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104224.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104225.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104226.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104227.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104228.jpg", "/media/events/corridoiosede/Corridoio/20190102/1210422_9.jpg"]}]}

Example: Events List in Time Range

Request URL:/dashboard/api/devices/15/sensors/202/events/mykey/?type=2&begin=1545227434&end=1546431091&all_events

{"events": [{"message": "Sterile_Zone", "event_id": 15640357, "timestamp": 1546431091, "sterile_zone_type": "INTRUSION", "sensor_id": 202, "media_ids": [10794585, 10794586, 10794587, 10794588, 10794589, 10794590, 10794591, 10794592, 10794593, 10794594, 10794595], "event_type": "Sterile_Zone", "description": "Sterile_Zone", "device_id": 15, "media_paths": ["/media/events/corridoio_sede/Corridoio/20190102/121131_2_0.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_1.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_2.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_3.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_4.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_5.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_6.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_7.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_8.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_9.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_10.jpg"]},

{"message": "SterileZone", "eventid": 15640237, "timestamp": 1546431042, "sterilezonetype": "INTRUSION", "sensorid": 202, "mediaids": [10794523, 10794524, 10794525, 10794526, 10794528, 10794529, 10794530, 10794531, 10794532, 10794533], "eventtype": "SterileZone", "description": "SterileZone", "deviceid": 15, "mediapaths": ["/media/events/corridoiosede/Corridoio/20190102/12104220.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104221.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104222.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104223.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104224.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104225.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104226.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104227.jpg", "/media/events/corridoiosede/Corridoio/20190102/12104228.jpg", "/media/events/corridoiosede/Corridoio/20190102/1210422_9.jpg"]}]}

Example: Aggregated Events Requests

Request URL:/dashboard/api/devices/15/sensors/202/events/mykey/?type=2&begin=1545227434&end=1546431091&aggregationmode=byhour

{"timeslots": [{"aggregated_value": {"all": 4}, "timestamp": 1546430400}, {"aggregated_value": {"all": 26}, "timestamp": 1546426800}, {"aggregated_value": {"all": 31}, "timestamp": 1546423200}, {"aggregated_value": {"all": 10}, "timestamp": 1546419600}]}

Example: Aggregated Events Requests with a wanted timestamp format

Request URL:/dashboard/api/devices/15/sensors/202/events/mykey/?type=2&begin=1545227434&end=1546431091&aggregationmode=byhour×tamp_format=%Y-%m-%dT%H:%M:%S

{"timeslots": [{"aggregated_value": {"all": 4}, "timestamp": "2019-01-02T12:00:00"}, {"aggregated_value": {"all": 26}, "timestamp": "2019-01-02T11:00:00"}, {"aggregated_value": {"all": 31}, "timestamp": "2019-01-02T10:00:00"}, {"aggregated_value": {"all": 10}, "timestamp": "2019-01-02T09:00:00"}]}
Name URL Method Description
Event Information /dashboard/api/devices/deviceid/sensors/sensorid/events/eventid/key GET Returns the events metadata

Example

Request URL:/dashboard/api/devices/15/sensors/202/events/15640357/mykey/

{"events": [{"message": "Sterile_Zone", "event_id": 15640357, "timestamp": 1546431091, "sterile_zone_type": "INTRUSION", "sensor_id": 202, "media_ids": [10794585, 10794586, 10794587, 10794588, 10794589, 10794590, 10794591, 10794592, 10794593, 10794594, 10794595], "event_type": "Sterile_Zone", "description": "Sterile_Zone", "device_id": 15, "media_paths": ["/media/events/corridoio_sede/Corridoio/20190102/121131_2_0.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_1.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_2.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_3.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_4.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_5.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_6.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_7.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_8.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_9.jpg", "/media/events/corridoio_sede/Corridoio/20190102/121131_2_10.jpg"]},
Name URL Method Description
Event Media List /dashboard/api/devices/deviceid/sensors/sensorid/events/eventid/media/key GET Returns the list of images associated to the events

Example

Request URL:/dashboard/api/devices/15/sensors/202/events/15640357/media/mykey/

[10794585, 10794586, 10794587, 10794588, 10794589, 10794590, 10794591, 10794592, 10794593, 10794594, 10794595]
Name URL Method Description
Event Media List /dashboard/api/devices/deviceid/sensors/sensorid/events/eventid/media/media_id/key GET Returns the media url

Example

Request URL:/dashboard/api/devices/15/sensors/202/events/15640357/media/10794586/mykey/

Aggregated Sensors

Name URL Method Description
Aggregated sensors list /dashboard/api/aggregated_sensors/key GET Retrives the list of the aggregated sensors

Example

Request URL:/dashboard/api/aggregated_sensors/mykey/

{"devices":[{"aggregated_sensor_id":"4","aggregated_sensor_name":"GrandCentral_QueueAggregated"},{"aggregated_sensor_id":"6","aggregated_sensor_name":"Class"}, {"aggregated_sensor_id":"8","aggregated_sensor_name":"AITECH"}]}
Name URL Method Description
Aggregated sensors /dashboard/api/aggregated_sensors/sensorid/key GET Retrives the information of an aggregated sensors

Example

Request URL:/dashboard/api/aggregated_sensors/3/mykey/

{"aggregated_sensor_id":"3","aggregated_sensor_name":"Mensa Aggregato","aggregated_sensor_event_type":"id[14] name[Counting] common_name[People counting]","aggregated_sensor_sensors":[{"id_source":"32","sensor_id":2,"sensor_name":"ENTER","event_type":14,"event_type_name":"Counting","points":[]},{"id_source":"32","sensor_id":33,"sensor_name":"EXIT","event_type":14,"event_type_name":"Counting","points":[]}],"aggregated_sensor_counter":true,"aggregated_sensor_reset_time":"17:00:00","aggregated_sensor_company":"AITECH","aggregated_sensor_site":"DEMO AITECH DEMO#AITECH Europe/Rome","operations_for_each_sensor":[{"operation_aggregated_sensor_id":3,"operation_sensor_id":2,"operation_field":"+"},{"operation_aggregated_sensor_id":3,"operation_sensor_id":33,"operation_field":"-"}]}