How do I calculate NFL EPA per play in Python?
Every play a team ran in a season with expected points added, win probability and success on each row, and a summary the API computes for you.
Code verified October 10, 2026. One call to get_plays, 10 credits.
The call
posteam is the offense. Use defteam to see the same numbers from the defense. A call returns up to 1,000 plays; page with offset past that.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.endzoneapi.com/v1/get_plays",
headers={"x-api-key": API_KEY},
json={
"posteam": "KC",
"season": 2025,
"limit": 1000,
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
plays = pd.DataFrame(data["plays"])
print(data["summary"])
by_type = plays.groupby("play_type").agg(
plays=("epa", "count"),
epa_per_play=("epa", "mean"),
success_rate=("success", "mean"),
)
print(by_type.round(3).sort_values("plays", ascending=False))
print(plays.groupby("down")["epa"].mean().round(3))
Replace YOUR_API_KEY with a key from your dashboard. Python needs requests and pandas (pip install requests pandas). JavaScript runs on Node 18 or newer, or in the browser.
What comes back
The data object of the response, trimmed to the first rows. Every field is real output from the run above.
{
"plays": [
{
"game_id": "2025_01_KC_LAC",
"week": 1,
"posteam": "KC",
"defteam": "LAC",
"qtr": 1,
"down": null,
"ydstogo": 0,
"play_type": "kickoff",
"desc": "11-C.Dicker kicks 59 yards from LAC 35 to KC 6. 80-T.Thornton pushed ob at KC 48 for 42 yards (24-B.St-Juste). PENALTY on KC-2-J.Williams, Offensive Holding, 10 yards, enforced at KC 34.",
"yards_gained": 0,
"epa": -0.24012075,
"wp": 0.43320796,
"success": 0
},
{
"game_id": "2025_01_KC_LAC",
"week": 1,
"posteam": "KC",
"defteam": "LAC",
"qtr": 1,
"down": 1,
"ydstogo": 10,
"play_type": "run",
"desc": "(14:52) (Shotgun) 10-I.Pacheco right guard to KC 28 for 4 yards (32-A.Gilman; 0-D.Henley).",
"yards_gained": 4,
"epa": -0.008932982,
"wp": 0.43320796,
"success": 0
},
"...998 more"
],
"summary": {
"plays": 1000,
"epa_total": 113.68,
"epa_per_play": 0.114,
"success_rate": 0.491
},
"count": 1000,
"next_offset": 1000
}What to do next
- get_team_stats (5 credits). Team EPA and success rate by week and situation without pulling every play.
- get_advanced_stats (5 credits). Next Gen Stats and Pro Football Reference metrics for the players behind the plays.
More guides
Start with 500 free credits
No card. REST or MCP.