Odds API Python and Node.js SDKs

Odds API Python and JavaScript SDKs, plus the OpenAPI 3.1 spec and a Postman collection, to call PreciseAPI from any language in a few lines.

Official clients wrap every endpoint with typed results, automatic retries on 429 and 5xx (respecting Retry-After), credit and rate-limit metadata on every response, a streaming client that reconnects and resyncs on sequence gaps (the stream is on the Syndicate plan), and webhook signature verification.

Node.js

Zero dependencies on Node 22+ (Node 18–21 needs ws for streaming). Ships TypeScript types.

terminal
npm install @preciseapi/node
index.js
import { PreciseAPI } from '@preciseapi/node';

const client = new PreciseAPI({ apiKey: process.env.PRECISEAPI_KEY });

const { data, credits } = await client.odds({ league: 'nba', markets: ['moneyline', 'spread'], books: ['pinnacle', 'draftkings'] });
console.log(data.length, 'events ·', credits.remaining, 'credits left');

// Streaming with automatic reconnects and gap recovery
const stream = client.stream({ leagues: ['nba'], markets: ['moneyline'] });
stream.on('snapshot', (msg) => console.log('snapshot', msg.data.length));
stream.on('market', (change) => console.log(change.book, change.market.key, change.market.outcomes.map((o) => o.price)));

Python

Python 3.9+, sync and async clients built on httpx.

terminal
pip install preciseapi            # REST
pip install "preciseapi[stream]"  # + WebSocket streaming
main.py
from preciseapi import PreciseAPI

client = PreciseAPI()  # reads PRECISEAPI_KEY
res = client.odds(league="nba", markets=["moneyline", "spread"], books=["pinnacle", "draftkings"])
print(len(res.data), "events ·", res.credits.remaining, "credits left")

# Async + streaming
import asyncio
from preciseapi import AsyncPreciseAPI

async def main():
    async with AsyncPreciseAPI() as client:
        async with client.stream(leagues=["nba"], markets=["moneyline"]) as stream:
            async for msg in stream:
                if msg["type"] == "delta":
                    print(len(msg["changes"]), "changes")

asyncio.run(main())

Errors

Both SDKs raise PreciseAPIError with status, code (the same codes as the error reference), message, docs_url and request_id. Include the request id when contacting support.

Other languages

The API is plain HTTPS + JSON, and the OpenAPI 3.1 spec (/openapi.json) generates a client for most languages (openapi-generator, oapi-codegen, NSwag).

Previous: Live scores & game clock · Next: AI assistants (MCP)