Skip to content

Added documentation about API to request all attributes from some scope #2037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop/4.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions _includes/docs/reference/coap-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ This example shown with the coap-client instead of CoAP cli since CoAP cli does
{% endcapture %}
{% include templates/info-banner.md content=difference %}

##### Request specific client and shared attributes

{% capture tabspec %}coap-attributes-request
A,Execute the command:,shell,resources/coap-attributes-request.sh,/docs/reference/resources/coap-attributes-request.sh{% endcapture %}
{% include tabs.html %}
Expand All @@ -245,6 +247,98 @@ However, it is still possible to have same keys for client, shared or even serve
{% endcapture %}
{% include templates/info-banner.md content=difference %}

{% if docsPrefix != "edge/" %}

##### Request specific client attributes
In order to request specific client attributes, you can use the following command:

```shell
coap-client -m get "coap://$THINGSBOARD_HOST_NAME/api/v1/$ACCESS_TOKEN/attributes/client?keys=attribute1,attribute2"
```
{: .copy-code}
Where:
- **$THINGSBOARD_HOST_NAME** - your localhost, or the platform address.
- **$ACCESS_TOKEN** - your device access token.

Result:

```json
{"client":{"attribute2":true,"attribute1":"value1"}}
```

##### Request specific shared attributes
In order to request specific shared attributes, you can use the following command:

```shell
coap-client -m get "coap://$THINGSBOARD_HOST_NAME/api/v1/$ACCESS_TOKEN/attributes/shared?keys=shared1"
```
{: .copy-code}
Where:
- **$THINGSBOARD_HOST_NAME** - your localhost, or the platform address.
- **$ACCESS_TOKEN** - your device access token.

Result:

```json
{"shared":{"shared1":"value1"}}
```

##### Request all client and shared attributes

In order to request all attributes, you can use the following command:

```shell
coap-client -m get "coap://$THINGSBOARD_HOST_NAME/api/v1/$ACCESS_TOKEN/attributes"
```
{: .copy-code}
Where:
- **$THINGSBOARD_HOST_NAME** - your localhost, or the platform address.
- **$ACCESS_TOKEN** - your device access token.

Result:

```json
{"client":{"attribute2":true,"attribute1":"value1"},"shared":{"shared1":"value1"}}
```

#### Request all client attributes

To request all client attributes from the server, you can use the following command:

```shell
coap-client -m get "coap://$THINGSBOARD_HOST_NAME/api/v1/$ACCESS_TOKEN/attributes/client"
```
{: .copy-code}
Where:
- **$THINGSBOARD_HOST_NAME** - your localhost, or the platform address.
- **$ACCESS_TOKEN** - your device access token.

Result:

```json
{"client":{"attribute2":true,"attribute1":"value1"}}
```

#### Request all shared attributes

To request all shared attributes from the server, you can use the following command:

```shell
coap-client -m get "coap://$THINGSBOARD_HOST_NAME/api/v1/$ACCESS_TOKEN/attributes/shared"
```
{: .copy-code}
Where:
- **$THINGSBOARD_HOST_NAME** - your localhost, or the platform address.
- **$ACCESS_TOKEN** - your device access token.

Result:

```json
{"shared":{"shared1":"value1"}}
```

{% endif %}

### Subscribe to attribute updates from the server

In order to subscribe to shared device attribute changes, send GET request with Observe option.
Expand Down
Loading