WebSocket. The line that stays open.
How live prices reach a betting platform without it having to keep asking.
Definition
A WebSocket is a network connection between a client and a server that stays open once it is made. Either side can send a message at any time, so the server can push a change the moment it happens rather than waiting to be asked.
How a WebSocket works
The connection starts as an ordinary web request that asks to upgrade. Once the server agrees, the same connection carries small messages both ways for as long as it stays up.
Polling works the other way round. The client asks the server every few seconds whether anything has changed. Most of those requests come back with nothing new, and a change that lands just after a request waits for the next one.
| Polling | WebSocket | |
|---|---|---|
| Who starts each update | The client asks | The server pushes |
| Delay after a change | Up to one polling interval | As soon as it is sent |
| Traffic when nothing moves | Repeated empty requests | Small heartbeats only |
Why odds feeds use WebSockets
Live prices change many times a minute, and a suspension has to arrive before the next bet does. A late suspension is how a book loses money, which matters most in in-play markets.
Good feeds add two safety features. A sequence number on every message shows at once whether one went missing. A heartbeat proves the line is alive while prices are quiet.
WebSockets on our platform
Our fancy odds API streams fancy, bookmaker and results data over a WebSocket, with a heartbeat every 50 ms and a sequence number on every message. After a drop, a client resumes from the last number it processed. Teams that prefer plain HTTP can take a REST snapshot and long-poll for changes instead. The odds API entry covers the rest.
Related terms
- Odds API: the data a WebSocket usually carries in betting.
- Suspension: the message that must never arrive late.
- In-play: where speed matters most.
WebSocket questions
Is a WebSocket faster than a REST API for live odds?
Usually, yes. A WebSocket pushes each change as it happens, while REST waits for the client to ask.
What is a WebSocket heartbeat?
A tiny message sent at a fixed interval to show the connection is alive. On our odds stream it arrives every 50 ms.
What happens when a WebSocket connection drops?
The client reconnects. On our stream it resumes from the last sequence number it processed, so nothing is skipped.
Keep reading
See the whole platform on one call.
30 minutes, no slides. We walk you through the platform or the API you need, answer every question, and send a written price, often the same day.