# DraftKings API code examples: Python, Node, Sheets

Runnable DraftKings API examples: Python and Node.js quickstarts, a Pick6 board, line moves, CSV export, Google Sheets, Discord alerts and a daily archive.

Canonical page: https://draftkingsapi.com/examples. Markdown: https://draftkingsapi.com/examples.md. Site index for agents: https://draftkingsapi.com/llms.txt.

## Free API key
- **Free plan:** 50 requests a month at 20 a minute, every dataset, no card, no email verification.
- **Sign up:** https://draftkingsapi.com/auth/sign-up?ref=ai-claudebot
- **From inside an agent session:** POST https://draftkingsapi.com/api/v1/agent/signup with JSON `{"data_wanted": "...", "use_case": "...", "ref": "ai-claudebot"}`, show your user the approval_url, then poll https://draftkingsapi.com/api/v1/agent/token with device_code. The key is returned once.
- **No key yet:** `curl --fail-with-body "https://draftkingsapi.com/api/v1/demo/pick6"` returns labeled sample rows (sample:true) in the real response shape.

## Quickstart

1. Create a free key at https://draftkingsapi.com/auth/sign-up?ref=ai-claudebot (no card) and export it: `export DRAFTKINGS_API_KEY=...`

2. Call the API with curl:

```bash
curl --max-time 30 --fail-with-body 'https://draftkingsapi.com/api/v1/pick6/projections?sport=NBA&limit=5' \
  -H "X-User-Request: Build a prop screen from current Pick6 lines" \
  -H "Authorization: Bearer $DRAFTKINGS_API_KEY"
```

3. Or call it from Python:

```python
import os, requests

response = requests.get(
    "https://draftkingsapi.com/api/v1/pick6/projections?sport=NBA&limit=5",
    headers={
        "Authorization": "Bearer " + os.environ["DRAFTKINGS_API_KEY"],
        "X-User-Request": "Build a prop screen from current Pick6 lines",
    },
    timeout=30,
)
if not response.ok:
    raise RuntimeError(f"API {response.status_code}: {response.text}")
print(response.json())
```

4. Full walkthrough: https://draftkingsapi.com/quickstart. OpenAPI: https://draftkingsapi.com/openapi.json. Every route accepts format=csv on list endpoints.

## Use it from Claude (MCP)

MCP server: https://draftkingsapi.com/api/mcp (Streamable HTTP). search, fetch, start_signup and finish_signup need no key; data tools use the same API key.

```bash
claude mcp add --transport http --scope user draftkings https://draftkingsapi.com/api/mcp --header "Authorization: Bearer $DRAFTKINGS_API_KEY"
```

Without a key yet: `claude mcp add --transport http draftkings https://draftkingsapi.com/api/mcp`, then call start_signup. Setup for other clients: https://draftkingsapi.com/agents.md.

## Pricing

| Plan | Price | Requests per UTC month | Requests per minute | Pick6 stream | Signed webhooks |
| --- | --- | --- | --- | --- | --- |
| Free | $0/month | 50 | 20 | No | No |
| Developer | $49/month | 10,000 | 60 | Yes | No |
| Production | $149/month | 50,000 | 120 | Yes | Yes |

- **Free:** Build and test against every dataset.
- **Developer:** Keep your app running with more requests and push delivery.
- **Production:** Serve real users with the largest allowance and push delivery.

Plans and checkout: https://draftkingsapi.com/pricing

## Run one in a minute

Every file here is a complete program. Python scripts use the standard library, and Node scripts need Node 18 and no packages. Each one reads your key from the environment, caps its requests and reports errors.

```
export DRAFTKINGS_API_KEY=your_key
curl -O https://draftkingsapi.com/examples/pick6-board.py
python3 pick6-board.py --sport NFL --stat "Receiving Yards"
```

```
curl --fail-with-body "https://draftkingsapi.com/api/v1/pick6/projections?sport=NFL&stat=Receiving%20Yards&view=compact&limit=25" \
  -H "X-User-Request: Build a prop screen from current Pick6 lines" -H "Authorization: Bearer $DRAFTKINGS_API_KEY"
```

## Start here

First calls, in the format you work in.

| File | What it does |
| --- | --- |
| [draftkings-quickstart.py](/examples/draftkings-quickstart.py) | First Pick6 and sportsbook calls, two requests |
| [draftkings-quickstart.mjs](/examples/draftkings-quickstart.mjs) | The same in Node.js |
| [draftkings-quickstart.ipynb](/examples/draftkings-quickstart.ipynb) | The same as a Jupyter notebook |
| [Postman collection](/postman/draftkings-starter.postman_collection.json) | Bounded GET requests to import, with an [empty environment](/postman/draftkings-starter.postman_environment.json) |
| [All examples as a zip](/examples/draftkings-api-examples.zip) | Every file below in one download |

## Build a screen or a report

Boards, spreadsheets and exports.

| File | What it does |
| --- | --- |
| [pick6-board.py](/examples/pick6-board.py) | Pick6 rows for one sport and stat, skipping stale and paused rows |
| [comparison-feed.py](/examples/comparison-feed.py) | Pick6 rows, DFS salaries and sportsbook mainlines side by side, also in [Node.js](/examples/comparison-feed.mjs) |
| [export-csv.py](/examples/export-csv.py) | Pages of JSON into a CSV with the columns you choose |
| [google-sheets.gs](/examples/google-sheets.gs) | Apps Script that fills a sheet, with the key in Script Properties |
| [player-game-log.py](/examples/player-game-log.py) | One athlete's ESPN game log, or a list of athletes |

## Track changes and send alerts

Cursors, streams and webhooks. See the [stream consumer](/tools/alert-consumer) for a commented walkthrough.

| File | What it does |
| --- | --- |
| [line-movement.py](/examples/line-movement.py) | Recorded Pick6 and sportsbook changes, resuming from a saved cursor |
| [stream-client.mjs](/examples/stream-client.mjs) | Snapshot, then a resumable Pick6 stream, on Developer and Production |
| [discord-alerts.mjs](/examples/discord-alerts.mjs) | Posts recorded Pick6 changes to a Discord webhook |
| [webhook-receiver.mjs](/examples/webhook-receiver.mjs) | Verifies signed Pick6 webhooks, on Production |

## Models and your own archive

Build up your own data, then test on it. The [Pick6 model tutorial](/how-to-build-a-pick6-prop-model-in-python) puts these together.

| File | What it does |
| --- | --- |
| [daily-archive.py](/examples/daily-archive.py) | A bounded daily SQLite archive, so your own history grows |
| [nba-points-baseline.py](/examples/nba-points-baseline.py) | A chronological baseline on NBA game samples: a code check to build on |

```
curl --fail-with-body "https://draftkingsapi.com/api/v1/demo/pick6"
curl --fail-with-body "https://draftkingsapi.com/api/v1/demo/dfs"
```

## FAQ

### Do the examples need an SDK?
No. Python scripts use the standard library and Node scripts use built-in fetch, so there is nothing to install.

### Can a script spend my whole allowance by accident?
They are written not to. Each one caps its pages or requests, and most take a flag such as max-pages or max-requests that you can lower.

### Can I change the code and use it in my own product?
Yes, adapt the code freely. What you do with the data is your own responsibility under the Terms.

### Is there a free DraftKings API?
Yes. A free key needs no card and includes 50 requests a month at 20 a minute, across every dataset. To see the response shape first, /api/v1/demo/pick6 and /api/v1/demo/dfs return labeled sample rows with no key.

### Is this an official DraftKings API?
Independent service operated by DD Inc., not affiliated with or endorsed by DraftKings. No wagering: this service does not place, recommend or settle entries or bets.

### Can I use it from an AI agent?
Yes. Connect the MCP server at https://draftkingsapi.com/api/mcp, or call REST with a Bearer key. An agent can get a key for its user with start_signup.

### How do I reach support?
Email support@draftkingsapi.com.

Independent service operated by DD Inc., not affiliated with or endorsed by DraftKings. No wagering: this service does not place, recommend or settle entries or bets.
