# Telemetry endpoints

Every path starts at your [API URL](https://docs.qualithm.com/api.md#find-your-api-url). Every response is JSON, and an error has the [error body](https://docs.qualithm.com/api.md#errors).

## Read a device metric as bucketed points

`GET /v1/teams/{teamId}/devices/{deviceId}/telemetry`

By bucket start `ts`, ascending, within `from` and `to`. Every page reads the same range, so pass the same query with each cursor.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `telemetry.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `deviceId` | path | string | Yes | A device ID: `dvc_<zone>_…`; also accepts the legacy `dev_…` |
| `metric` | query | string | Yes | The metric to read: 1 to 64 ASCII letters, digits, `_`, `.` or `-` |
| `from` | query | string (date-time) | Yes | Range start, RFC 3339, inclusive. Any time from 1970-01-01T00:00:00Z to 2200-01-01T00:00:00Z, both included. |
| `to` | query | string (date-time) | Yes | Range end, RFC 3339, exclusive. Any time from 1970-01-01T00:00:00Z to 2200-01-01T00:00:00Z, both included. |
| `bucket` | query | string | No | Bucket width in whole seconds, from 1 to 31536000 (one year). Default 60. |
| `agg` | query | string | No | Bucket aggregate: avg, min, max, sum, count, last, delta or rate. Default avg. |
| `fill` | query | string | No | `locf` carries the last observation forward across empty buckets |
| `limit` | query | integer | No | Items per page, 1 to 100. Default 50. |
| `cursor` | query | string | No | A previous page's `nextCursor`, to read the page after it |

**Response:** `200` with [TelemetryPointPage](#telemetrypointpage) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/devices/<device-id>/telemetry?metric=<metric>&from=<from>&to=<to>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Types

### TelemetryPointPage

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `items` | array of [TelemetryPoint](#telemetrypoint) | Yes |  |
| `nextCursor` | string or null | Yes | Pass as `cursor` to read the next page; `null` on the last page |

### TelemetryPoint

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `ts` | integer (int64) | Yes | The bucket start, epoch milliseconds |
| `value` | number or null | Yes | The bucket's aggregate. Null for a gap with no prior observation, and for the first bucket of a delta or rate series. |
