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

# Order Book Updates

> Subscribe to real-time changes in a market's order book

<Warning>
  This WebSocket API will be deprecated on July 1, 2026. See the [Migration Guide](/api-reference/centrifugo-migration) to move to the Centrifuge-based API.
</Warning>

Subscribe to changes in a particular order book. You will receive updates when orders are filled, cancelled, or posted. Note that for performance reasons, updates are delayed by at most 100ms.

**CHANNEL NAME FORMAT**

`order_book_v2:{token}:{marketHash}`

| Name       | Type   | Description                                               |
| ---------- | ------ | --------------------------------------------------------- |
| token      | string | Restrict updates to only orders denominated in this token |
| marketHash | string | The market to subscribe to                                |

**MESSAGE PAYLOAD FORMAT**

The message payload is an array of JSON objects representing each object with the fields below. Note that these are the same fields as mentioned in [the orders section](/api-reference/get-orders), with an additional `status` and `updateTime` field.

| Name                     | Type    | Description                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| orderHash                | string  | A unique identifier for this order                                                                                                                                                                                                                                                                                                                            |
| status                   | string  | "ACTIVE" if this order is still valid, "INACTIVE" if cancelled, "FILLED" if completely filled                                                                                                                                                                                                                                                                 |
| fillAmount               | string  | How much this order has been filled in Ethereum units up to a max of `totalBetSize`. See [the token section](/api-reference/unit-conversion) of how to convert this into nominal amounts                                                                                                                                                                      |
| pendingFillAmount        | string  | What amount is pending fill in Ethereum units up to a max of `totalBetSize`. See [the token section](/api-reference/unit-conversion) of how to convert this into nominal amounts                                                                                                                                                                              |
| maker                    | string  | The market maker for this order                                                                                                                                                                                                                                                                                                                               |
| totalBetSize             | string  | The total size of this order in Ethereum units. See [the token section](/api-reference/unit-conversion) for how to convert this into nominal amounts.                                                                                                                                                                                                         |
| percentageOdds           | string  | The odds that the `maker` receives in the sportx protocol format. To convert to an implied odds divide by 10^20. To convert to the odds that the taker would receive if this order would be filled in implied format, use the formula `takerOdds=1-percentageOdds/10^20`. See [the unit conversion section](/api-reference/unit-conversion) for more details. |
| expiry                   | number  | Depcreated field: the time in unix seconds after which this order is no longer valid. Always 2209006800                                                                                                                                                                                                                                                       |
| apiExpiry                | number  | The time in unix seconds after which this order is no longer valid                                                                                                                                                                                                                                                                                            |
| salt                     | string  | A random number to differentiate identical orders                                                                                                                                                                                                                                                                                                             |
| isMakerBettingOutcomeOne | boolean | `true` if the maker is betting outcome one (and hence taker is betting outcome two if filled)                                                                                                                                                                                                                                                                 |
| signature                | string  | Signature of the maker on this order                                                                                                                                                                                                                                                                                                                          |
| updateTime               | string  | Server-side clock time for the last modification of this order.                                                                                                                                                                                                                                                                                               |
| sportXeventId            | string  | The event related to this order                                                                                                                                                                                                                                                                                                                               |

Note that the messages are sent in batches in an array. If you receive two updates for the same `orderHash` within an update, you can order them by `updateTime` after converting the `updateTime` to a BigInt or BigNumber.

***

```javascript theme={null}
const marketHash =
  "0x04b9af76dfb92e71500975db77b1de0bb32a0b2413f1b3facbb25278987519a7";
const token = "0xa25dA0331C0853FD17C47c8c34BCCBAaF516C438";
const channel = realtime.channels.get(`order_book_v2:${token}:${marketHash}`);
channel.subscribe((message) => {
  console.log(message.data);
});
```

The above command returns JSON structured like this

```json theme={null}
[
  {
    "orderHash": "0x7bd76648f589f3e272d48294d8881fe68aae7704f7b2ef0a50bf612be44271",
    "status": "INACTIVE",
    "fillAmount": "2000000000",
    "pendingFillAmount": "1000000000",
    "maker": "0x9883D5e7dC023A441A81Ef95af406C69926a0AB6",
    "totalBetSize": "500000000",
    "percentageOdds": "750000000000000000000",
    "expiry": 1747500000000,
    "apiExpiry": 1747500000000,
    "salt": "12345678901234567890",
    "isMakerBettingOutcomeOne": false,
    "signature": "0xbf099ab02255d5e2a9e063dc43a7afe96e65f5e8fc2ed3d2ba60b0a3fcadb3441bf32271293e85b7a795c9d86a2384035a0da3285113e746547e236bc58885e01",
    "updateTime": 1747490000000,
    "sportXeventId": "L13772588"
  }
]
```
