API - Getting data for events
To get data from event log, it is necessary to run following GET-query for URL http://192.168.1.1/api/event-data/2. Here 2 - is the ID of the graph of interest.
In the request headers, you must pass the API key and the boundaries of the time interval of interest. X-WH-START and X-WH-END are transmitted in UnixTime format. For example:
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 X-WH-START: 1422797440 X-WH-END: 1422997405
Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.
Accept: application/json Content-Type: application/json
Consider an example of two events. Event number 1 is the parent event. It starts on the 5th second of every minute and ends on the 40th second of every minute. The log records data once for the entire event. The time of the beginning of the event and the last value of the interval register I60 are recorded in the log. Screenshots illustrate the setting of this event.
The second event is the child event for the first event. Therefore, it can only be executed when the first event is executed. In addition, the condition is limited so that it starts at the 25th second of every minute and ends at the 35th. Data for it is written to the log every 2 seconds. The current value of the I60 register is written to the log. Screenshots illustrate the setting of this event.
Example of getting date about event #1:
URL: http://192.168.1.1/api/event-data/1
Method: GET
Headers:
Accept: application/json Content-Type: application/json Accept-Encoding: gzip, deflate, sdch X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 X-WH-START: 1422797440 X-WH-END: 1422997405
Example of response:
[ { "rowid": "3050", "event_id": "1", "start_time": "1422797405", "end_time": "1422797440", "xtra_regs": [ { "E1.0": 1422797405 }, { "E1.1": 39 } ] }, { "rowid": "3052", "event_id": "1", "start_time": "1422797465", "end_time": "1422797500", "xtra_regs": [ { "E1.0": 1422797465 }, { "E1.1": 39 } ] }, { "rowid": "3054", "event_id": "1", "start_time": "1422797525", "end_time": "1422797560", "xtra_regs": [ { "E1.0": 1422797525 }, { "E1.1": 39 } ] }, { "rowid": "3056", "event_id": "1", "start_time": "1422797585", "end_time": "1422797680", "xtra_regs": [ { "E1.0": 1422797585 }, { "E1.1": 39 } ] }, { "rowid": "3058", "event_id": "1", "start_time": "1422797705", "end_time": "1422797740", "xtra_regs": [ { "E1.0": 1422797705 }, { "E1.1": 39 } ] }, { "rowid": "3060", "event_id": "1", "start_time": "1422797765", "end_time": "1422797800", "xtra_regs": [ { "E1.0": 1422797765 }, { "E1.1": 39 } ] }, { "rowid": "3062", "event_id": "1", "start_time": "1422797825", "end_time": "0", "xtra_regs": [ { "E1.0": 1422797825 }, { "E1.1": 39 } ] } ]
Event's attrubutes:
rowid | int | Unique event identifier in database |
event_id | int | Event ID |
start_time | int | Event start time |
end_time | int | Event end time. If the event still in progress, then end time = 0 |
xtra_regs | object | Object with data on additional registers which are saved in event log. Key - Value. |
Additional register name format:
"E" + event ID + "." + register's serial number in the event starting from 0
Example of query for data on event #2:
URL: http://192.168.1.1/api/event-data/2
Method: GET
Headers:
Accept: application/json Content-Type: application/json Accept-Encoding: gzip, deflate, sdch X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 X-WH-START: 1422804505 X-WH-END: 1422800200
Response example:
[ { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 25 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 27 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 29 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 31 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 33 } ] } ]