> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oddspapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速入门指南 - 几分钟内连接Odds API

> 几分钟内开始使用OddsPapi。连接WebSocket网关，使用API密钥认证，订阅频道，并流式传输实时体育赔率数据。

## 1) 连接

网关地址：

* **ws**: `wss://v5.oddspapi.io/ws`

<Tabs>
  <Tab title="JavaScript (Node)">
    ```js theme={null}
    import WebSocket from "ws";

    const ws = new WebSocket("wss://v5.oddspapi.io/ws");

    ws.on("open", () => {
      ws.send(JSON.stringify({ type: "login", apiKey: process.env.ODDS_API_KEY, lang: "zh" }));
    });

    ws.on("message", (data) => {
      const msg = JSON.parse(data.toString());
      console.log(msg.type ?? msg.channel, msg);
    });
    ```
  </Tab>

  <Tab title="Python">
    ```py theme={null}
    import json
    import os
    import websocket

    def on_open(ws):
        ws.send(json.dumps({
            "type": "login",
            "apiKey": os.environ["ODDS_API_KEY"],
            "lang": "zh",
        }))

    def on_message(ws, message):
        msg = json.loads(message)
        print(msg.get("type") or msg.get("channel"), msg)

    ws = websocket.WebSocketApp(
        "wss://v5.oddspapi.io/ws",
        on_open=on_open,
        on_message=on_message,
    )
    ws.run_forever()
    ```
  </Tab>
</Tabs>

## 2) 最小登录消息

```json theme={null}
{
  "type": "login",
  "apiKey": "YOUR_API_KEY",
  "lang": "zh"
}
```
