Answer

How to get sports odds in Node.js

A copy-paste Node.js example that fetches live odds with built-in fetch, plus the polling and streaming patterns that follow.

How do I get sports odds in Node.js?

Use the built-in fetch in Node 18 and later to call GET /v1/sports/{sport_key}/odds with an X-API-Key header. The response is plain JSON: a list of games, each carrying bookmakers, markets, and current prices. A free ParlayAPI key includes 1,000 credits per month, and the open-source parlay-api-js SDK on GitHub wraps the same endpoints if you prefer a client library.

More detail

No SDK is required: fetch, one header, and JSON.parse cover it. Get sport keys from GET /v1/sports, which is free to call, and control the response with regions and markets parameters. Every price keeps its source label, so rendering a per-book board is a straight map over the response.

For an app that reacts to line moves, poll at an interval your credit budget supports and diff against /v1/sports/{sport_key}/line-movement, or move to push: WebSocket and SSE streams are available on Business tier and above, and the SSE feed suits serverless and edge runtimes that cannot hold a raw socket.

Code written for the-odds-api ports directly: point the base URL at parlay-api.com, keep the same paths and parameters, and existing npm client code keeps working through the /v4 compatibility layer.

Endpoint

GET /v1/sports/{sport_key}/odds

const resp = await fetch(
  "https://parlay-api.com/v1/sports/basketball_nba/odds?regions=us&markets=h2h",
  { headers: { "X-API-Key": process.env.PARLAY_KEY } },
);
const games = await resp.json();
for (const g of games) console.log(g.away_team, "@", g.home_team);

Why developers use it

FAQ

Is there a TypeScript client?

The parlay-api-js SDK at github.com/JacobiusMakes/parlay-api-js wraps the endpoints, and the OpenAPI spec at /openapi.json supports generating typed clients with your preferred generator.

How do I stream odds instead of polling in Node?

Connect to wss://parlay-api.com/ws/odds/{sport_key} or the SSE feed, both available on Business tier and above. Free, Starter, and Pro keys use REST polling, which the docs cover with worked examples.

Does this work in Deno and Bun?

Yes. Any runtime with standard fetch works unchanged, since authentication is a single header and responses are plain JSON.

Related

/answers/nfl-odds-python/answers/odds-api-with-websockets/docs/cookbook