# List sensor readings

> The workspace's environmental readings, newest first, a page at a time. Narrow them to one device, one growing room or one kind of measurement, and use since and until to fetch only the readings taken within a window.

Source: https://docs.xplantpro.com/docs/api/sensor-readings/list-sensor-readings

`GET https://app.xplantpro.com/api/v1/sensor-readings`

- Required scope: `read:sensor_readings`
- Credentials: workspace API key (`xpk_`)
- Idempotency-Key: ignored on this endpoint

Pages are larger here than on other lists: 100 readings by default and up to 1,000. To read further back than one page reaches, follow `meta.next_cursor` with the same filters until it comes back `null`. Readings taken at the same moment keep a fixed order, so none is skipped or repeated.

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `device_id` | string (uuid) | No | Only readings from this device. |
| `room_id` | string (uuid) | No | Only readings for this growing room. |
| `type` | `"temperature"` \| `"humidity"` \| `"ph"` \| `"co2"` \| `"light"` \| `"other"` | No | Only this kind of reading. |
| `since` | string (date-time) | No | Only readings taken at or after this time, as an ISO 8601 timestamp in UTC or with an offset. Write an offset's `+` as `%2B`. |
| `until` | string (date-time) | No | Only readings taken at or before this time, as an ISO 8601 timestamp in UTC or with an offset. Write an offset's `+` as `%2B`. Must not be earlier than `since`. |
| `limit` | integer | No | Page size. Values above 1,000 are capped at 1,000. Default `100`. From 1 to 1000. |
| `offset` | integer | No | Number of records to skip. Prefer `cursor` where a list offers it: an offset shifts when records are added ahead of it. Default `0`. At least 0. |
| `cursor` | string | No | Continue from the previous page: pass its `meta.next_cursor` unchanged, with the same filters. Treat it as opaque. Not combinable with `offset`. Up to 2048 characters. |

## Example

**curl**

```bash
curl "https://app.xplantpro.com/api/v1/sensor-readings?device_id=5f7a9c1e-3b5d-4f7a-9c1e-3b5d7f9a1c3e&type=temperature&since=2026-09-24T00%3A00%3A00Z&until=2026-09-25T00%3A00%3A00Z&limit=1000" \
  -H "Authorization: Bearer $XPLANT_API_KEY"
```

**JavaScript**

```js
import { XPlantClient } from "@shmaplex/xplant-sdk";

const client = new XPlantClient({ apiKey: process.env.XPLANT_API_KEY });

const readings = await client.sensorReadings.list({
  device_id: "5f7a9c1e-3b5d-4f7a-9c1e-3b5d7f9a1c3e",
  type: "temperature",
  since: "2026-09-24T00:00:00Z",
  until: "2026-09-25T00:00:00Z",
  limit: 1000,
});
```

**Python**

```python
import os
import requests

resp = requests.get(
    "https://app.xplantpro.com/api/v1/sensor-readings",
    headers={"Authorization": f"Bearer {os.environ['XPLANT_API_KEY']}"},
    params={
        "device_id": "5f7a9c1e-3b5d-4f7a-9c1e-3b5d7f9a1c3e",
        "type": "temperature",
        "since": "2026-09-24T00:00:00Z",
        "until": "2026-09-25T00:00:00Z",
        "limit": 1000,
    },
    timeout=10,
)
body = resp.json()
if not body["ok"]:
    raise RuntimeError(f"{resp.status_code} {body['code']}: {body['error']}")
readings = body["data"]
```

## Response

`200` with `{ "ok": true, "data": … }`. `data` is an array. To get the next page, pass `meta.next_cursor` back as `cursor`; it is `null` on the last page. See [Pagination](https://docs.xplantpro.com/docs/pagination.md).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (uuid) | Yes | — |
| `device_id` | string (uuid) | Yes | — |
| `team_id` | string (uuid) | Yes | The id of the workspace the reading belongs to. |
| `room_id` | string \| null (uuid) | Yes | — |
| `type` | string | Yes | What was measured: `temperature`, `humidity`, `ph`, `co2`, `light`, `other`. |
| `value` | number | Yes | — |
| `unit` | string | Yes | — |
| `recorded_at` | string | Yes | When the reading was taken, as an ISO 8601 timestamp. |
| `notes` | string \| null | Yes | — |
| `created_at` | string | Yes | — |

```json title="Response"
{
  "ok": true,
  "data": [
    {
      "id": "f1a7c3e9-2b4d-4f6a-8c0e-3d5b7a9c1e24",
      "device_id": "8e3b1f52-6c0d-4a7e-9b21-5f4d8c2a7e13",
      "team_id": "5d2e8b17-9c4a-4e3f-b6d0-1a7c9e2f4b83",
      "room_id": "2c6f9a41-7d3e-4b8a-a1c5-9e0d4f7b3a26",
      "type": "temperature",
      "value": 24.1,
      "unit": "°C",
      "recorded_at": "2026-09-25T14:00:00.000Z",
      "notes": null,
      "created_at": "2026-09-25T14:00:31.000Z"
    }
  ]
}
```

The envelope can also carry `meta`:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `next_cursor` | string \| null | Yes | Pass as `cursor` to fetch the next page. `null` means this is the last page. |

| Response header | Meaning |
| --- | --- |
| `X-Request-Id` | Identifies this request. Include it when you contact support. |

## Errors

| Status | Code | When |
| --- | --- | --- |
| `401` | `UNAUTHORIZED` | The key is missing, malformed or revoked, or its owner is no longer a member of the workspace. |
| `402` | `PAID_PLAN_REQUIRED` | The workspace's plan does not include the API. The full API is included with xPlant+ Teams and Enterprise; on Hobby and Pro Lab, keys can connect devices only. |
| `403` | `FORBIDDEN` | The key lacks a scope this operation requires, or its owner's current role in the workspace cannot use it — a key never does more than its owner can in xPlant. `error` names the scope, and for a role, the role it needs. |
| `403` | `DEVICE_TOKEN_NOT_ACCEPTED` | A device token was sent; this operation needs a workspace API key. |
| `422` | `VALIDATION_ERROR` | Both `cursor` and `offset` were sent; use one. |
| `422` | `INVALID_CURSOR` | The cursor is malformed, or came from a different list or different filters. Start again without it. |
| `422` | `VALIDATION_ERROR` | A query parameter is malformed: `device_id` or `room_id` is not a UUID, `since` or `until` is not a timestamp, `since` is later than `until`, or `limit` is not a whole number. `error` names the parameter, for example `device_id: must be a UUID`. |
| `429` | `RATE_LIMIT_EXCEEDED` | Too many requests for this key, device token or workspace. Wait `Retry-After` seconds. |
| `500` | `READINGS_QUERY_FAILED` | The readings could not be read. Retry later. |

Branch on `code`, never on the `error` text. See [Errors](https://docs.xplantpro.com/docs/errors.md).
