Attributes
The HTTP Attributes API lets devices upload client-side attributes, request attribute values, and poll for shared attribute updates. For an explanation of attribute types, see Attributes.
See Getting Connected for authentication and connection details.
ThingsBoard picks the type of each value as it parses the JSON, and by default a string that looks like a number is stored as a number — see JSON Payload Data Types.
Publish Client-Side Attributes
Section titled “Publish Client-Side Attributes”Upload client-side attributes with a POST request:
POST http(s)://THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes{"attribute1": "value1", "attribute2": true, "attribute3": 42.0}curl -s -X POST -H "Content-Type: application/json" -d '{"attribute1":"value1","attribute2":true,"attribute3":42.0}' "http://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes"Request Attribute Values
Section titled “Request Attribute Values”Request client-side and shared attribute values with a GET request:
GET http(s)://THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes?clientKeys=attr1,attr2&sharedKeys=shared1,shared2| Query parameter | Description |
|---|---|
clientKeys |
Comma-separated list of client-side attribute keys to return |
sharedKeys |
Comma-separated list of shared attribute keys to return |
curl -s "http://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes?clientKeys=attribute1,attribute2&sharedKeys=shared1,shared2"Response:
{"client": {"attribute1": "value1", "attribute2": true}, "shared": {"shared1": "value2", "shared2": false}}Subscribe to Shared Attribute Updates
Section titled “Subscribe to Shared Attribute Updates”Poll for shared attribute changes with a long-lived GET request:
GET http(s)://THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes/updates?timeout=20000curl -s "http://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes/updates?timeout=20000"The request blocks until a shared attribute changes or the timeout elapses. The timeout parameter is in milliseconds. When an update occurs, ThingsBoard returns the changed attributes:
{"shared": {"firmware_version": "2.1.0"}}Was this helpful?