> For the complete documentation index, see [llms.txt](https://developer.aiodds.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.aiodds.com/bookmaker-odds/websocket-overview.md).

# WebSocket Overview

## WebSocket Protocol

**MQTT over WebSocket（MQTT v5 Recommended）**

The WebSocket connection uses MQTT over WebSocket protocol and is available through `mq.aiodds.com`. Authenticate with your username and secret. Network access is restricted to allowlisted IP addresses.

* Domain is `mq.aiodds.com`.
* Sample code:

{% code expandable="true" %}

```python
import ssl
import paho.mqtt.client as mqtt
USER = "your user"
SECRET = "your secret"
topics = [
    "match/<user>",
    "odds/<category>/<user>",  # category: 1/2 (1:in-play. 2:pre-match)
]
# Connection callback
def on_connect(client, userdata, flags, rc):
    print("Connected:", rc)
    for topic in topics:
        client.subscribe(topic)
# Message callback
def on_message(client, userdata, msg):
    print(msg.topic, msg.payload)
# WebSocket protocol
def run():
    client_id = f"<user>/<Unique ID string>"
    client = mqtt.Client(client_id=client_id, transport='websockets')
    client.tls_set(cert_reqs=ssl.CERT_NONE)
    client.username_pw_set(username=USER, password=SECRET)
    client.ws_set_options(path='/')
    client.on_connect = on_connect
    client.on_message = on_message
    client.connect("mq.aiodds.com", 443, 10)
    client.loop_forever()
if __name__ == '__main__':
    run()
```

{% endcode %}

## WebSocket ↔ API Mapping

| WebSocket Topic                                               | Corresponding API(s)                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Bookmaker Odds](/bookmaker-odds/websocket/bookmaker-odds.md) | <ul><li><a href="/pages/kVFRlFJ4fW8HmihLZbmK#get-v1-odds-inplay-bookmaker-markets">Get In-Play Odds by Bookmaker</a></li><li><a href="/pages/kVFRlFJ4fW8HmihLZbmK#get-v1-odds-inplay-market-bookmakers">Get In-Play Odds by Market</a></li><li><a href="/pages/hG4geszuxen6RWTvbOxX#get-v1-odds-prematch-bookmaker-markets">Get Pre-Match Odds by Bookmaker</a></li><li><a href="/pages/hG4geszuxen6RWTvbOxX#get-v1-odds-prematch-market-bookmakers">Get Pre-Match Odds by Market</a></li></ul> |
| [Settlement](/bookmaker-odds/websocket/settlement.md)         | [Get Match Settlement](/bookmaker-odds/bookmaker-odds/settlement.md#get-v1-settlement-get)                                                                                                                                                                                                                                                                                                                                                                                                      |
| [Match](/bookmaker-odds/websocket/match.md)                   | <ul><li><a href="/pages/7yJzP2zkNyjr4UynRW04#get-v1-match-list">Search matches</a></li><li><a href="/pages/7yJzP2zkNyjr4UynRW04#get-v1-match-get">Get match by ID</a></li></ul>                                                                                                                                                                                                                                                                                                                 |
| [Match score](/bookmaker-odds/websocket/match-score.md)       | [Get match score by ID](/bookmaker-odds/basic-data/match.md#get-v1-match-score-get)                                                                                                                                                                                                                                                                                                                                                                                                             |


---

# 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, and the optional `goal` query parameter:

```
GET https://developer.aiodds.com/bookmaker-odds/websocket-overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
