guides

WebSocket vs polling: which to use for live odds

By · Published · Updated · 4 min read

Use polling for pre-match odds and anything that refreshes once a minute or slower. Use a WebSocket for live games and for more than 2 books at once: the server pushes each price change, and you stop spending requests on prices that did not move.

What is the difference between polling and a WebSocket?

Polling is your code asking "anything new?" on a timer. A WebSocket is one open connection where the server sends each change when it happens.

Polling (REST)WebSocket
Who starts each updateYour client, on a timerThe server, on each price change
What you receiveThe full response or a list of changes since your last callA snapshot once, then only changed prices
LimitRequests per second on your planConnections on your plan
After a network dropCall againReconnect and resume from your last sequence number
Code neededAn HTTP client and a loopA WebSocket client and a reconnect handler

How does polling work with PricedOdds?

You call GET /v1/changes with the cursor from your last response. The API returns what changed since then, plus the next cursor.

curl -s "https://api.pricedodds.com/v1/changes?since=$CURSOR" \
  -H "Authorization: Bearer $PRICEDODDS_API_KEY"

Poll no faster than your plan's request rate. Solo allows 1 request per second, Starter 3, Growth 5 and All-Access 10. When you go over, the API answers rate_limited and a Retry-After header tells you how long to wait.

One request per second is 86,400 requests a day. That budget also has to cover every other call your app makes.

How does the WebSocket work?

You connect once, subscribe to leagues, books and markets, and receive price deltas. There are four steps.

  1. Connect to wss://api.pricedodds.com/v1/stream and authenticate.
  2. Send a subscribe message. Every field is optional.
  3. Apply the snapshot frames, which hold the current state.
  4. Apply each price frame by selection_id and book.
import WebSocket from "ws";

const ws = new WebSocket("wss://api.pricedodds.com/v1/stream");
let lastSeq = 0;

ws.on("open", () => {
  ws.send(JSON.stringify({ type: "auth", key: process.env.PRICEDODDS_API_KEY }));
});

ws.on("message", (raw) => {
  const msg = JSON.parse(raw);
  if (msg.seq) lastSeq = msg.seq;

  if (msg.type === "ready") {
    ws.send(JSON.stringify({
      type: "subscribe",
      leagues: ["nba", "nfl"],
      books: ["draftkings", "fanduel"],
      markets: ["moneyline", "spread", "total"],
      include: ["best", "fair"],
    }));
  }

  if (msg.type === "price") {
    for (const change of msg.data.changes) {
      // decimal: null means the book pulled that price
      console.log(msg.data.book, change.market, change.side, change.line, change.american);
    }
  }
});

Run this on a server. Never ship your key to a browser.

A price frame carries the event, the book, and a changes list. Each change has the market, period, side, line, decimal, american and prev_american. With include: ["best","fair"], the frame also carries the best price across your books and the no-vig fair price for each changed selection.

What happens when the connection drops?

You reconnect and send resume with the highest seq you stored. The server replies resume_ok and sends the frames you missed.

{"type":"resume","since_seq":1048213,"leagues":["nba","nfl"],"books":["draftkings","fanduel"]}

If your sequence number is too old, the server sends resync and a fresh snapshot. Three more rules from the docs:

  • The server pings every 20 seconds.
  • A client that cannot keep up is closed with code 4008 (slow_consumer). Reconnect and resume.
  • Opening more connections than your plan allows closes the socket with code 4029.

When is polling enough?

  • Pre-match tools. A line that you refresh every minute does not need a stream.
  • Daily or hourly jobs. Models, reports and alerts that run on a schedule.
  • One or two games at a time. A few calls per second cover it.
  • Serverless code. Functions that start, run and stop cannot hold a connection open.

When do you need a WebSocket?

  • Live odds. Prices move during play, and a timer either misses moves or burns requests.
  • Many books or leagues at once. One subscription covers all of them. With polling, each extra book or league competes for the same request budget.
  • Line-movement alerts. Each price frame includes prev_american, so you see the move without storing the old price yourself.
  • A local copy of the market. Snapshot plus deltas keeps an in-memory book in sync.

What does the WebSocket cost?

WebSocket is included in All-Access at $349 a month. On the other plans it is an add-on.

PlanREST per monthWebSocket add-onTotal with WebSocketConnections
Solo (any 2 books)$39+$59$981
Starter (any 5)$99+$129$2281
Growth (any 10)$179+$169$3482
All-Access (all 15 + Pinnacle)$349Included$3493

Pinnacle is a +$99 a month add-on outside All-Access, and the add-on includes WebSocket for Pinnacle.

Without the add-on, a WebSocket connection is refused with plan_lacks_ws, and GET /v1/changes is the way to stay current. Every plan starts with a 3-day free trial, which includes 1 connection. Signup takes a $1 card verification that is refunded immediately, and the plan you pick is charged from day 4 unless you cancel before the trial ends. See pricing and the WebSocket docs. Measured latency: in a 20-minute test on 23 November 2026, live prices reached an external client in 486 ms at the median and 2,399 ms at p95 from the upstream source timestamp, upstream delay included. Method and tables by book are on the latency page.

Can I use both?

Yes. Use REST for the first load, for lookups such as GET /v1/events?league=nba, and for recovery. Use the WebSocket for everything that changes while your app is running.

Which books have live prices is in in-play coverage by sportsbook.