> ## Documentation Index
> Fetch the complete documentation index at: https://docs.limitless.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# Market Data

> Subscribe to price and orderbook updates and read the newPriceData and orderbookUpdate payloads

This page covers subscribing to price and orderbook updates with `subscribe_market_prices`, and the `newPriceData` and `orderbookUpdate` payloads that subscription delivers.

## Subscribing to market data

Subscribe to price and orderbook updates by emitting `subscribe_market_prices`:

```typescript theme={null}
// AMM price updates
socket.emit('subscribe_market_prices', {
  marketAddresses: ['0x1234...']
});

// CLOB orderbook updates
socket.emit('subscribe_market_prices', {
  marketSlugs: ['btc-100k-weekly']
});

// Both at once (recommended to avoid overwriting subscriptions)
socket.emit('subscribe_market_prices', {
  marketAddresses: ['0x1234...'],
  marketSlugs: ['btc-100k-weekly']
});
```

<Warning>
  Subscriptions **replace** previous ones. If you want both AMM prices and CLOB orderbook, send both `marketAddresses` and `marketSlugs` together in a single call.
</Warning>

### Initial snapshot

Right after the `system` acknowledgement, the server emits one `orderbookUpdate` per CLOB slug in your subscription with the full current book. This happens on every `subscribe_market_prices` call, including a re-subscribe over a live connection, and it covers every slug in the new set, not only the ones you added. A market with no resting orders still gets its snapshot: `bids` and `asks` are empty arrays and `midpoint` is `0.5`.

The snapshot carries the same `orderbook` object as [`GET /markets/{slug}/orderbook`](/api-reference/trading/orderbook) minus `lastTradePrice`, so you can seed local state from the socket alone.

Two cases do not produce a snapshot:

* A slug that does not resolve to a market. It is listed in the acknowledgement's `markets` array and joined, but no book is sent.
* A resolved market. It is dropped from `markets` and nothing is sent. If every requested slug is resolved you get an `error` event instead.

If a slug you expect is missing after the acknowledgement, fetch it over REST.

A re-subscribe replaces the previous subscription, so there is a brief gap in live frames between the two calls. The snapshots that follow close it: replace your local copy of each book with its snapshot, and use `version` to discard any live frame that arrives with a lower value (see [`orderbookUpdate`](/developers/websocket/market-data#orderbookupdate)).

AMM addresses receive an initial `newPriceData` the same way, with `blockNumber` set to `0`, when a price is available.

## Event payloads

### `newPriceData`

```json theme={null}
{
  "marketAddress": "0x1234...",
  "updatedPrices": {
    "yes": "0.65",
    "no": "0.35"
  },
  "blockNumber": 12345678,
  "timestamp": "2024-01-01T00:00:00.000Z"
}
```

<Info>
  **Looking for individual events?** `orderbookUpdate` is market-wide state, not an event feed. For discrete events:

  * **Your own orders, in real time** — [`subscribe_order_events`](/developers/websocket/order-events). One event per lifecycle change, authenticated, and it only ever carries your own orders.
  * **Every mined trade in a market** — [Get Market Events](/api-reference/trading/market-events). Public, newest first, paginated. Cached, so not real time, and mined trades only: no placements or cancellations.

  There is no public WebSocket stream of every trade in a market. Market-wide over WebSocket is the coalesced book only.
</Info>

### `orderbookUpdate`

Emitted for CLOB markets when the book changes (new bids/asks, removals, or fills). `orderbook` carries the full updated book. Each side is a sorted array of price levels.

Updates are **coalesced**: several changes in quick succession arrive as a single message, so on a busy market one frame can represent several fills. Each message is the resulting book, not a list of what changed, so replace your local copy with what arrives rather than diffing consecutive messages or counting frames as events.

```json theme={null}
{
  "marketSlug": "btc-100k-weekly",
  "orderbook": {
    "bids": [
      { "price": 0.53, "size": 100 },
      { "price": 0.52, "size": 250 }
    ],
    "asks": [
      { "price": 0.55, "size": 80 },
      { "price": 0.56, "size": 300 }
    ]
  },
  "version": 48213,
  "timestamp": "2024-01-01T00:00:00.000Z"
}
```

| Field            | Type                                | Description                                                                                                                                                                                                                                                                                                                                                                                            |
| ---------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `marketSlug`     | `string`                            | CLOB market slug                                                                                                                                                                                                                                                                                                                                                                                       |
| `orderbook.bids` | `{ price: number, size: number }[]` | Bid levels, highest price first                                                                                                                                                                                                                                                                                                                                                                        |
| `orderbook.asks` | `{ price: number, size: number }[]` | Ask levels, lowest price first                                                                                                                                                                                                                                                                                                                                                                         |
| `version`        | `number`                            | Publisher sequence for the book. It increases with every frame for a market while the same publisher is active and can restart after a backend failover, so do not treat it as contiguous. Use it to drop a frame that arrives out of order right after subscribing. A snapshot served from the database fallback carries `0`; accept it only if you have not yet received a live frame for that slug. |
| `timestamp`      | `string`                            | ISO-8601 event timestamp                                                                                                                                                                                                                                                                                                                                                                               |

<Note>
  `price` and `size` are JSON numbers; coerce defensively to preserve decimal precision. For a one-shot snapshot, use [`GET /markets/{slug}/orderbook`](/api-reference/trading/orderbook), which returns the same shape. You also receive this message once per CLOB slug immediately after `subscribe_market_prices`, carrying the current book (see [Initial snapshot](/developers/websocket/market-data#initial-snapshot)).
</Note>

## Related

* [WebSocket overview](/developers/websocket/overview): connection details, handshake authentication, and the full event reference
