guides

How to measure odds API latency yourself

By · Published · Updated · 4 min read

You can measure the latency of an odds feed with 2 timestamps and your own clock. On the PricedOdds WebSocket, sourceChangedAt gives the time from the upstream source to you, and ts gives the time from PricedOdds ingest to you. This guide has a script that computes both, and explains what each number includes.

Which timestamps does a price frame carry?

sourceChangedAt is the market time of the upstream source, in ISO-8601 (UTC, ending in Z). It is omitted when the source does not send a time. ts on a WebSocket frame, and changedAt and updatedAt on snapshots and REST, are when PricedOdds ingested the frame. The meaning of changedAt, updatedAt and ts did not change.

This is a price frame from the live stream on 23 November 2026, with the ids shortened. sourceChangedAt is on each change when the source sent a time:

{ "type": "price", "seq": 50681646, "ts": "2026-11-23T19:41:18.289Z",
  "data": { "event_id": "evt_fx2i...", "book": "bet365",
    "changes": [ { "market_id": "mkt_7sh7...", "market": "spread", "period": "game", "selection_id": "sel_rsj2...",
      "side": "home", "line": -0.5, "decimal": 2.55, "american": 155, "prev_american": 148,
      "sourceChangedAt": "2026-11-23T19:41:17.870Z" } ] } }

On REST, each price object carries the same field next to updatedAt and changedAt. This one is from GET /v1/odds on the same day:

{ "book": "draftkings", "decimal": 2.25, "american": 125, "implied": 0.4444,
  "updatedAt": "2026-11-23T19:09:48.936Z", "changedAt": "2026-11-23T17:53:11.802Z",
  "sourceChangedAt": "2026-11-23T15:06:42.870Z" }

The frames are described in the WebSocket docs. The prices are there only to show the fields, and nothing here is betting advice.

What are the two numbers?

const sourceToClientMs = Date.now() - Date.parse(change.sourceChangedAt);
const ingestToClientMs = Date.now() - Date.parse(frame.ts);
  • Source to client is the number you feel: from the market time of the upstream source to your code. It includes upstream delay, PricedOdds processing and your network path.
  • Ingest to client starts when PricedOdds already has the frame. It is mostly your network path to the API.

How do I measure it with Node?

This script needs Node 22 or later, which has a built-in WebSocket client. It authenticates with the first message, subscribes, and prints the median and p95 of both series.

// measure-latency.mjs: source -> client and ingest -> client on the PricedOdds WebSocket.
// Node 22 or later. Usage: PRICEDODDS_API_KEY=... node measure-latency.mjs
const URL = process.env.PRICEDODDS_WS_URL ?? "wss://api.pricedodds.com/v1/stream";
const KEY = process.env.PRICEDODDS_API_KEY;
const SECONDS = Number(process.env.SECONDS ?? 120); // how long to measure
const WARMUP = Number(process.env.WARMUP ?? 10);    // seconds skipped after subscribing

const source = [];
const ingest = [];
let subscribedAt = 0;

const ws = new WebSocket(URL);
ws.addEventListener("open", () => ws.send(JSON.stringify({ type: "auth", key: KEY })));
ws.addEventListener("message", (event) => {
  const receivedAt = Date.now();
  const frame = JSON.parse(event.data);
  if (frame.type === "ready") {
    ws.send(JSON.stringify({ type: "subscribe", markets: ["moneyline", "spread", "total"] }));
    subscribedAt = receivedAt;
    return;
  }
  if (frame.type === "error") { console.error(frame); return; }
  if (frame.type !== "price" || receivedAt - subscribedAt < WARMUP * 1000) return;

  ingest.push(receivedAt - Date.parse(frame.ts));
  for (const change of frame.data.changes) {
    if (!change.sourceChangedAt) continue; // the source sent no market time
    const ms = receivedAt - Date.parse(change.sourceChangedAt);
    if (ms >= -2000 && ms <= 30000) source.push(ms); // drop stale or first-seen times
  }
});
ws.addEventListener("close", (event) => console.log("closed", event.code));

function summary(samples) {
  if (samples.length === 0) return { n: 0 };
  const sorted = [...samples].sort((a, b) => a - b);
  const at = (p) => sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))];
  return { n: sorted.length, median: at(0.5), p95: at(0.95) };
}

setTimeout(() => {
  console.log("ingest -> client (ms)", summary(ingest));
  console.log("source -> client (ms)", summary(source));
  ws.close();
}, (SECONDS + WARMUP) * 1000);

Run it with PRICEDODDS_API_KEY=... node measure-latency.mjs. We ran this script against the live API on 23 November 2026 for 60 seconds with an All-Access key. It connected, subscribed and filled both series. Run it with your key to get your own figures.

Which samples should I leave out?

Two kinds, the same ones we leave out.

  • Frames queued during the initial snapshot. They arrive in a burst after you subscribe, so their delay is not the delay of the stream. The script counts price frames only and skips the first seconds.
  • Stale or missing source times. Keep source to client samples from -2 s to 30 s. A source time older than 30 seconds usually means the market was first seen, not that the frame was slow. In our window 47% of ingest samples had no usable source time.

How do I correct for my clock?

Both numbers subtract a server time from your local time, so an offset in your clock moves every sample by the same amount. Synchronize the machine with NTP before you measure. In our test the client clock was 38.4 ms behind the API host, and we added that to every sample.

A clock that is off can make the result meaningless. When we ran the script above from a second machine, its clock was about 0.8 seconds behind, and both series came out negative. We do not publish those numbers. The figures on the latency page come from the clock-corrected test.

What did we measure with the same method?

Live prices reached our test client in 0.49 seconds at the median from the upstream source timestamp, and 2.4 seconds at p95. Across pre-match and live, the median was 0.75 seconds. Of that, PricedOdds processing added 0.43 milliseconds at the median.

Measured on 23 November 2026, 18:40 to 19:00 Europe/Madrid (UTC+1) (19 minutes 49 seconds), from one external client on a separate machine, on All-Access with all 16 books, corrected for clock offset. These figures include delay from the upstream source, which PricedOdds does not control. They will be updated after a 72-hour measurement. The tables by book and the caveats are on the latency page.

Why will my numbers differ?

Your network path to the API is not the same as the test client path. Some books and some pre-match markets have slower source timestamps. A quieter or busier slate changes the mix. If sourceChangedAt is missing on a change, you can still measure ingest to client with ts.

The WebSocket is included in All-Access and is an add-on on the other plans. See pricing, or create an account to try it.