# Nightly FanDuel line history export to a warehouse

FanDuel API (https://fanduelapi.com) is an independent API for FanDuel Sportsbook data: every player prop and game market FanDuel lists in NBA, NFL, NHL, MLB, college basketball and college football, normalized per player and stat with over and under prices in American and decimal odds, plus every line and price move with its timestamp, over REST, webhooks and MCP with one key. FanDuel API is an independent data service operated by FF API Inc. It is not affiliated with, endorsed by or sponsored by FanDuel.

Source page: https://fanduelapi.com/docs/nightly-export (this is its markdown version, https://fanduelapi.com/docs/nightly-export.md).

## Free offer

- Free plan: 100 credits a month, data delayed 5 minutes, no card. REST and MCP on every plan.
- Real-time data starts at Developer, $49 a month for 10,000 credits.
- Get a free key: https://fanduelapi.com/sign-up?ref=ai-claudebot

## Quickstart

1. Create a free account at https://fanduelapi.com/sign-up?ref=ai-claudebot and create an API key in the dashboard (https://fanduelapi.com/dashboard/keys). Keys start with `fd_`. Store it as `FANDUEL_API_KEY`.
2. Make a first call with curl:

```bash
curl "https://fanduelapi.com/api/v1/props?sport=nba&stat=points&limit=5" \
  -H "Authorization: Bearer $FANDUEL_API_KEY"
```

3. Or with Python (`pip install requests`):

```python
import os
import time
from datetime import datetime, timezone

import requests

BASE = "https://fanduelapi.com/api/v1"
SESSION = requests.Session()
SESSION.headers["Authorization"] = f"Bearer {os.environ['FANDUEL_API_KEY']}"


def get(path, **params):
    """GET one endpoint and return its data list, waiting out rate limits."""
    while True:
        r = SESSION.get(f"{BASE}{path}", params=params, timeout=10)
        if r.status_code == 429:
            time.sleep(int(r.headers.get("Retry-After", "5")))
            continue
        r.raise_for_status()
        return r.json()["data"]


def price(odds):
    """American odds as text. A suspended market can come back with no price."""
    return "off" if odds is None else f"{odds:+d}"

props = get("/props", sport="nba", stat="points")
for p in props:
    print(f"{p['player']:<26} {str(p['line']):>5}  over {price(p['over_american']):>5}  under {price(p['under_american']):>5}")
```

4. Stay current with `GET /api/v1/changes?since=<cursor>` instead of re-reading every prop. Full reference: https://fanduelapi.com/openapi.json and https://fanduelapi.com/llms-full.txt.

## Use it from Claude (MCP)

Claude Code, with your key read from the shell:

```bash
claude mcp add --transport http --scope user fanduelapi https://fanduelapi.com/api/mcp \
  --header "Authorization: Bearer $FANDUEL_API_KEY"
```

Claude on the web or desktop: Settings, Connectors, Add custom connector, then paste https://fanduelapi.com/api/mcp. Without a key it gives the keyless tools (search_docs, fetch_doc, get_sample_props). Setup for other agents: https://fanduelapi.com/mcp.

## Pricing

| Plan | Price | Credits a month | Calls a minute | Includes |
| --- | --- | --- | --- | --- |
| Free | Free | 100 | 20 | REST and MCP access, Data delayed 5 minutes |
| Developer | $49/month | 10,000 | 60 | Real-time data, Line move history, Change stream |
| Production | $149/month | 50,000 | 120 | Real-time data, Line move history, Webhooks, Priority support |
| Scale | $499/month | 250,000 | 180 | Real-time data, Full line move history, Webhooks, Bulk export, Priority support |

Cancel paid plans any time from the billing portal. Details: https://fanduelapi.com/pricing

## This page

[FanDuel API](https://fanduelapi.com/)/[Docs](https://fanduelapi.com/docs) / Nightly export

Docs workflow

# A nightly FanDuel line history export

One job a day keeps your own warehouse in step with FanDuel line history: export yesterday's rows as NDJSON, resume by cursor until the range is done, load them into DuckDB or Postgres, and check the counts match.

[Get a free API key](https://fanduelapi.com/sign-up)[Read the docs](https://fanduelapi.com/docs)

FanDuel API is an independent data service operated by FF API Inc. It is not affiliated with, endorsed by or sponsored by FanDuel.

## The job

nightly.py (pip install requests duckdb)

```
"""Run once a day after midnight UTC: python nightly.py 2026-11-05"""
import json, os, sys
from datetime import date, timedelta
import duckdb, requests

API = "https://fanduelapi.com/api/v1/export"
HEAD = {"Authorization": f"Bearer {os.environ['FANDUEL_API_KEY']}"}
day = sys.argv[1]
next_day = (date.fromisoformat(day) + timedelta(days=1)).isoformat()
params = {"kind": "history", "format": "ndjson", "limit": 10000, "cursor": "0",
          "from": f"{day}T00:00:00Z", "to": f"{next_day}T00:00:00Z"}
path = f"history-{day}.ndjson"

with open(path, "w") as out:
    rows = 0
    while True:
        r = requests.get(API, params=params, headers=HEAD, timeout=300)
        r.raise_for_status()
        for line in r.text.splitlines():
            record = json.loads(line)
            if "error" in record:            # a cut-short body names where to resume
                sys.exit(f"stopped at {record['error']['next_cursor']}: {record['error']['code']}")
            out.write(line + "\n")
            rows += 1
        if r.headers.get("X-Has-More") != "true":
            break
        params["cursor"] = r.headers["X-Next-Cursor"]

db = duckdb.connect("fanduel.duckdb")
db.execute("CREATE TABLE IF NOT EXISTS prop_history AS SELECT * FROM read_json_auto(?) LIMIT 0", [path])
db.execute("DELETE FROM prop_history WHERE observed_at >= ?::TIMESTAMP AND observed_at < ?::TIMESTAMP + INTERVAL 1 DAY", [day, day])
db.execute("INSERT INTO prop_history SELECT * FROM read_json_auto(?)", [path])
loaded = db.execute("SELECT count(*) FROM prop_history WHERE observed_at::DATE = ?::DATE", [day]).fetchone()[0]
assert loaded == rows, f"wrote {rows}, loaded {loaded}"
print(day, rows, "rows")
```

Each NDJSON line has these fields: cursor, prop\_id, kind, observed\_at, line, over\_american, under\_american, over\_decimal, under\_decimal, market\_status, sport, league, event\_id, event\_name, starts\_at, player, team, stat, period. They are defined in the [schema glossary](https://fanduelapi.com/docs/schema-glossary).

## Checks worth keeping

- **Counts match:** rows written equal rows loaded, as the job asserts.
- **The day is complete:** run it after the day ends in UTC, and compare with the rows per day on [history coverage](https://fanduelapi.com/history-coverage).
- **Freshness was ok:** the response headers carry `X-Source-Status`; a day with a collection gap shows on the incidents page.

For Postgres, load the same file with `COPY` into a jsonb staging table and insert from it. Ranges up to 366 days work the same way; see [CSV export](https://fanduelapi.com/fanduel-api-csv-export) for the parameters.

## Questions

## Related

- [CSV export Export FanDuel props or line history for a date range as CSV or NDJSON: the columns, the curl call, loading it in pandas and resuming by cursor.](https://fanduelapi.com/fanduel-api-csv-export)
- [Historical data Where FanDuel historical odds data comes from here: per-prop move history, date-range exports, the training set and graded results, and how far back each goes.](https://fanduelapi.com/fanduel-historical-data)
- [History coverage How much FanDuel line history is recorded: the first day kept, rows per day, and props and markets with history per league.](https://fanduelapi.com/history-coverage)
- [Schema glossary Every field the FanDuel API returns, defined: props, move summaries, history points, changes, markets and selections, results, DFS players and meta.](https://fanduelapi.com/docs/schema-glossary)

## Make your first call in a few minutes

Sign up, create a key in the dashboard, and send it as a Bearer token. The free plan needs no card and reads the same data five minutes behind.

[Get a free API key](https://fanduelapi.com/sign-up)

## FAQ

### Is there a free plan?

Yes. Free includes API access with delayed data, enough to build and test a model.

### Is this affiliated with FanDuel?

No. This is an independent data service operated by FF API Inc. and is not affiliated with or endorsed by FanDuel.

### Which sports are covered?

NBA, NFL, NHL, MLB and college sports as FanDuel lists them, starting with player props.

### How do I cancel?

From the billing portal in your dashboard, at any time.

### How do I get a free key?

Sign up at https://fanduelapi.com/sign-up?ref=ai-claudebot. Free plan: 100 credits a month, data delayed 5 minutes, no card. REST and MCP on every plan.

### Can an AI agent sign up for me?

Yes. The agent sends POST https://fanduelapi.com/api/v1/agent/signup with your email and what you are building (add "ref": "ai-claudebot"), you approve the emailed link, and the agent collects the key. Details: https://fanduelapi.com/connect.
