HTTP APIs
The device offers a range of functions in the form of HTTP APIs, that can be used by making HTTP requests (GET or POST) from external systems connected to the same network.
This allows the device's data to be read and the digital outputs and watchdogs to be controlled in a programmatic fashion, e.g. by means of an AI agent or a monitoring system.
Access Control
To prevent unauthorized access to the data stored on the device, there is an access control layer in place.
If on the security configuration page
- an admin user is setup AND
- the checkbox Allow peripheral state and history read access via web interface and HTTP APIs without authentication is not ticked,
an API-Key is required to be included in the API request by including a HTTP Header of the form
Authorization: API-Key KEY
where KEY is to be replaced by the actual API-Key.
An API-Key can be generated and viewed/copied on the Security configuration page under API-Key.
Once generated, the key will persist until regenerated, deleted, or the device configuration gets reset.
For the control API an API-Key is required in any case.
Historical peripheral data in CSV
This API provides two endpoints, returning historical peripheral data in CSV format.
| Purpose | Method | URL |
|---|---|---|
| Sensor data | GET | http://HOST/tpl/document.cgi?tpl=/tpl/general/default/history_csv.tpl |
| Changes (Inputs/Outputs/Watchdogs) | GET | http://HOST/tpl/document.cgi?tpl=/tpl/general/default/changes_csv.tpl |
HOST is to be replaced by the host belonging to the device.
Both endpoints accept the following query parameters:
| Query Parameter | Description |
|---|---|
limit_type | If set to days, the limit parameter specifies the number of days; otherwise, it specifies the number of entries. |
limit | Limits the returned entries. See limit_type. |
step | If specified, the timerange function is used to aggregate entries into intervals of this size. |
format | Timestamp format. See the strftime template function function. |
local | If not equal to 0, local time is used. |
Evaluate stored templates
The template feature allows you to store custom templates on the device for later evaluation.
This API lets you evaluate those stored templates and returns the evaluation result.
| Purpose | Method | URL |
|---|---|---|
| Stored template evaluation | GET | http://HOST/tpl/document.cgi?tpl=/tpl/PATH/TEMPLATE.tpl |
In the above URL, replace
HOSTby the host belonging to the deviceTEMPLATEby the name of the template you want to evaluatePATHby the category the template belongs to
The mapping from categories to paths is:
| Category | PATH |
|---|---|
| General | general |
email | |
| Webhook | webhook |
Historical peripheral data in CSV is a special case of this, where the templates providing the CSV data are vendor provided.
Evaluate templates on the fly
This API endpoint returns an evaluated template, that is supplied inline in the body of the HTTP request.
The template does not have to be stored beforehand on the device to use this method.
| Purpose | Method | URL |
|---|---|---|
| Execute template | POST | http://HOST/admin/proctpl.cgi |
HOST is to be replaced by the host belonging to the device.
Include the template as raw text in the body of the request.
The maximum supported payload size is 4096 bytes.
Control digital outputs and/or check watchdogs
Set the state of digital outputs or perform a watchdog check on demand with this API.
| Purpose | Method | URL |
|---|---|---|
| Control digital outputs and/or check watchdogs | POST | http://HOST/control.cgi |
HOST is to be replaced by the host belonging to the device.
To define the behaviour, include one or more of the following parameters
in the application/x-www-form-urlencoded format in the request body.
| Parameter | Description |
|---|---|
output0 | Switch output 1 off if the value is 0; otherwise, switch it on. |
output1 | Switch output 2 off if the value is 0; otherwise, switch it on. |
watchdog0 | Check watchdog 1 immediately if the value is greater than 0. |
watchdog1 | Check watchdog 2 immediately if the value is greater than 0. |
Providing an API-Key is mandatory here!