Authentication
For each request, authentication data must be sent. For the TreeApi, two kinds of authentication are possible: basic authentication and JWT authentication.
Basic authentication
If basic authentication is used, the user name and password must be encoded in the basic authentication header field of the HTTP request. This must be done for each request.
JWT authentication
TBD
Request and response body
Request bodies must be encoded as JSON data. In addition it is required to send the correct HTTP content header field:
Content-Type: application/json
All response bodies are encoded as JSON data too.
Read Item
Retrieve single item values.
HTTP mode
GET
URL
http(s)://<ip or host>:<port>/<item id>
Instead of backslash \ the normal slash / must be used as separator.
URL Parameters
Parameter | Description | Values | Mandatory |
---|---|---|---|
light | If activated, only the value of the item is returned. If deactivated, a set of predefined properties are returned. | true/false | No. Default: false |
waitForChange | return request on item value change | true/false | No. Default: false |
properties | Comma-separated list of item property ids to fetch | <property-id>,<property-id>,… | No. Default: empty |
Example
Request:
GET http://127.0.0.1:21012/NETx/VAR/Boolean/Item001?properties=1002,1003,1004
Response:
{ "itemId": "NETx\\VAR\\Boolean\\Item001", "apiPath": "NETx/VAR/Boolean/Item001", "parentItemId": "NETx\\VAR\\Boolean", "name": "Item001", "description": "Variable 1 (Boolean)", "type": 21, "quality": "uncertain", "value": null, "lastChange": "2023-05-26T10:05:51.437Z", "accessRights": "readWrite", "source": "", "properties": [ { "id": 1002, "name": "Persistent", "value": false, "unit": "" }, { "id": 1003, "name": "IsValueSet", "value": false, "unit": "" }, { "id": 1004, "name": "Redundant", "value": false, "unit": "" } ] }
Read Multiple Items
To retrieve Retrieve multiple items, the request item Ids must be passed as json array in the request body.
HTTP mode
POST
URL
http(s)://<ip or host>:<port>/read
URL parameters
Parameter | Description | Values | Mandatory |
---|---|---|---|
light | If activated, only the value of the item is returned. If deactivated, a set of predefined properties are returned. | true/false | No. Default: false |
Request body
["<item id1>", "<item id2", ...]
Example
Request:
http://127.0.0.1:21012/read
[ "NETx/VAR/Boolean/Item001", "NETx/VAR/Boolean/Item002"]
Response:
[ { "itemId": "NETx\\VAR\\Boolean\\Item001", "apiPath": "NETx/VAR/Boolean/Item001", "parentItemId": "NETx\\VAR\\Boolean", "name": "Item001", "description": "Variable 1 (Boolean)", "type": 21, "quality": "uncertain", "value": null, "lastChange": "2023-05-26T10:05:51.437Z", "accessRights": "readWrite", "source": "" }, { "itemId": "NETx\\VAR\\Boolean\\Item002", "apiPath": "NETx/VAR/Boolean/Item002", "parentItemId": "NETx\\VAR\\Boolean", "name": "Item002", "description": "Variable 2 (Boolean)", "type": 21, "quality": "uncertain", "value": null, "lastChange": "1899-12-30T00:00:00Z", "accessRights": "readWrite", "source": "" } ]
Write Item value
In case the api permission for this item is write-only ('w'), the request returns with HTTP 204
Write single item
$ curl -u "usr:passwd" -s -X POST -H "Content-Type: application/json" -d '"NEW Value for 001"' <http://localhost:21012/NETx/VAR/String/Item001>
Write single item - Retrieve only value of single item
$ curl -u "usr:passwd" -s -X POST -H "Content-Type: application/json" -d '"NEW Value for 001"' <http://localhost:21012/NETx/VAR/String/Item001?light=true>