Skip to main content

kingsplaybook

The official Python SDK for the KingsPlaybook Developer API — confirmed lineups, raw player projections, canonical game lines, and a pick-history archive for NBA, MLB, and NHL.

It's a thin, typed wrapper over the public /v1 REST API: one client class, one method per endpoint. Zero dependencies — it uses only the Python standard library.

Install

pip install kingsplaybook

Requires Python 3.9+.

Get an API key

Sign up at kingsplaybook.org/devs. Your key looks like kp_live_…. The Free tier covers lineups; paid tiers add projections, lines, and history.

Quick start

from kingsplaybook import KingsPlaybook

kp = KingsPlaybook(api_key="kp_live_...")

# Confirmed lineups (Free tier)
lineups = kp.lineups(league="nba", date="2026-05-21")
for game in lineups["data"]:
    away = (game["away_team"] or {}).get("abbreviation")
    home = (game["home_team"] or {}).get("abbreviation")
    print(f"{away} @ {home}")

# Player projections (Starter tier and up)
projections = kp.projections(league="nba", date="2026-05-21")
print(f"{projections['meta']['count']} projections")

The api_key argument falls back to the KINGSPLAYBOOK_API_KEY environment variable, so KingsPlaybook() works when that is set.

Methods

Method Endpoint Min. tier
kp.health() GET /v1/health none
kp.freshness() GET /v1/meta/freshness Free
kp.lineups(league, date) GET /v1/lineups Free
kp.projections(league, date) GET /v1/projections Starter
kp.lines(league, date) GET /v1/lines Pro
kp.history(date, pick_type=…, sport=…) GET /v1/history/picks Premium

league is "nba", "mlb", or "nhl". date is an ISO-8601 string (YYYY-MM-DD). For history, pick_type is "game" or "prop" (omit for both).

Each method returns a plain dict shaped {"data": ..., "meta": ...}. The package ships TypedDict definitions (LineupsResponse, ProjectionsResponse, …) in kingsplaybook.models, and is marked py.typed — type checkers and editors get full autocomplete over the responses.

Error handling

Every failure raises a KingsPlaybookError or a subclass. The subclass tells you what went wrong without parsing a message:

from kingsplaybook import (
    KingsPlaybook,
    AuthenticationError,
    TierError,
    RateLimitError,
    KingsPlaybookError,
)

try:
    kp.lines(league="mlb", date="2026-05-21")
except AuthenticationError:
    ...  # 401 — key missing, invalid, or revoked
except TierError:
    ...  # 403 — your plan does not include this endpoint
except RateLimitError:
    ...  # 429 — back off and retry
except KingsPlaybookError as exc:
    ...  # anything else (transport, 404, 5xx) — exc.status has the code

Configuration

KingsPlaybook(
    api_key="kp_live_...",   # or KINGSPLAYBOOK_API_KEY
    base_url="https://api.kingsplaybook.org",  # or KINGSPLAYBOOK_API_URL
    timeout=30.0,            # per-request timeout, seconds
)

License

MIT

Metadata

Release files for kingsplaybook 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kingsplaybook 0.1.0
File Size Uploaded Provenance Actions
kingsplaybook-0.1.0.tar.gz 6.7 kB Without provenance Details for kingsplaybook-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kingsplaybook 0.1.0
File Interpreter ABI Platform Actions
kingsplaybook-0.1.0-py3-none-any.whl Python 3 none any Details for kingsplaybook-0.1.0-py3-none-any.whl

Total release size: 15.1 kB

Release files / kingsplaybook-0.1.0.tar.gz

Download URL kingsplaybook-0.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
eaab4b0a9b22b8dffb9faa8a5705b3ba0a504abbdd1af12cc10df52accf30de6
BLAKE2b-256 checksum
How to use checksums
ef4a1ec19460a8f52ad7d3c254ecb25e83c6cc62304d20b0934a7448a587af81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / kingsplaybook-0.1.0-py3-none-any.whl

Download URL kingsplaybook-0.1.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b655791ca1db4f551a0960182c34f2b618742281522ea770d2ee236d0a62a8b
BLAKE2b-256 checksum
How to use checksums
1e609671b30bfebf0684e4ce180fa076f05d1397f09ed2086c80ec9c97b42555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for kingsplaybook 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page