Metadata-Version: 2.4
Name: draftkingsapi
Version: 0.1.0
Summary: Python client for draftkingsapi.com: DraftKings Pick6 lines and line history, DFS salaries, sportsbook odds and box scores. Independent, not affiliated with DraftKings.
License: MIT
Project-URL: Repository, https://github.com/draftkingsapi/draftkingsapi-python
Project-URL: Issues, https://github.com/draftkingsapi/draftkingsapi-python/issues
Project-URL: Homepage, https://draftkingsapi.com
Project-URL: Documentation, https://draftkingsapi.com/docs
Project-URL: OpenAPI, https://draftkingsapi.com/openapi.json
Project-URL: Status, https://draftkingsapi.com/status
Keywords: draftkings,pick6,dfs,sportsbook,odds,sports-data,api-client
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# draftkingsapi (Python)

Python client for [draftkingsapi.com](https://draftkingsapi.com): DraftKings Pick6 lines and line history,
DFS salaries, contests and slates, sportsbook odds and price history, and box scores. Standard library only,
no dependencies, typed.

draftkingsapi.com is an independent API. It is not affiliated with or endorsed by DraftKings. "DraftKings" is a
trademark of its owner and is used here only to describe the data.

```bash
pip install draftkingsapi
```

## No key needed

The keyless feeds are delayed and capped, cost no credits, and need no account:

```python
from draftkingsapi import Client

dk = Client()  # reads DRAFTKINGS_API_KEY if set; keyless calls never send it

board = dk.public_board(league="nba", limit=3)
for prop in board["props"]:
    print(prop["player"], prop["stat"], prop["line"], prop["more_multiplier"])

games = dk.public_sportsbook(league="nfl", limit=2)
for game in games["games"]:
    print(game["away"], "at", game["home"], [(m["market"], m["side"], m["line"], m["american"]) for m in game["markets"]])

moves = dk.public_line_moves(market="pick6", limit=5)
costs = dk.credit_costs()            # credits per endpoint
status = dk.status()                 # measured collection status
sample = dk.demo("odds", limit=1)    # frozen sample rows, for the response shape only
```

Output of the first loop, run on 15 Nov 2026 (live data, so yours will differ; a prop with no current line prints None):

```text
Giannis Antetokounmpo Points 32.5 0.8
Cade Cunningham Points 30.5 1
Bam Adebayo Points None None
```

## With a key

Get a free key (100 credits a month, no card) at https://draftkingsapi.com/sign-up, then:

```bash
export DRAFTKINGS_API_KEY=dk_...
```

```python
from draftkingsapi import Client

dk = Client(user_request="Build a prop screen from current Pick6 lines")

lines = dk.pick6_projections(sport="NBA", limit=100)
history = dk.pick6_line_history(lines["data"][0]["pickable_id"], change_type="line_move")
odds = dk.odds(sport="NFL", market="moneyline")
salaries = dk.dfs_players(sport="NFL", format="csv")      # CSV text
box = dk.stats_player_games("NBA", 2026, limit=50)
edges = dk.ev(league="nba", min_edge=2)
```

`user_request` is optional: one plain sentence about the task, sent as `X-User-Request`. Never put personal data in it.

### Pagination

List routes return `pagination.has_more` with a cursor. `paginate()` follows it with a page budget, so a loop cannot
spend your whole allowance:

```python
for row in dk.paginate(dk.odds, sport="NBA", max_pages=5):
    ...
```

It follows `next_cursor` (sent back as `cursor`), `next` on the stats routes and `next_after` on the change feeds
(both sent back as `after`).

### Errors

Every non-2xx response raises a subclass of `DraftKingsAPIError` with the API's own message:

| Status | Exception | What to do |
| --- | --- | --- |
| 400 | `InvalidRequestError` | `e.error["query_help"]` often has a corrected example |
| 401 | `AuthenticationError` | missing or wrong key; raised before any request when a keyed method has no key |
| 402 | `PaymentRequiredError` | `e.error["upgrade_url"]` |
| 404 | `NotFoundError` | `e.error["closest_endpoints"]` |
| 429 | `RateLimitError` | wait `e.retry_after` seconds; if `e.error["limit"] == "month"`, stop retrying |
| 503 | `DatasetUnavailableError` | dataset temporarily unavailable; not charged, retry later |

```python
from draftkingsapi import Client, RateLimitError

try:
    Client().odds(sport="NFL")
except RateLimitError as e:
    print("retry in", e.retry_after, "seconds:", e.message)
```

## Methods

Keyless: `public_board`, `public_sportsbook`, `public_line_moves`, `demo(dataset)`, `credit_costs`, `directory`,
`status`, `history_coverage`.

Keyed: `coverage`, `events`, `odds`, `history`, `pick6_projections`, `pick6_history`, `pick6_line_history`,
`projections`, `changes`, `dfs_sports`, `dfs_contests`, `dfs_slates`, `dfs_players`, `dfs_changes`, `compare`,
`compare_books`, `ev`, `arbitrage`, `stats_games`, `stats_player_games`, `stats_team_games`, `context_games`,
`context_player_stats`, `context_team_stats`, `sportsbook_scopes`, `sportsbook_snapshot`, `stream_snapshot`.

Optional filters are keyword arguments, passed through unchanged. Every route's parameters are in the
[OpenAPI document](https://draftkingsapi.com/openapi.json) and the [docs](https://draftkingsapi.com/docs).
Not wrapped: the server-sent event stream, the native sportsbook WebSocket, and account, billing and sign-up routes.

## Plans

Free 100 credits a month, Developer $49, Production $149, Scale $499 a month. Credits per endpoint:
`Client().credit_costs()` or https://draftkingsapi.com/api/v1/credit-costs.

## Tests

```bash
python -m unittest discover -s tests            # mocked, no network
DRAFTKINGS_LIVE=1 python -m unittest tests.test_live -v   # live keyless endpoints, no key, no credits
```

MIT License.
