TreeApi: API specification

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

JWT config options can be set in xio.TreeApi.cfg
A Bearer token can be retrieved via POST /security/createToken
Body:

{ "username": "--username--", "password": "--password--" }

A new token can be retrieved by providing a valid token to GET /security/refresh

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

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:

Response:

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

URL parameters

Parameter

Description

Values

Mandatory

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

Example

Request:

Response:

Read tree recursively

Retrieve current tree state recursively

URL parameters

Parameter

Description

Values

Mandatory

Parameter

Description

Values

Mandatory

root

Base item branch (required, eg. NETx/VAR).

 

Yes.

properties

Comma-separated list of item property ids to fetch.

 

No. Default: ““

depth

Maximum recursion depth (0=unlimited).

 

No. Default: 0

Read partial tree recursively

Retrieve multiple tree parts recursively

URL parameters

Parameter

Description

Values

Mandatory

Parameter

Description

Values

Mandatory

properties

Comma-separated list of item property ids to fetch.

 

No. Default: ““

depth

Maximum recursion depth (0=unlimited).

 

No. Default: 0

Write Item value

In case the api permission for this item is write-only ('w'), the request returns with HTTP 204

Write single item

Write single item - Retrieve only value of single item

Write Multiple Items

To write multiple items, the item Ids including the values and optionally the timestamps must be passed as JSON array in the request body.

HTTP mode

POST

URL

URL parameters

None

Request body

  • itemId: mandatory

  • value: mandatory

  • timestamp: optional

  • source: optional

    • If not used, use: “SYS:TREEAPI;IP:<client IP>;USR:<username>”

Example

Request:

Response:

Listen for item value changes

Make sure to include the 'Authorization' header based on your chosen settings.

URL parameters

Parameter

Description

Values

Mandatory

Parameter

Description

Values

Mandatory

items

Comma-separated list of item property ids to watch.

Comma-separated list of item property ids.

No. Default ““.

URL parameters

 

 

 

 

items

comma-separated list of item property ids to watch