# Datasets, rows and nodes

A key reads one project (see [Scopes](/guides/scopes)). Inside it, the API
serves two kinds of resource: **datasets**, the named tables of the project,
with their rows; and **nodes**, the edge devices that collect the project's
data. Datasets need the `datasets_read` scope, nodes `nodes_read`.

## Datasets

```bash
curl -H "X-Api-Key: $MUVIA_API_KEY" \
  https://api.muviabi.com/api/public/v1/projects/<project_id>/datasets
```

`GET /v1/projects/{project_id}/datasets` is a [page](/guides/pagination#lists)
of the datasets the project shows, sorted by name:

- the project's **own** datasets, built in Muvia from the project's data;
- the **physical** datasets of the project's database, which belong to the
  database rather than the project and show in every project on it. Of the
  tables the nodes write, only two are shown: the flat view of the readings
  and their latest values.

`GET /v1/projects/{project_id}/datasets/{dataset_id}` answers one of them:

```json
{
  "id": "<dataset_id>",
  "name": "<dataset name>",
  "description": null,
  "project_id": "<project_id>",
  "is_physical": false,
  "columns": [
    { "name": "timestamp", "type": "DateTime('Europe/Rome')" },
    { "name": "line", "type": "String" },
    { "name": "pieces", "type": "Int64" },
    { "name": "temperature", "type": "Nullable(Float64)" }
  ],
  "created_at": "2026-05-12T08:30:00Z",
  "updated_at": "2026-09-20T14:05:12Z"
}
```

| Field | Meaning |
| --- | --- |
| `id` | The dataset's identifier, for the other paths. |
| `name` | The name shown in Muvia. |
| `description` | The description written in Muvia, or `null`. |
| `project_id` | The project that owns it; `null` for a physical dataset. |
| `is_physical` | `true` for a physical dataset of the project's database. |
| `columns` | Each column's `name` and `type`, as saved with the dataset. |
| `created_at`, `updated_at` | When it was created and last changed; `null` when unknown. |

A column's `type` is the type its values are stored with: `Int64` and
`Float64` for numbers, `String` for text, `DateTime('Europe/Rome')` for a date
and time read in that time zone, `Nullable(…)` around a type whose value may
be missing. Read a type you do not know as text.

A dataset id that is neither the project's own nor a physical dataset of its
database answers `404` «Dataset not found», whether it does not exist or belongs
elsewhere.

## Rows

```bash
curl -H "X-Api-Key: $MUVIA_API_KEY" \
  "https://api.muviabi.com/api/public/v1/projects/<project_id>/datasets/<dataset_id>/rows?size=500&start=2026-11-01T00:00:00Z&end=2026-11-02T00:00:00Z"
```

`GET /v1/projects/{project_id}/datasets/{dataset_id}/rows` runs the dataset's
saved query, as Muvia's own preview of the dataset runs it, and answers one
page of what it returns: `columns`, the names the query returns now, and
`items`, one object per row keyed by those names.
[Pagination](/guides/pagination#dataset-rows) explains `page`, `size` and
`has_more`.

Rows come **in the order the dataset's query returns them**, not oldest first:
a query without `ORDER BY` can return them in a different order on each call.
To read a stretch of time, pass `start` and `end`, which only some datasets
honour:

| The dataset | Without `start` and `end` | With them |
| --- | --- | --- |
| Reads events, or adds their context to its rows | `422 enrichment_needs_a_window` | The period |
| Reads analysis notes or facts alone | The latest day | The period |
| Any other | Its query's own rows | Ignored: its query's own rows |

Values arrive as JSON: numbers as numbers, text as strings, a date and time as
an ISO 8601 string, a decimal as a string, an array as a list, a map as an
object. A missing value is `null`, and so is a number that is not finite.

### Errors of a rows read

| Status | Code | Means |
| --- | --- | --- |
| 400 | `bad_request` | Only one of `start` and `end`, or `end` not after `start`. |
| 403 | `forbidden` | The query reads analysis notes or facts the key's scopes do not grant. |
| 409 | `conflict` | The project has no database, so there are no rows to read. |
| 422 | `validation_error` | A parameter is out of range, or `start`/`end` lacks an offset. |
| 422 | `enrichment_needs_a_window` | The dataset needs `start` and `end`. |
| 422 | `query_failed` | The dataset's own query does not run; a person mends it in Muvia. |
| 503 | `service_unavailable` | The data store did not answer, or the copy of the readings is catching up — then with `Retry-After`. |

The [Errors](/guides/errors) guide has the envelope and every other code.

## Nodes

```bash
curl -H "X-Api-Key: $MUVIA_API_KEY" \
  https://api.muviabi.com/api/public/v1/projects/<project_id>/nodes
```

`GET /v1/projects/{project_id}/nodes` is a page of the project's edge nodes,
**oldest enrolment first**; `GET /v1/projects/{project_id}/nodes/{node_id}`
answers one, or `404` «Node not found».

```json
{
  "id": "<node_id>",
  "name": "<node name>",
  "project_id": "<project_id>",
  "software_version": "<version>",
  "last_seen_at": "2026-11-28T09:14:03Z",
  "enrolled_at": "2026-06-03T11:20:00Z"
}
```

| Field | Meaning |
| --- | --- |
| `id` | The node's identifier, as the node reports it — the same `node_id` a [webhook](/guides/webhooks) names. |
| `name` | The name of its latest configuration, or `null`. |
| `project_id` | The project it belongs to. |
| `software_version` | The version its agent reports, or `null`. |
| `last_seen_at` | When its agent last reported in, or `null`. |
| `enrolled_at` | When it joined the project, or `null`. |

Every field but `id` and `project_id` can be `null`: a node that never
reported in has no version and was never seen. A node that has not reported
for a while is offline; compare `last_seen_at` with the present, or subscribe
to the `nodes.node_offline` [webhook](/guides/webhooks).
