> ## 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.

# Best Odds

> Subscribe to real-time best odds updates

Subscribe to best odds changes across all order books. 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**

`best_odds:global`

<Info>
  The channel no longer includes a `baseToken` parameter. All token denominations are now broadcast on this single global channel.
</Info>

**MESSAGE PAYLOAD FORMAT**

| Name                     | Type    | Description                                                                                                                                                                                                                                           |
| ------------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| baseToken                | string  | The token for the best odds result order                                                                                                                                                                                                              |
| marketHash               | string  | The market for the best odds result                                                                                                                                                                                                                   |
| isMakerBettingOutcomeOne | boolean | Whether the maker is betting outcome one                                                                                                                                                                                                              |
| percentageOdds           | string  | The odds the `maker` receives in the sportx protocol format. To convert to implied odds divide by 10^20. To get taker implied odds: `takerOdds = 1 - percentageOdds / 10^20`. See [unit conversion](/api-reference/unit-conversion) for more details. |
| updatedAt                | number  | Timestamp in milliseconds for when these became the best odds                                                                                                                                                                                         |
| sportId                  | number  | The sport ID for this market                                                                                                                                                                                                                          |
| leagueId                 | number  | The league ID for this market                                                                                                                                                                                                                         |

Messages are sent in batches as an array.

***

<CodeGroup>
  ```javascript JavaScript theme={null}
  // To subscribe
  const sub = client.newSubscription("best_odds:global");

  sub.on("publication", (ctx) => {
    const data = ctx.data;
    // message handler logic
  });

  sub.subscribe();
  ```

  ```python Python theme={null}
  import asyncio
  from centrifuge import Client, PublicationContext, SubscriptionEventHandler

  async def on_publication(ctx: PublicationContext) -> None:
      print(ctx.data)

  async def main():
      client = Client(
          "wss://realtime.sx.bet/connection/websocket",
          token="YOUR_TOKEN",  # from /user/realtime-token/api-key
      )
      await client.connect()
      handler = SubscriptionEventHandler(on_publication=on_publication)
      sub = client.new_subscription("best_odds:global", handler)
      await sub.subscribe()
      await asyncio.Future()  # keep running

  asyncio.run(main())
  ```
</CodeGroup>

The above returns JSON structured like this:

```json theme={null}
[
  {
    "baseToken": "0x1BC6326EA6aF2aB8E4b68c83418044B1923b2956",
    "marketHash": "0xddaf2ef56d0db2317cf9a1e1dde3de2f2158e28bee55fe35a684389f4dce0cf6",
    "isMakerBettingOutcomeOne": true,
    "percentageOdds": "750000000000000000000",
    "updatedAt": 1747500000000,
    "sportId": 1,
    "leagueId": 1236
  }
]
```
