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

# Market Updates

> Subscribe to real-time market changes

Subscribe to all changes in markets on sx.bet. You will get updates when:

* A new market is added
* A market is removed (set to `INACTIVE`)
* A market's fields have changed (for example, game time has changed or the market has settled)

**CHANNEL NAME**

`markets:global`

**MESSAGE PAYLOAD FORMAT**

See [the markets section](/api-reference/get-markets-active) for the format of the message.

***

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

  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("markets:global", handler)
      await sub.subscribe()
      await asyncio.Future()  # keep running

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

The above returns JSON structured like this:

```json theme={null}
[
  {
    "gameTime": 1625674200,
    "group1": "MLB",
    "leagueId": 171,
    "leagueLabel": "MLB",
    "line": 7,
    "liveEnabled": false,
    "marketHash": "0x384c6d8e17c9b522a17f7bb049ede7d3dd9dd1311232fe854e7f9f4708dfc4c",
    "outcomeOneName": "Over 7.0",
    "outcomeTwoName": "Under 7.0",
    "outcomeVoidName": "NO_GAME_OR_EVEN",
    "sportId": 3,
    "sportLabel": "Baseball",
    "sportXEventId": "L7186379",
    "status": "ACTIVE",
    "teamOneName": "Tampa Bay Rays",
    "teamTwoName": "Cleveland Indians",
    "type": 2
  }
]
```
