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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.matchplay.events/real-time-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
