Skip to content

docs(attributes): unified attribute-request API across MQTT/HTTP/CoAP/gateway - #529

Open
ShvaykaD wants to merge 8 commits into
mainfrom
feature/docs-unified-attribute-request
Open

docs(attributes): unified attribute-request API across MQTT/HTTP/CoAP/gateway#529
ShvaykaD wants to merge 8 commits into
mainfrom
feature/docs-unified-attribute-request

Conversation

@ShvaykaD

Copy link
Copy Markdown
Contributor

Overview

Documents the unified attribute-request API introduced in thingsboard/thingsboard#15865:

  • Per-scope "fetch all" — MQTT: an empty clientKeys/sharedKeys value returns the whole scope; HTTP/CoAP: allClientKeys=true / allSharedKeys=true query params; Gateway: a request carrying only {id, device} returns both scopes.
  • Scope-separated gateway response{"client": {...}, "shared": {...}} (the legacy value/values form is preserved and noted as deprecated).
  • Verified examples — request/response snippets use the mqtt.js Node emulator so they actually run end to end.

Pages updated

  • docs/reference/{mqtt-api,http-api,coap-api,gateway-api}/attributes.mdx
  • docs/edge/reference/apis-and-sdks/{mqtt-api,http-api,coap-api,gateway-mqtt-api,device-api}.mdx
  • _includes/.../mqtt-js-attributes-request.js, mqtt-js-gateway-attributes-request.js

Related

…HTTP/CoAP

- device & gateway MQTT, HTTP, CoAP attribute-request pages, plus edge mirrors
- document fetch-all per scope (MQTT: empty value; HTTP/CoAP: allClientKeys/allSharedKeys)
- replace non-working mosquitto sub/pub request examples with mqtt.js emulators
- fix invalid gateway client/shared array example; deprecate legacy client/key/keys
- add request-parameter tables; remove stale 'overlapping keys' note
- all examples verified against a live instance

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ThingsBoard documentation to describe a unified attribute-request API behavior across MQTT/HTTP/CoAP and the Gateway API, including “fetch all” semantics and scope-separated responses, and adds runnable Node/mqtt.js example scripts referenced from the docs.

Changes:

  • Documented per-scope “fetch all” behavior ("" for MQTT/Gateway keys, allClientKeys/allSharedKeys for HTTP/CoAP) and clarified scope exclusion rules.
  • Updated Gateway attribute request/response docs to use clientKeys/sharedKeys and describe scope-separated responses.
  • Added downloadable mqtt.js scripts for device and gateway attribute requests and linked them from the docs.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/content/_includes/docs/reference/mqtt-api/attributes.mdx Adds field semantics and a mqtt.js example for MQTT attribute requests.
src/content/_includes/docs/reference/http-api/attributes.mdx Clarifies HTTP attribute read endpoint and adds allClientKeys/allSharedKeys parameters.
src/content/_includes/docs/reference/coap-api/attributes.mdx Clarifies CoAP attribute read endpoint and adds allClientKeys/allSharedKeys parameters.
src/content/_includes/docs/reference/gateway-api/attributes.mdx Updates Gateway attribute request docs to clientKeys/sharedKeys, scope-separated response, and adds mqtt.js example.
src/content/_includes/docs/edge/reference/apis-and-sdks/mqtt-api.mdx Mirrors unified MQTT attribute-request semantics for Edge docs and adds an additional example.
src/content/_includes/docs/edge/reference/apis-and-sdks/http-api.mdx Notes Edge HTTP “get attributes” supports allClientKeys/allSharedKeys.
src/content/_includes/docs/edge/reference/apis-and-sdks/coap-api.mdx Notes Edge CoAP “get attributes” supports allClientKeys/allSharedKeys.
src/content/_includes/docs/edge/reference/apis-and-sdks/gateway-mqtt-api.mdx Updates Edge gateway MQTT attribute request docs and adds a Node/mqtt.js example.
src/content/_includes/docs/edge/reference/apis-and-sdks/device-api.mdx Adds short MQTT attribute-request guidance for Edge Device/Gateway topics.
public/resources/docs/reference/mqtt-api/mqtt-js-attributes-request.js Adds a downloadable mqtt.js script for device attribute requests.
public/resources/docs/reference/gateway-api/mqtt-js-gateway-attributes-request.js Adds a downloadable mqtt.js script for gateway attribute requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/content/_includes/docs/edge/reference/apis-and-sdks/device-api.mdx Outdated
Comment thread src/content/_includes/docs/reference/mqtt-api/attributes.mdx
Comment thread public/resources/docs/reference/gateway-api/mqtt-js-gateway-attributes-request.js Outdated
Comment thread src/content/_includes/docs/reference/gateway-api/attributes.mdx Outdated
@vvlladd28 vvlladd28 added the awaiting-product-merge Waiting for corresponding changes to be merged into the main product repository label Jul 1, 2026
…attribute-request

# Conflicts:
#	src/content/_includes/docs/reference/coap-api/attributes.mdx
#	src/content/_includes/docs/reference/gateway-api/attributes.mdx
…I example

Follow-up to the main merge, driven by testing the documented commands
against a live instance.

- MQTT device: restore the mqtt.js example. mosquitto_rr cannot be used
  here — ThingsBoard only accepts a subscription to
  v1/devices/me/attributes/response/+ (MqttTransportHandler switches on
  the exact topic), and mosquitto_rr rejects a wildcard response topic.
  Add the npm install prerequisite, matching mqtt-api/rpc.mdx.
- All four pages: tabs per scope combination (specific keys, all client,
  all shared, all attributes), each carrying both the request and the
  response for that case. CoAP shows the Access Token and X.509 commands
  inside every tab instead of a single detached block.
- HTTP and CoAP: document the no-parameters default and add
  allClientKeys/allSharedKeys examples (PROD-8496 QA comments).
- Gateway: the legacy scope collision only happens when both scopes come
  back at once — with explicit keys a single scope is queried and no
  collision occurs. Verified on a live gateway session.
- Gateway: use version strings that survive JSON_TYPE_CAST_ENABLED
  (on by default), which turns "1.0" into the number 1.0.
The Edge gateway MQTT API page was missed when the other pages were
corrected after testing against a live instance.

- Replace the Node.js/mqtt.js example with mosquitto_rr. The page claimed
  a command-line example was impossible because subscribe and publish
  must share one MQTT session; mosquitto_rr does exactly that, and the
  gateway response topic needs no wildcard, so it works. Verified on a
  live gateway session.
- A scope is absent from the response whenever it returned nothing, not
  only when it was not requested.
- Use version strings that survive JSON_TYPE_CAST_ENABLED.
…efault on Edge

- Gateway: a scope is absent from the response whenever it returned
  nothing, not only when it was not requested. Brings the page in line
  with the other attribute pages, which were already corrected.
- Edge HTTP and CoAP: state that a request without query parameters
  returns both scopes in full (PROD-8496 QA comments).
Verified against PE 4.4: the legacy fetch-all path applies the
single-vs-multiple rule to each scope independently, so a response can
carry `values` for the client scope and `value` for the shared one at the
same time. Both examples are verbatim responses from that run.
- Rename to "request/response format": the response shape differs too,
  not just the request fields.
- Replace the list of shortcomings with a plain description of what the
  format does, plus one sentence on what clientKeys/sharedKeys adds.
- Drop the empty-keys paragraph and its example. The field table already
  requires key or keys, so that path is outside the documented contract.
- Keep the deprecation notice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-product-merge Waiting for corresponding changes to be merged into the main product repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants