> For the complete documentation index, see [llms.txt](https://docs.matchplay.events/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.matchplay.events/real-time-api.md).

# Real time API

{% hint style="info" %}
This page is still a work in progress. Please report issues or omissions.
{% endhint %}

## Connecting to the web socket

You connect to the web socket using the following URL:

{% code overflow="wrap" %}

```http
wss://ws.app.matchplay.events/app/tnrxzkahdeullnwje83e?protocol=7&client=js&version=8.5.0&flash=false
```

{% endcode %}

The web socket connection URL may change in the future, but will be updated here if it does.

## Subscribing to the tournament channel

After connecting to the web socket you must subscribe to the channel that corresponds to the tournament you want to receive events for. Replace **{TOURNAMENT\_ID}** with the tournament id for the tournament and the the following message to the socket

```json
{
    "event":"pusher:subscribe",
    "data":{
        "auth":"",
        "channel":"tournaments.{TOURNAMENT_ID}"
    }
}
```

## Receiving events

After you have subscribed to the channel you will start to receive events. The following events are possible.

| Event name                         | Payload                                                                                                                                           |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `TournamentUpdated`                | Payload contains the updated tournament model                                                                                                     |
| `RoundCreatedOrUpdated`            | Payload contains the round model. Use the [Get games](/games-api.md#get-games) endpoint with the `round` parameter to get the games for the round |
| `RoundsDeleted`                    | Payload contains the round ids for the deleted rounds                                                                                             |
| `GameCreatedOrUpdated`             | Payload contains the updated game model                                                                                                           |
| `GamesDeleted`                     | Payload contains the game ids for the deleted games                                                                                               |
| `SinglePlayerGameCreatedOrUpdated` | Payload contains the updated game model                                                                                                           |
| `SinglePlayerGamesDeleted`         | Payload contains the game ids for the deleted games                                                                                               |
| `ArenasAdded`                      | Payload contains the arena ids for the added arenas. [Resolve any unknown objects](/players-and-arenas-api.md).                                   |
| `PlayersAdded`                     | Payload contains the player ids for the added players. [Resolve any unknown objects](/players-and-arenas-api.md).                                 |
| `PlayersChanged`                   | Payload contains the player ids for the changed players. [Resolve any unknown objects](/players-and-arenas-api.md).                               |
| `ArenasChanged`                    | Payload contains the arena ids for the changed arenas. [Resolve any unknown objects](/players-and-arenas-api.md).                                 |
| `QueueChanged`                     | Payload *may* contain the updated queue models, but may not in case the queue is too large                                                        |
