Arkstone
Contact us
Glossary

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.

PollingWebSocket
Who starts each updateThe client asksThe server pushes
Delay after a changeUp to one polling intervalAs soon as it is sent
Traffic when nothing movesRepeated empty requestsSmall 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.

  • Odds API: the data a WebSocket usually carries in betting.
  • Suspension: the message that must never arrive late.
  • In-play: where speed matters most.
FAQ

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.

Related

Keep reading

01 / TermOdds APIA data service that delivers live betting prices, market status and results to an operator's platform for its own markets.
02 / TermSuspensionA short pause in a market, such as while a ball is bowled or a goal is checked. New bets wait and are accepted or refused when it reopens.
03 / ArticleWebSocket or polling for oddsSpeed, reliability and resume after a drop: when a stream wins and when plain polling is enough.
Next step

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.