# OData feed

The OData feed opens a project's datasets in Excel, Power BI or any tool
that reads OData version 4: every dataset the project shows is a table, read
live, page by page. It is read-only and uses the same API keys, the same
`datasets_read` scope and the same data export module as the REST API.

The feed address of a project is

```text
https://api.muviabi.com/api/public/v1/projects/<project_id>/odata
```

and the project's **Data export** settings in Muvia show it, ready to copy.

## Open it in Excel or Power BI

1. Ask a company administrator for a key for the project: the
   **Excel and Power BI** preset in **Settings → Company → API keys** grants
   what the feed needs.
2. In Excel choose **Data → Get Data → From Other Sources → From OData Feed**;
   in Power BI, **Get data → OData feed**.
3. Paste the feed address and confirm.
4. When asked for access, choose **Basic**: any user name will do, the key is
   the password.
5. Pick the tables to load.

Connect datasets that are already aggregated: a table of raw readings is too
large for a sheet. A dataset that adds the context of events to its rows needs
a period: add `start` and `end` to its table's address (see [A period](#a-period)).

## Authentication

The feed reads the key from the `X-Api-Key` header, as REST does, or from
`Authorization: Basic` — the password, or the user name when the password is
empty. It never reads a key from the address: an address ends up in logs and
shared workbooks.

Every credential failure is the same `401`, with
`WWW-Authenticate: Basic realm="Muvia", charset="UTF-8"` so the tool asks for
the key. A key reaches its own project only: any other answers `404`.

## Routes

| Path, under `/api/public/v1/projects/{project_id}` | Answers |
| --- | --- |
| `/odata` | The service document: one entity set per dataset the project shows. |
| `/odata/$metadata` | The schema of every set, as CSDL XML. |
| `/odata/{entity_set}` | A page of the set's rows. |
| `/odata/{entity_set}/$count` | How many rows the set's `$filter` keeps, as plain text. |

```bash
curl -u ":$MUVIA_API_KEY" \
  "https://api.muviabi.com/api/public/v1/projects/<project_id>/odata/<entity_set>?\$top=2"
```

```json
{
  "@odata.context": "https://api.muviabi.com/api/public/v1/projects/<project_id>/odata/$metadata#<entity_set>",
  "value": [
    { "_row": 0, "timestamp": "<timestamp>", "line": "<line>", "pieces": 120 },
    { "_row": 1, "timestamp": "<timestamp>", "line": "<line>", "pieces": 118 }
  ]
}
```

Answers are JSON (`application/json;odata.metadata=minimal`) and carry the
header `OData-Version: 4.0`.

## Names and types

A set is named after its dataset and a property after its column, made into
OData identifiers: accents folded, every other character outside letters,
digits and `_` turned into `_`, a leading digit prefixed with `_`, at most 120
characters. Two names that would collide each get a suffix of their own, so a
name never passes to another dataset or column; deleting or renaming a dataset
can break a query bound to it, never point it at another.

| A column holding | Is read as |
| --- | --- |
| Whole numbers | `Edm.Int16`, `Edm.Int32` or `Edm.Int64`; wider ones as `Edm.Decimal` of scale 0 |
| Decimals | `Edm.Decimal`, with their precision and scale |
| Floating-point numbers | `Edm.Double` |
| Dates | `Edm.Date` |
| Dates and times | `Edm.DateTimeOffset` |
| Booleans | `Edm.Boolean` |
| Anything else: text, identifiers, lists, maps, documents | `Edm.String`; a value of several values as its JSON text |

Every property may be `null`. Each set's key is `_row`, the row's position in
this read: a dataset has no identity of its own, so `_row` promises nothing
across reads.

A row carries exactly the set's properties. A column the dataset's query no
longer returns reads as `null`; one it newly returns is left out until the
dataset is saved again in Muvia. A column it now returns with another type
answers `422 query_failed`: «The dataset's columns changed since it was saved:
open it in Muvia and save it again».

## Query options

| Option | Supported |
| --- | --- |
| `$select` | Properties, or `*`. |
| `$filter` | `eq`, `ne`, `gt`, `ge`, `lt`, `le`, `and`, `or`, `not`, parentheses, and the functions `startswith`, `endswith`, `contains`, `tolower`, `toupper`, `length`, `year`, `month`, `day`, `hour`, `minute`, `second`. |
| `$orderby` | Properties, `asc` or `desc`; a `null` sorts first ascending, last descending. |
| `$top`, `$skip` | Non-negative whole numbers; `$skip` at most 10,000,000. |
| `$count` | `true` adds `@odata.count`. |
| `$format` | `json` only. |

A comparison with `null` answers as OData says: `null gt 1` is false and
`null ne 'x'` true. A value of several values cannot be filtered or sorted.

`$expand`, `$apply`, `$search`, `$compute`, `$levels` and `$deltatoken`, the
operators `add`, `sub`, `mul`, `div`, `divby`, `mod`, `has` and `in`, other
functions, paths, and GUID, time-of-day and other typed literals answer
`501 not_implemented`, naming what is not supported. Any other `$` option,
and an option given twice in any spelling, answers `400 bad_request`.
Parameters not starting with `$` are custom options; the feed reads `start`
and `end` and leaves the rest alone.

## Paging

A page holds up to 5,000 rows. When more follow, the answer carries
`@odata.nextLink`: the same address and options plus a `$skiptoken`. Follow it
as it is; Excel and Power BI do.

A read longer than one page is fixed when its first page is asked for: rows
arriving meanwhile neither appear in it nor shift its pages, and show in the
next read. A read ends with its last page, or an hour after it began if left
halfway; a `$skiptoken` of an ended read answers `400` «This page belongs to a
read that has ended: refresh to start again», and one followed with other
options, or not written by the feed, answers `400` too.

A key may have 20 reads of a project in progress at once. One more answers
`429` «Too many reads in progress for this key: finish or wait for one to
end», with `Retry-After`.

A read that would hold more rows than its ceiling — 5,000,000, or 100,000 on
a project whose database is not yet set up for the feed — answers
`400 too_deep`, naming the ceiling; so does a `$skip` past 10,000,000. Filter
the feed, or read a dataset that aggregates.

## A period

A dataset that reads events, or adds their context to its rows, is read over
the period the options `start` and `end` name: ISO 8601 instants with their
offset, both or neither.

```text
…/odata/<entity_set>?start=2026-10-01T00:00:00Z&end=2026-10-08T00:00:00Z
```

Without them, it answers `422 enrichment_needs_a_window`. A dataset over
analysis notes or facts alone reads the period too, and the latest day without
one; every other dataset ignores them. An instant without an offset answers
`400 bad_request`. A next link keeps the period.

## Errors

The feed answers errors in OData's own format, not the REST envelope, with the
header `OData-Version: 4.0`:

```json
{
  "error": {
    "code": "bad_request",
    "message": "$top is given more than once"
  }
}
```

The codes are those of the [Errors](/guides/errors) guide, plus `too_deep`. A
validation error carries `details`, each with `code`, `message` and `target`.
A project of the demo environment serves no feed: `409 conflict`.

## Rate limits

The feed counts each key on its own counter: 600 requests per minute by
default, since a refresh fetches every page. Each request also spends the
company's daily budget, shared with REST. A `429` carries `Retry-After`; see
[Rate limits](/guides/rate-limits).
