An open-source client for private sports odds research with ParlayAPI. It uses native fetch, includes TypeScript types, and builds ESM and CommonJS modules. The event-market search below works without an account. Metered routes use your API key and account credits. Available sports, bookmakers, markets and historical records vary by request.
From a terminal with Node.js 18 or later, run one public odds request. The command uses the versioned SDK release and needs no account or project setup.
npm exec --yes --package=https://github.com/JacobiusMakes/parlay-api-js/releases/download/v0.6.0/parlay-api-0.6.0.tgz -- parlay-preview nbaThe first line reports how many events the sample returned. When a team price is present, the next lines identify the matchup, event ID, bookmaker, team, American price and available market timestamp. Add --json to inspect the complete response. An empty sample is a successful result with zero events. An unsupported sport or rate limit exits with an error. The command makes one API request and sends no configured account key.
After installing the SDK in a project, use the same public route from JavaScript or TypeScript:
import { ParlayAPI } from "parlay-api";
const board = await new ParlayAPI().previewOdds("nba");
console.log(board.sport_key, board.events_returned);To inspect the sample without installing Node, open the public odds preview. For deterministic example data, use the fictional sandbox.
Grade the Cubs’ 8–7 Game 7 win. Chicago won the moneyline. Give Chicago a run line of −1.5 and Cleveland covers instead. Change the score or edit the four fictional American prices to see which outputs move.
Edit and run the JavaScript in LiveCodes. Change Chicago’s score to 9 to see the run-line winner change, or set both fictional prices to −110 to get an even 50.0% share.
To use the same released SDK math on a web page, paste this into an HTML file. It loads the ES module from the 0.5.0 release through a commit-pinned CDN URL. Both prices belong to the same fictional moneyline.
<meta charset="utf-8">
<output id="chicago-share"></output>
<script type="module">
import { devig } from "https://cdn.jsdelivr.net/gh/JacobiusMakes/parlayapi-notebooks@190bb4278efecc8677f812f06ca6486c4f08274f/docs/baseball-run-line/parlay-api-0.5.0.js";
const [chicago] = devig(-150, +130);
document.getElementById("chicago-share").textContent =
"Chicago’s no-vig share: " + (100 * chicago).toFixed(1) + "%";
</script>The page displays 58.0% with no API key or sports-data request. The calculation normalizes the two implied probabilities to sum to one.
Install the prebuilt SDK from its versioned GitHub release in a project using Node.js 18 or later.
npm install https://github.com/JacobiusMakes/parlay-api-js/releases/download/v0.6.0/parlay-api-0.6.0.tgz
node --input-type=module -e 'import { devig } from "parlay-api"; console.log(devig(-110, -110))'The second command runs locally and prints [ 0.5, 0.5 ]. The package includes CommonJS (require("parlay-api")), ES modules and TypeScript declarations. To try a synthetic odds board, run the first request.
A search for “Super Bowl” can turn up a halftime song as well as a football contract. Read the venue, contract ID and exact question before comparing prices. Similar titles can settle on different events.
Download the Node.js search starter, extract it and run these commands inside its folder with Node.js 18 or later. The archive includes SDK 0.5.0.
npm ci --offline --ignore-scripts
node examples/prediction_markets.mjs
node examples/prediction_markets.mjs "World Series"Each search makes one keyless request for up to three candidates across Kalshi and Polymarket. The output includes each venue’s response status and the price fields it supplied. A successful search can return zero candidates. A source warning leaves that venue’s coverage uncertain.
To request the separate NFL sport snapshot, get a project key, set PARLAYAPI_KEY in your private environment and run node examples/prediction_markets.mjs --nfl-snapshot. That route is documented at one credit per request.
Use the American prices for every outcome offered by one bookmaker on the same event, market and line at the same time. This fictional two-way quote yields a 4.76% overround. It measures the margin implied by the quoted prices. Realized revenue also depends on the bets placed.
import { marketHold } from "parlay-api";
const overround = marketHold([-110, -110]);
console.log((100 * overround).toFixed(2) + "%"); // 4.76%The private Next.js example renders fictional NBA games and an empty board before you connect a service. A server-side SDK request can load one synthetic or account snapshot. Scores are matched to team names, and an unavailable score stays empty.
To work on the client itself, clone the source and compile it locally.
git clone https://github.com/JacobiusMakes/parlay-api-js.git
cd parlay-api-js
npm install --ignore-scripts
npm run build
node examples/quickstart.mjsThe quickstart prints a fictional basketball matchup and up to three bookmakers with prices for both teams. An empty board and a game missing a complete pair have separate messages. Run it without an API key. From another local project, install the built checkout with npm install /absolute/path/to/parlay-api-js.
Download the NBA scanner starter for Node.js 18 or later. Extract it and run npm ci --offline --ignore-scripts inside the extracted directory. The ZIP includes the published 0.5.0 SDK. The same commands work in a built source checkout.
node examples/arb_finder.mjs
node examples/ev_scanner.mjsEach script makes one public sandbox request and prints the number of fictional records and up to three matchups. The arbitrage response holds its records in the arbs field. The expected-value response returns an array. The examples work with an empty API key, including when a key is set in the environment.
To inspect real pregame prices after the rehearsal, open the public NBA preview. Compare the event, bookmaker, market and team before comparing prices.
Use the free API workload planner to write down your active window, refresh interval, separately polled sports, requests per refresh and active days. Include every required endpoint and page. The planner needs no account or key and does not make API requests.
Leave credit cost unknown until you verify the unit cost for your exact request shape in the current documentation. The estimate uses your assumptions; it does not establish live coverage, entitlement or the freshness of returned records.
For several request shapes with different or unknown unit costs, use the offline request-budget kit. It includes a CSV template, exact JSON export and a self-contained notebook. Unpriced work keeps the total credit estimate unknown.
Save this example as first-request.mjs in the project where you installed the SDK and run node first-request.mjs. It requests synthetic sandbox quotes without using an API key.
import { ParlayAPI } from "parlay-api";
const client = new ParlayAPI({ sandbox: true, apiKey: "" });
const odds = await client.odds("basketball_nba", {
regions: "us",
markets: ["h2h"],
});
console.log(odds[0]?.bookmakers ?? []);Use a short league name such as nba, nfl, mlb, nhl or epl anywhere the client takes a sport key. For example, client.odds("nba") requests basketball_nba. The exported SPORT_ALIASES table lists the mappings. The full mma key retains its all-competitions meaning.
When the sandbox returns the fields you need, create a free account to get your own API key. Keep the key in your private server or local environment.
const client = new ParlayAPI({ apiKey: process.env.PARLAYAPI_KEY });Keep keys out of browser bundles and public repositories. This client does not grant permission to redistribute the underlying data publicly. See API documentation for current endpoint availability, pricing and access requirements.
The source includes methods for sports, events, odds, props, historical queries and other API endpoints. A method's presence does not establish that data is available for a particular request. Inspect returned records and bookmaker timestamps before comparing quotes. Calculated opportunities are not guarantees of profit or execution.
Local helpers include devig, edge, kellyStake and odds-format conversions:
import { devig } from "parlay-api";
const [homeProbability, awayProbability] = devig(-110, -110);toaCompat: true selects compatible /v4 routes for supported methods. Validate the endpoints, parameters and returned fields used by your application when migrating.
Sandbox mode only changes methods with a sandbox route; other methods can still use live endpoints. Start with the included quickstart rather than assuming every method is keyless.
| Client option | Default | Effect |
|---|---|---|
maxRetries |
0 |
Number of additional attempts after HTTP 429. A value of 2 permits at most 3 HTTP calls for one method invocation. |
timeout |
30000 ms |
Timeout for each fetch attempt. Time spent waiting between attempts is additional. |
import { ParlayAPI, RateLimitedError } from "parlay-api";
const client = new ParlayAPI({ maxRetries: 2, timeout: 5000 });
try {
const sports = await client.sports();
console.log(sports.length);
} catch (error) {
if (!(error instanceof RateLimitedError)) throw error;
console.error("Polling paused after a rate-limit response.");
}The client honors a usable Retry-After value in whole seconds or as an HTTP date. If the server asks for more than 30 seconds, the call stops with the rate-limit error. With no usable header, the first two delays start at 500 ms and 1 second, with up to 249 ms of jitter. Each delay is capped at 30 seconds. A timeout, network failure, or any other HTTP error ends that call immediately. On metered routes, include every possible attempt in your request budget.
Run three rate-limit cases locally and calculate an upper bound for one scheduled job. The example uses fictional responses.
The client exposes typed errors and parses quota headers into lastQuota. Streaming access depends on the endpoint and account plan. streamOdds uses the runtime's global WebSocket; provide options.webSocket if your runtime lacks it.
In SDK 0.4.4, the service codes OUT_OF_USAGE_CREDITS and CREDIT_LIMIT_REACHED raise
CreditLimitExceededError. A plan lookback denial raises TierGatedError. Catch these
separately when deciding whether to pause scheduled reads or check the requested date.
See six first-response examples.
Practice choosing a next check with the offline first-response rehearsal. Its twelve invented cases distinguish authentication, access, rate-limit and transport outcomes, with explicit attempt and wait budgets. The Python command runs without keys or API requests.
npm run build
npm run test:package
npm testThe build produces ESM, CommonJS and type declarations. The existing smoke test makes network requests to sandbox and public endpoints and checks an invalid-key response; it is not an offline test suite.
MIT. The client source license does not license redistribution of API data.