Node quickstart

This script makes 4 calls with the built-in fetch of Node 18 or later: books and leagues without a key, then the games of a league and the odds of one game with a key. We ran it on 23 November 2026.

What is the script?

// quickstart.mjs: first calls to the PricedOdds API. Node 18 or later.
// Usage: PRICEDODDS_API_KEY=... node quickstart.mjs
const BASE = "https://api.pricedodds.com/v1";
const KEY = process.env.PRICEDODDS_API_KEY;
const auth = { headers: { Authorization: `Bearer ${KEY}` } };

// 1. No key needed: books and leagues
const books = (await (await fetch(`${BASE}/books`)).json()).data;
console.log("books:", books.length);
const leagues = (await (await fetch(`${BASE}/leagues?q=nba`)).json()).data;
console.log("leagues matching nba:", leagues.map((l) => l.id).join(", "));

// 2. With a key: games of a league
const events = (await (await fetch(`${BASE}/events?league=nba`, auth)).json()).data;
console.log("nba events:", events.length);
const game = events[0];
console.log(game.id, game.away.name, "@", game.home.name, game.startsAt);

// 3. Odds for one game, from every book on your plan
const odds = (await (await fetch(`${BASE}/events/${game.id}/odds?markets=moneyline,spread,total`, auth)).json()).data;
for (const market of odds.markets) {
  for (const selection of market.selections) {
    const best = selection.best;
    console.log(market.market, market.period, selection.side, selection.line ?? "",
      "books:", selection.prices.length, "best:", best.book, best.american, "fair:", selection.fair?.american ?? "n/a");
  }
}

Run it with PRICEDODDS_API_KEY=... node quickstart.mjs.

What does it print?

The first lines of our run on 23 November 2026. Your numbers will differ.

books: 16
leagues matching nba: nba, wnba
nba events: 48
evt_7crncn3koszns4ci Memphis Grizzlies @ Charlotte Hornets 2026-11-24T00:00:00.000Z
moneyline 1h home  books: 14 best: prophetx 125 fair: 127
moneyline 1h away  books: 14 best: fanduel -130 fair: -127

This is an example of the output, not current prices.

What should I change first?

  • The league. Find ids with GET /v1/leagues?q=, which needs no key.
  • The markets. Read keys from GET /v1/markets. Add a period with @, for example moneyline@game.
  • The books. Add books= to keep some of the books on your plan.

What next?

For real time, the WebSocket docs show the stream, and how to measure latency has a script for it. Every endpoint is in the docs. 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.

FAQ

Which Node version do I need?

Node 18 or later, for the built-in fetch. No package is needed.

Why does the script print several periods?

Because a market is returned for every period the books price: full game, halves and quarters. Add the period to the market, for example moneyline@game, to get one.

What are best and fair?

best is the top price for a selection across the books on your plan, with the book that has it. fair is a no-vig price for that selection.

Can I run it without a key?

Only the first part. Books and leagues need no key. Events and odds do.