Fantasy football data API in Python
Pull season PPR leaders, weekly lines and snap shares, injuries and depth charts in Python, and build a backfield board you can export to CSV or a spreadsheet.
Every script run against the live API on December 4, 2026. One full run: 34 credits.
This is a data API for fantasy football, not a league-management one. It does not connect to a fantasy league platform or read your roster. It serves what you analyze: fantasy points by week, snap counts, injuries and depth charts, for every season back to 1999 (snap counts from 2013).
The tutorial pulls the 2025 PPR leaders by position, then builds a board for one backfield: Pittsburgh's Kenneth Gainwell and Jaylen Warren, with weekly points, targets and snap share, plus the Week 17 injury report and depth chart. One full run costs 34 credits: 15 for the three leaderboards, 15 for the two players' lines and the team's snap counts, and 4 for the injury report and depth chart.
1. Install the client and set your key
The client has no required dependencies. This tutorial uses pandas for the tables and matplotlib for the chart. The client reads your key from ENDZONEAPI_API_KEY.
pip install "endzoneapi[pandas]" matplotlib
export ENDZONEAPI_API_KEY=your_key_here2. Rank players by PPR points
get_player_leaders ranks players on any weekly stat over a season. fantasy_points_ppr is full-PPR scoring summed over the games they played. min_games keeps out players with a few big weeks, and the script adds points per game.
import pandas as pd
from endzoneapi import Client, to_dataframe
client = Client() # reads ENDZONEAPI_API_KEY
frames = []
for position in ["RB", "WR", "TE"]:
out = client.get_player_leaders(
"fantasy_points_ppr", season=2025, position=position, min_games=8, limit=40
)
frame = to_dataframe(out, key="leaders")
frame["ppg"] = frame["value"] / frame["games"]
frames.append(frame)
leaders = pd.concat(frames, ignore_index=True)
leaders = leaders.rename(columns={"value": "ppr_points"})
leaders.to_csv("ppr_leaders_2025.csv", index=False)
cols = ["rank", "name", "team", "games", "ppr_points", "ppg"]
for position, frame in leaders.groupby("position"):
print(position)
print(frame[cols].round(1).head(3).to_string(index=False))
print("credits left:", client.last_credits_remaining)Output
RB
rank name team games ppr_points ppg
1 Christian McCaffrey SF 17 416.6 24.5
2 Bijan Robinson ATL 17 370.8 21.8
3 Jahmyr Gibbs DET 17 366.9 21.6
TE
rank name team games ppr_points ppg
1 Trey McBride ARI 17 315.9 18.6
2 Kyle Pitts ATL 17 210.8 12.4
3 Travis Kelce KC 17 193.2 11.4
WR
rank name team games ppr_points ppg
1 Puka Nacua LA 16 375.0 23.4
2 Jaxon Smith-Njigba SEA 17 359.9 21.2
3 Amon-Ra St. Brown DET 17 324.0 19.1
credits left: 1101The last line is the credit balance of the key that ran it; yours will differ. The file has 120 rows, 40 per position. Swap fantasy_points_ppr for fantasy_points for standard scoring, or for targets, receiving_epa or any of the other weekly columns.
3. Build a board for one backfield
Two calls give the inputs. get_player_stats returns every weekly line for a player, including fantasyPointsPpr, carries and targets. get_snap_counts returns offensive snaps and the share of the team's snaps for every player on a team, by week, and uses the same player ids. The script keeps the regular season (weeks 1 to 18) and joins the two on player and week.
import pandas as pd
from endzoneapi import Client, to_dataframe
client = Client()
backs = {"Kenneth Gainwell": "00-0036919", "Jaylen Warren": "00-0037228"}
lines = []
for name, player_id in backs.items():
stats = client.get_player_stats(player_id, season=2025)
weekly = to_dataframe(stats, key="weeks")
weekly["player_id"] = player_id
lines.append(weekly)
points = pd.concat(lines)[["player_id", "week", "carries", "targets", "fantasyPointsPpr"]]
points = points.rename(columns={"fantasyPointsPpr": "ppr"})
snaps = to_dataframe(client.get_snap_counts(team="PIT", season=2025, limit=1000), key="snap_counts")
snaps = snaps[snaps["player_id"].isin(backs.values()) & (snaps["week"] <= 18)]
snaps = snaps[["player", "player_id", "week", "offense_pct"]]
board = snaps.merge(points, on=["player_id", "week"]).sort_values(["player", "week"])
board.to_csv("pit_backfield_2025.csv", index=False)
print(board.groupby("player").tail(3).to_string(index=False))
print("credits left:", client.last_credits_remaining)Output
player player_id week offense_pct carries targets ppr
Jaylen Warren 00-0037228 16 0.49 14 2 29.1
Jaylen Warren 00-0037228 17 0.32 12 0 6.4
Jaylen Warren 00-0037228 18 0.37 14 5 14.9
Kenneth Gainwell 00-0036919 16 0.54 9 7 23.8
Kenneth Gainwell 00-0036919 17 0.68 7 4 6.8
Kenneth Gainwell 00-0036919 18 0.67 5 9 21.4
credits left: 1086search_players returns the player ids if you do not have them. offense_pct is the share of the team's offensive snaps (0.68 is 68%). The snap-count call returns every Pittsburgh player for the season in one page: 837 rows, under the 1,000-row limit.
4. Compare the season with the last four games
A waiver decision looks at the recent weeks, so the script prints each back's season average next to his last four games.
import pandas as pd
board = pd.read_csv("pit_backfield_2025.csv")
rows = {}
for player, g in board.groupby("player"):
last4 = g.tail(4)
rows[player] = {
"games": len(g),
"snap_pct": g["offense_pct"].mean(),
"snap_pct_last4": last4["offense_pct"].mean(),
"ppr_per_game": g["ppr"].mean(),
"ppr_last4": last4["ppr"].mean(),
"targets_last4": last4["targets"].sum(),
}
print(pd.DataFrame(rows).T.round(2).to_string())
print("snap share vs PPR points, correlation:", round(board["offense_pct"].corr(board["ppr"]), 2))Output
games snap_pct snap_pct_last4 ppr_per_game ppr_last4 targets_last4
Jaylen Warren 16.0 0.51 0.41 13.57 14.55 10.0
Kenneth Gainwell 17.0 0.50 0.60 13.02 17.90 27.0
snap share vs PPR points, correlation: 0.49How to read it:
- Over the season the two split snaps evenly (51% and 50%) and scored about the same per game (13.6 and 13.0 PPR points).
- In the last four games Gainwell played 60% of the snaps and drew 27 targets, to Warren's 41% and 10. His PPR average over those games was 17.9, against 14.6 for Warren.
- Across both backs' games, snap share and PPR points have a correlation of 0.49. Playing time matters, and it leaves most of the week-to-week swing unexplained.
5. Chart the weekly points
import matplotlib.pyplot as plt
import pandas as pd
board = pd.read_csv("pit_backfield_2025.csv")
wide = board.pivot(index="week", columns="player", values="ppr").reindex(range(1, 19))
ax = wide.plot(marker="o", figsize=(9, 4))
ax.set_ylabel("PPR points")
plt.tight_layout()
plt.savefig("pit_backfield_ppr.png", dpi=150)- Kenneth Gainwell
- Jaylen Warren
From the board above. Gainwell missed no game but the bye in week 5; Warren has no row for week 4.
Both backs swung between single digits and 30 points from one week to the next. Weekly fantasy scores are noisy, which is why the board shows snaps and targets next to points.
6. Add the injury report and depth chart
get_injuries returns the official report for a team and week: game status, practice participation and the injury. get_depth_chart returns the team's depth chart by formation and position. Both default to the latest week, so pass week to look back. This is Week 17.
from endzoneapi import Client, to_dataframe
client = Client()
injuries = to_dataframe(client.get_injuries(team="PIT", season=2025, week=17), key="injuries")
print(len(injuries), "players on the Week 17 report")
print(injuries[["name", "position", "report_status", "report_primary_injury"]].head(5).to_string(index=False))
backs = ["00-0036919", "00-0037228"]
print(injuries[injuries["player_id"].isin(backs)][["name", "position", "report_status", "report_primary_injury", "practice_status"]].to_string(index=False))
depth = to_dataframe(client.get_depth_chart("PIT", season=2025, week=17, formation="Offense"), key="depth_chart")
print(depth[depth["position"] == "RB"][["formation", "position", "depth_rank", "name"]].head(4).to_string(index=False))
print("credits left:", client.last_credits_remaining)Output
13 players on the Week 17 report
name position report_status report_primary_injury
Brandin Echols CB Out Groin
Calvin Austin III WR Out Hamstring
James Pierre CB Out Calf
T.J. Watt LB Out Lung
Isaac Seumalo G Questionable Triceps
name position report_status report_primary_injury practice_status
Jaylen Warren RB None None Full Participation in Practice
formation position depth_rank name
3WR 1TE RB 1 Jaylen Warren
3WR 1TE RB 2 Kenneth Gainwell
3WR 1TE RB 3 Kaleb Johnson
credits left: 108213 Pittsburgh players were on the Week 17 report. Warren is one of them with no game status and full practice participation; Gainwell is not listed. The depth chart listed Warren first, Gainwell second and Kaleb Johnson third, while the snap counts that week went 68% to Gainwell and 32% to Warren. A depth chart is a list, not a usage report: check both.
7. Export for a spreadsheet
Every step above saved a CSV, and board.to_csv(...) is all a spreadsheet needs: open pit_backfield_2025.csv in Excel or import it into Google Sheets. To refresh it each week, rerun the script after the games finish.
Tools and credits
- get_player_leaders: 3 calls, 15 credits (RB, WR and TE).
- get_player_stats: 2 calls, 10 credits.
- get_snap_counts: 1 call, 5 credits.
- get_injuries: 1 call, 2 credits.
- get_depth_chart: 1 call, 2 credits.
One full run: 34 credits.
What you can do with the data
You may store these rows, train models and backtest on them, and build products that show your users what you derive. You may not redistribute the rows as a dataset or API of its own. The API does not connect to any fantasy league platform, so rosters and scoring settings stay with you.
Details: data timing and rights.
What to do next
Start with 500 free credits every month
No card. pip install endzoneapi, REST or MCP.