# Market data

The OpenAPI 3.1 document is the full description, including schemas:

https://router.inference.ai.exchange/v1/openapi.json

## `GET /v1/exchange/collections`

List the collections and the models that each holds now.

It needs no credential and names no provider or workspace. The list holds the
presets of the `system` workspace that have a group. A collection that no
listed model matches has an empty `models`.

## `GET /v1/exchange/harnesses`

List the harnesses whose guide the exchange verified in the last 14 days.

The exchange tests the published recipe of each harness against a real
deployment. The list names no deployment, so it needs no credential. It is
empty when it is not available.

## `GET /v1/exchange/lifetime`

Return the jobs and tokens that the exchange has processed in total.

It needs no credential and names no buyer or provider. The totals are zero when
the figures are not available.

## `GET /v1/exchange/list-prices`

List the models that have a list price.

It needs no credential. A model with no list price is not in the list.

## `GET /v1/exchange/markets`

Report the depth of each market.

One row for each served model with a resting offer. A row counts independent
providers, not offers. The exchange groups affiliated accounts and shared
upstreams first, so resellers of one upstream count once.

## `GET /v1/exchange/models`

List each served model that has a live offer, with its price range and depth.

A row says what the model is, what it can do, what it costs and how deep the
market is. It joins `/v1/exchange/markets` and `/v1/exchange/offers`. The query
takes the filters of `/v1/models` that describe a model. A filter that names a
provider or reads the price of one offer gets `400`, because this view names no
provider.

## `GET /v1/exchange/offers`

List the resting offers without their providers.

The models, prices and service commitments are public. The provider of each
offer is not, because a provider name beside a price would show its quote to
its competitors. The list leaves out unverified offers, which a buyer reaches
only by a deployment symbol that names the provider. The list is sorted by
generation rate, cheapest first.

## `GET /v1/exchange/routers`

List the router models that a request can name in `model`.

A router model admits all the models that the exchange lists now, so its
`models` change when providers list and withdraw models. The router models
differ in their rules.

## `GET /v1/exchange/stream`

The live book, over a WebSocket.

Open the socket, then send one `MarketRequest` frame with a credential within
five seconds. A key with the `list` scope is enough. The exchange replies with
a `snapshot` of every resting offer, then a `MarketEvent` frame for each
change: an offer repriced or withdrawn, a provider that connects or
disconnects, and a request that found no offer. An unverified offer appears
only for a workspace that can buy from it. If the exchange refuses the
credential, it sends a `refused` frame and closes the socket.

Set `receipts` on the subscribe frame to also receive the receipts of your
workspace. No other subscriber sees them. This feed names providers, so it
needs a credential, unlike `/v1/exchange/offers`.

A market subscriber that falls behind skips the events it missed. A receipts
subscriber that falls behind is disconnected. It must reconnect and read a new
snapshot of the jobs in flight. The exchange pings every 30 seconds. It closes
the socket when the peer answers no ping or sends no frame for 10 seconds.
