guides
How to stream every book on your plan with one WebSocket connection
One WebSocket connection to PricedOdds carries every book, sport and league on your plan. In a 30-second run on November 23, 2026, one connection on All-Access received price changes from 15 books and 351 events. This article shows the script, what arrived and how to narrow the stream.
What does one connection carry?
You connect once to wss://api.pricedodds.com/v1/stream, authenticate and subscribe. Every field of the subscription is optional. With no leagues, sports or books, you get everything on your plan: a snapshot of the current state, then each price change.
What is the script?
It needs Node 22 or later, which has a built-in WebSocket client, and no packages.
// one-connection.mjs: one WebSocket for every book, sport and league on your plan.
// Node 22 or later. Usage: PRICEDODDS_API_KEY=... node one-connection.mjs
const KEY = process.env.PRICEDODDS_API_KEY;
const SECONDS = Number(process.env.SECONDS ?? 30);
const frames = {};
const books = new Map();
const events = new Set();
const ws = new WebSocket("wss://api.pricedodds.com/v1/stream");
ws.addEventListener("open", () => ws.send(JSON.stringify({ type: "auth", key: KEY })));
ws.addEventListener("message", (event) => {
const frame = JSON.parse(event.data);
frames[frame.type] = (frames[frame.type] ?? 0) + 1;
if (frame.type === "ready") {
console.log("plan:", frame.data.plan, "books:", frame.data.books.length);
// No leagues, sports or books: everything on the plan, on this one connection.
ws.send(JSON.stringify({ type: "subscribe", markets: ["moneyline", "spread", "total"] }));
}
if (frame.type === "price") {
books.set(frame.data.book, (books.get(frame.data.book) ?? 0) + frame.data.changes.length);
events.add(frame.data.event_id);
}
if (frame.type === "error") console.error(frame);
});
setTimeout(() => {
console.log("frames:", frames);
console.log("books with price changes:", books.size, "events:", events.size);
console.log([...books].sort((a, b) => b[1] - a[1]).map(([book, n]) => `${book} ${n}`).join(", "));
ws.close();
}, SECONDS * 1000);Run it with PRICEDODDS_API_KEY=... node one-connection.mjs.
What arrived in 30 seconds?
Our run on November 23, 2026 with an All-Access key, subscribed to moneyline, spread and total. It is an example of one evening, not a promise of volume.
| Frame type | Frames |
|---|---|
ready | 1 |
snapshot | 326 |
price | 1,920 |
score | 81 |
event | 1 |
The price frames carried 10,921 price changes from 15 books across 351 events.
| Book id | Price changes |
|---|---|
fanatics | 3,616 |
bet365 | 1,884 |
novig | 1,158 |
polymarket | 1,155 |
kalshi | 651 |
betmgm | 543 |
hardrock | 396 |
prophetx | 388 |
caesars | 345 |
betrivers | 242 |
fliff | 214 |
draftkings | 150 |
fanduel | 102 |
betonline | 73 |
circa | 4 |
The sixteenth book on the plan sent no change to those three markets in that half minute.
How do I narrow the stream?
Add filters to the subscription. They combine.
{"type":"subscribe","sports":["tennis"],"status":"live","markets":["moneyline"]}leaguesandsports: lists of ids. Find league ids withGET /v1/leagues, which needs no key.books: some of the books on your plan.markets: market keys fromGET /v1/markets.status:"live"for in-play events only. The default is"scheduled,live".
A mistyped id returns an error frame with did_you_mean.
How many connections do I get?
Solo and Starter have 1, Growth has 2 and All-Access has 3. During the trial every plan has 1. One is enough for most single-server tools, because one connection carries the whole plan. If your client cannot keep up, the server closes the socket with code 4008, and you reconnect and resume from the last seq.
Which markets are pushed?
The market types marked realtime: true in GET /v1/markets and in the coverage file. The current list, with what each one is, is on the coverage page.
Where do I start?
The frames are in the WebSocket docs, a longer example is in the JavaScript tutorial, and measured delivery times are on the latency page. The WebSocket is included in All-Access and is an add-on on the other plans. Every plan starts with a 3-day free trial with a $1 card verification that is refunded immediately. The plan you pick at signup is charged from day 4 unless you cancel before the trial ends. See pricing or create an account.
Each book on your plan arrives the same way, for example DraftKings prices on the same socket.