REST API
The Trendz REST API lets you fetch view data programmatically — for example, to pull computed telemetry into external dashboards, scripts, or third-party tools.
All endpoints are served under the base URL:
http(s)://<trendz-host>:8888/apiTrendz/Authentication
Section titled “Authentication”Authenticate each request with a JWT token or a ThingsBoard API key.
JWT token
Section titled “JWT token”Obtain a token by posting credentials to the Trendz login endpoint:
curl -X POST 'http://localhost:8888/apiTrendz/publicApi/auth/login' \ -H 'Content-Type: application/json' \ -d '{"username": "[email protected]", "password": "tenant"}'Response:
{"token": "YOUR_JWT_TOKEN", "refreshToken": "YOUR_JWT_REFRESH_TOKEN"}Pass the token in the X-Authorization header of subsequent requests:
X-Authorization: Bearer YOUR_JWT_TOKENAccess tokens are valid for 2.5 hours; use the refresh token to obtain a new one before expiry.
ThingsBoard API key
Section titled “ThingsBoard API key”A ThingsBoard API key needs no login
request and stays valid until it expires or is revoked in ThingsBoard. Pass it in the X-Authorization header with
the ApiKey prefix:
X-Authorization: ApiKey YOUR_API_KEYThe key must belong to a Tenant Administrator or a Customer User. Requests run with that user’s permissions.
Build View Report
Section titled “Build View Report”The primary external endpoint. Returns the computed data for a saved Trendz view.
POST /apiTrendz/publicApi/buildReportContent-Type: application/jsonRequest body
Section titled “Request body”{ "viewConfigId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "rangeStartTs": 1700000000000, "rangeEndTs": 1700086400000, "filters": { "Building": ["Office A", "Office B"] }}| Field | Type | Required | Description |
|---|---|---|---|
viewConfigId |
UUID | Yes | ID of the saved Trendz view to execute |
rangeStartTs |
long | No | Start of the time range, Unix timestamp in milliseconds |
rangeEndTs |
long | No | End of the time range, Unix timestamp in milliseconds |
filters |
object | No | Key-value map of filter field names to selected values; filters must be configured in the view |
Response body
Section titled “Response body”{ "columnLabels": ["timestamp", "Building", "avgTemperature"], "dataTable": [ { "timestamp": 1700000000000, "Building": "Office A", "avgTemperature": 21.4 }, { "timestamp": 1700003600000, "Building": "Office A", "avgTemperature": 22.1 } ]}| Field | Type | Description |
|---|---|---|
columnLabels |
string[] | Ordered list of column names in the report |
dataTable |
object[] | Rows of data; each row is a map of column name to value |
Error responses
Section titled “Error responses”| HTTP status | Reason |
|---|---|
400 Bad Request |
The request body is missing required fields or references an invalid view |
429 Too Many Requests |
The server-side queue is full; retry after a short delay |
500 Internal Server Error |
An error occurred while computing the view report |
Example
Section titled “Example”curl -X POST "http://localhost:8888/apiTrendz/publicApi/buildReport" \ -H "Content-Type: application/json" \ -H "X-Authorization: Bearer <jwt-token>" \ -d '{ "viewConfigId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "rangeStartTs": 1700000000000, "rangeEndTs": 1700086400000 }'Was this helpful?