# WebSocket API

SoccerFootball.info is the first soccer API to offer a complete WebSocket real-time data service. Get live match events, real-time statistics, and live betting odds updates delivered instantly to your application through a persistent WebSocket connection — no polling, no delays.

Our WebSocket infrastructure is built for speed and reliability, with servers in Europe (EU) and Asia (AS) to ensure optimal connectivity worldwide.

## Why WebSocket for Soccer Data?

Traditional REST API polling introduces latency and wastes bandwidth. Every poll request takes time, and most responses contain no new data. Our WebSocket API pushes data to your application the instant it changes, making it ideal for:

* **Live score trackers and widgets** — display goals and match events as they happen
* **Real-time betting platforms** — react to odds changes and match events instantly
* **In-play statistics dashboards** — show possession, corners, shots, and cards in real-time
* **Automated trading systems** — execute strategies based on live odds and statistics movements
* **Mobile applications** — push notifications triggered by real-time match events
* **Fantasy sports platforms** — update player performance data live during matches

## Ultra-Low Latency with MAIN\_REALTIME

The [MAIN\_REALTIME](/websocket/channels/main-realtime.md) channel, exclusive to MEGA plan subscribers, delivers match events (goals, kickoffs, halftime, match end) with the absolute lowest latency available in the market.

When milliseconds matter — in live betting arbitrage, in-play trading, or competitive fantasy sports — MAIN\_REALTIME gives you the edge over any other soccer data provider.

## Available Channels

We offer 6 WebSocket channels to cover every real-time soccer data need:

### Match Events

* [**MAIN**](/websocket/channels/main.md) — Key match events: goals, halftime, match start and end. Available from PRO plan.
* [**MAIN\_REALTIME**](/websocket/channels/main-realtime.md) — Same events as MAIN with ultra-low latency delivery. MEGA plan only.

### Live Statistics

* [**STATS**](/websocket/channels/stats.md) — Complete statistics snapshots including possession, attacks, shots, corners, fouls, cards, and xG. Available from ULTRA plan.
* [**STATS\_REALTIME**](/websocket/channels/stats-realtime.md) — Real-time statistics deltas, delivering only changed values for instant updates and minimal bandwidth. MEGA plan only.

### Live Odds

* [**ODDS**](/websocket/channels/odds.md) — Complete odds snapshots for all major markets (1X2, Over/Under, Asian Handicap, Corners, and more) from bet365 and Unibet. Available from ULTRA plan.
* [**ODDS\_REALTIME**](/websocket/channels/odds-realtime.md) — Real-time odds deltas for instant market movement detection. MEGA plan only.

## Competitive Advantages

* **First soccer API with WebSocket** — no other soccer data provider offers real-time WebSocket streaming for matches, statistics, and odds
* **Real-time odds streaming** — get live odds changes from bet365 and Unibet as they happen, not minutes later
* **Real-time statistics** — possession, corners, shots, cards, xG — all delivered instantly as they update
* **Ultra-low latency** — MAIN\_REALTIME channel delivers the fastest match events in the industry
* **Low bandwidth** — REALTIME channels send only changed data (deltas), minimizing network usage
* **Flexible subscriptions** — subscribe to all matches, a single match, or an entire league
* **Reliable infrastructure** — EU and AS server regions for optimal connectivity worldwide

## Getting Started

1. Subscribe to a [plan that includes WebSocket access](/price-and-limits.md) (PRO or higher)
2. Obtain a WebSocket token via the [/v1/ws/new](/v1/ws/new.md) REST endpoint
3. Connect to the WebSocket server and [subscribe to channels](/websocket/getting-started.md)
4. Start receiving real-time data

For complete integration instructions, code examples in JavaScript and Python, and detailed channel documentation, see the [WebSocket Getting Started guide](/websocket/getting-started.md).

## Bridging REST and WebSocket

Our WebSocket system uses its own real-time IDs for matches, teams, and championships. To seamlessly bridge between REST API data and WebSocket real-time data, use these dedicated mapping endpoints:

* [/v1/live/ws](/v1/live/live-ws.md) — Live matches with dual ID mapping (WebSocket + REST IDs)
* [/v1/championships/ws](/v1/championships/ws.md) — Championships with dual ID mapping
* [/v1/teams/ws](/v1/teams/ws.md) — Teams with dual ID mapping

These endpoints return both the `ws_realtime` ID (used in WebSocket channels) and the `rest_releated` ID (used in REST API endpoints) for every entity, enabling you to cross-reference data between the two systems effortlessly.


---

# Agent Instructions: 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://info.soccerfootball.info/websocket-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.
