REST Polling vs WebSockets for Live Odds Data

A practical comparison of polling and streaming for live odds. Freshness, credit cost and the break-even point, snapshot plus delta consistency, sequence numbers, reconnection and hybrid designs.

Every integration with a live odds feed eventually faces the same choice: ask for the board on a timer, or hold a connection open and let changes come to you. Either can be correct. A pricing page that refreshes every few minutes doesn't need a socket, and a live trading dashboard can't be built on a 30-second poll. The REST polling vs WebSockets choice is mostly about four things: how fresh the data must be, what it costs, how you keep local state correct, and what happens when the network fails.

This post works through each with PreciseAPI's actual numbers, so the decision comes down to arithmetic. For production streaming client code, see the Node.js WebSocket tutorial.

REST polling vs WebSockets side by side

REST pollingWebSocket stream
EndpointGET /v1/odds and friendswss://api.preciseapi.com/v1/stream
What you receiveThe full current state for your query, every timeA snapshot, then only the markets that changed
FreshnessBounded by your poll intervalDeltas flushed every 250 ms
BillingPer request: 2 credits for /v1/odds1 credit on open, then 1 per connection-minute
Correctness modelEach response stands aloneOrdered messages with sequence numbers
PlansEvery paid plan (pre-game only on Edge and Sharp)Syndicate (10 connections)
Typical failure429 or 5xx on one requestSilent gap or dropped connection

Edge and Sharp are REST-only and pre-game only, so on those plans the question is how to use a polling odds API well, not whether to stream. In-play odds, over REST or the stream, are on Syndicate.

Freshness: what "live" means in each model

With polling, a price change becomes visible at your next request. If you poll every T seconds, a change waits T/2 seconds on average and up to T in the worst case, plus the request round trip. Polling also loses intermediate states. A line that moves out and back between two polls never appears in your data.

Poll intervalAverage delayWorst-case delay
60 s~30 s~60 s
15 s~7.5 s~15 s
5 s~2.5 s~5 s
Streamunder 250 ms batching + network~250 ms + network

On the stream, the server collects changes for each connection and flushes them every 250 ms. Within one window, changes are conflated per market. If a market moves twice in 250 ms, you receive its latest version once. That suits screens, alerts and models that act on current state. If you need every recorded price point for the main full-game markets, use /v1/history rather than trying to reconstruct it from a feed.

Cost: find the break-even before you choose

The two models bill in different units. Polling costs scale with how often you call. A single /v1/odds request costs 2 credits and can return up to 200 events, across several leagues if you comma-separate them. A stream costs 1 credit per minute however many events, books or markets it carries.

For one /v1/odds call per interval, running around the clock:

StrategyCredits per dayCredits per 30 days
Poll every 5 s34,5601,036,800
Poll every 15 s11,520345,600
Poll every 30 s5,760172,800
Poll every 60 s2,88086,400
Poll every 120 s1,44043,200
One stream connection1,44043,200

So one stream connection costs the same as polling a single /v1/odds query every two minutes. Any faster polling costs more than the stream and delivers older data. Polling needs more than one call per cycle when you exceed 200 events or use /v1/props (3 credits, 25 events per call), and every extra call widens the gap.

Two details often get missed:

Rate limits are per account and shared by every key: 300 requests a minute on Edge, 1,200 on Sharp, 3,000 on Syndicate. Five leagues polled every 5 seconds is 60 a minute, a fifth of Edge's budget. Failed requests are never charged. See pricing for allowances.

Consistency: snapshot plus delta

A REST response is self-contained. If one poll fails, you lose nothing except freshness, and the next poll reflects the current state. The cost of that simplicity is that the API doesn't tell you what changed. You have to compute the difference yourself:

const prev = new Map(); // market id -> price signature

async function poll() {
  const url = 'https://api.preciseapi.com/v1/odds?league=nba&markets=moneyline,spread,total&include_suspended=true';
  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.PRECISEAPI_KEY}` } });
  if (res.status === 429 || res.status >= 500) {
    const wait = Number(res.headers.get('retry-after')) || 5;
    return wait * 1000; // not charged; back off and try again
  }
  if (!res.ok) throw new Error(`odds ${res.status}`);

  const { data } = await res.json();
  const seen = new Set();
  for (const event of data) {
    for (const book of event.bookmakers) {
      for (const m of book.markets) {
        seen.add(m.id);
        const sig = `${m.suspended}|${m.outcomes.map((o) => `${o.point ?? ''}@${o.price}`).join('|')}`;
        if (prev.get(m.id) !== sig) onChange(event, book.id, m); // new, moved or (un)suspended
        prev.set(m.id, sig);
      }
    }
  }
  for (const id of prev.keys()) if (!seen.has(id)) { prev.delete(id); onRemoved(id); }
  return 15_000;
}

async function loop() {
  const next = await poll().catch((err) => (console.error(err.message), 30_000));
  setTimeout(loop, next);
}
loop();

Market ids stay stable for a given event, book, market key, period and subject, so a market id is a safe key for diffing. Note the include_suspended=true. REST endpoints leave suspended markets out by default, so without that flag a market whose source stopped reporting looks the same as one that was removed.

The stream does this work for you. On subscribe you receive a snapshot in the same shape as a /v1/odds response. After that, each delta contains changes, which are complete market objects tagged with event_id and book, and removed, which are market ids. Because each change is a full market, applying one is a replacement, not a patch. Replaying the same change twice produces the same state. There are two subtleties:

Sequence numbers: how you know your state is correct

The streaming model fails silently. If one delta goes missing, your board is wrong and nothing visibly breaks. Sequence numbers are what make that detectable:

When you spot a gap, send {"type":"resync"} and ignore deltas until the new snapshot arrives. The server accepts at most one subscribe or resync per second per connection and answers extra requests with a rate_limited error, so throttle on your side. The streaming reference has the full message list.

Reconnection and failure modes

Failures look very different in REST polling vs WebSockets.

Polling fails one request at a time. Handle 429 by waiting Retry-After seconds and handle 5xx with backoff. Neither is charged. Nothing needs rebuilding.

Streaming fails at the connection level, and the close code tells you whether a retry can work:

Close codeMeaningWhat to do
4001Authentication failed, or the key was revoked or expiredStop and alert a human
4002Out of credits, or the key hit its credit capStop and alert a human
4003Streaming isn't included in the plan, or the key is scoped to RESTStop and alert a human
4029Too many concurrent connectionsWait longer, then retry
1013MaintenanceBack off and retry
Anything elseNetwork drop or server restartExponential backoff with jitter

Open streams are re-checked every billing minute. Revoking a key, a downgrade or an exhausted balance closes a stream that is already running, with the matching code. The server also sends WebSocket pings and drops connections that stop answering them. It disconnects clients that fall too far behind reading, rather than buffering for them indefinitely. Keep message handling fast and push heavy work onto a queue.

On the client side, run a watchdog. If nothing arrives for roughly two and a half heartbeat intervals, assume the connection is dead, mark the board stale and reconnect.

Hybrid designs that work

Most production systems end up using both models, so REST polling vs WebSockets is rarely an either-or.

Stream for live state, REST for everything else. Reference endpoints such as /v1/leagues, /v1/sportsbooks and /v1/markets are free, so cache them at startup. Use /v1/events for schedules and /v1/history (the line movement API) for backfilling charts. Keep the socket for streaming odds.

REST bridge during stream outages. If a reconnect takes longer than a few seconds, a slow poll keeps the board roughly current until the next snapshot:

let bridge = null;

function onStreamDown() {
  if (bridge) return;
  bridge = setInterval(() => poll().catch(() => {}), 30_000); // 4 credits/min while active
  markBoardStale(); // tell users prices may lag
}

function onSnapshot(msg) {
  clearInterval(bridge);
  bridge = null;
  loadSnapshot(msg.data); // stream is authoritative again
}

One socket, many readers. Browsers should never hold your API key. Run the stream on a server and fan state out over your own WebSocket or server-sent events, as in the odds screen guide. One connection can feed as many users as your own servers can handle.

Webhooks for sparse events. If you only care about main-market line moves beyond a threshold, signed webhooks push them to you at 1 credit per alert with no connection to maintain. The Discord alert bot tutorial shows a complete relay.

A quick decision guide

Frequently asked questions

Is the WebSocket stream always cheaper than polling?

No. A stream costs 1 credit per minute while it's open, which equals one /v1/odds call every two minutes. If you poll less often than that, or only for short periods, polling is cheaper. Polling more often costs more than the stream.

Does the stream send every single price change?

It sends every market that changed, flushed every 250 ms. If one market changes more than once inside a window, you get its latest version. For a recorded series of main full-game prices, use /v1/history.

What happens to sequence numbers after a reconnect?

They start again on the new connection. After reconnecting you subscribe again and receive a fresh snapshot, which replaces your local state completely, so the new sequence never needs to line up with the old one.

Can I open the stream directly from a browser?

Clients that can't set headers can send {"type":"auth","api_key":"…"} as the first message, but in a browser that still exposes your key to anyone using the page. Keep the stream on a server and fan data out to browsers yourself.

Which plans include WebSocket streaming?

Syndicate includes 10 concurrent connections, along with in-play odds. Edge and Sharp use REST and webhooks for pre-game odds. The live odds API page covers in-play coverage.

Keep reading