About espn-api
espn-api is a skill for developers retrieving sports data through ESPN’s unofficial, undocumented JSON APIs. It guides endpoint selection, request construction, and response parsing, with notes on handling API changes and errors.
Key features
- 01Retrieve scores, standings, and team data
- 02Fetch player data and game logs
- 03Access odds, injuries, and news
- 04Reference league slugs and endpoint catalogs
- 05Handle response schemas and common pitfalls
Use cases
- 01Get league scores for a chosen date
- 02Check a team roster or player season stats
- 03Look up game odds and injury reports
- 04Write API requests with caching and error handling
MCP support
The input does not describe a relationship to MCP.
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ sejaldua/ espn-api --skill espn-apiAfter installing, type/espn-apiin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
LICENSE.gitignoreREADME.mdreferences/league-slugs.mdendpoints.mdgotchas.mdresponse-schemas.mdscripts/espn_fetch.shespn_fetch.pyDetails
From the project READMEESPN Public API Skill
You are an expert at using ESPN's undocumented public JSON APIs to fetch sports data. These APIs power espn.com and the ESPN mobile app. They require no authentication and return JSON.
Important: These are unofficial, undocumented APIs. They may change without notice. Be respectful with request volume, implement caching when possible, and handle errors gracefully.
How to Use This Skill
- Identify what the user needs (scores, standings, player stats, odds, etc.)
- Determine the sport and league using the slug reference in references/league-slugs.md
- Pick the right API domain and endpoint from references/endpoints.md
- Construct the URL and fetch the data
- Parse the JSON response using patterns from references/response-schemas.md
- Watch for common pitfalls documented in references/gotchas.md
API Domains
There are six ESPN API domains. Choose based on your data need:
| Domain | Base URL | Use For |
|---|---|---|
| Site API | https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/ | Scores, teams, rosters, news, injuries, game summaries |
| Site API v2 | https://site.api.espn.com/apis/v2/sports/{sport}/{league}/ | Standings only (the site/v2 path returns a stub for standings) |
| Core API v2 | https://sports.core.api.espn.com/v2/sports/{sport}/leagues/{league}/ | Athletes, detailed stats, odds, play-by-play, venues, coaches |
| Core API v3 | https://sports.core.api.espn.com/v3/sports/{sport}/{league}/ | Enriched athlete data, leaders |
| Web API v3 | https://site.web.api.espn.com/apis/common/v3/sports/{sport}/{league}/ | Player season stats, gamelogs, splits, leaderboards |
| CDN | https://cdn.espn.com/core/{league-abbrev}/ | Full game packages (boxscore + plays + win prob). Requires ?xhr=1 |
| Now API | https://now.core.api.espn.com/v1/sports/news | Real-time news feed |
Quick Start Recipes
Get today's scores for any league
curl "https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/scoreboard"
# Example: NBA scores today
curl "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/scoreboard"
# Scores for a specific date
curl "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/scoreboard?dates=20250315"
Get standings
# IMPORTANT: Use /apis/v2/ NOT /apis/site/v2/ (the latter returns a stub)
curl "https://site.api.espn.com/apis/v2/sports/basketball/nba/standings"
curl "https://site.api.espn.com/apis/v2/sports/football/nfl/standings"
Get all teams
curl "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/teams"
Get a team's roster
# Team IDs: look them up from the teams endpoint first
curl "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/teams/13/roster"
Get a full game summary (boxscore + plays + leaders)
curl "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/summary?event=401765432"
Get player season stats
# Uses the Web API v3 domain. Works for NFL, NBA, NHL, MLB.
curl "https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/3136776/stats"
Get player game log
curl "https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/3136776/gamelog"
Get betting odds for a game
curl "https://sports.core.api.espn.com/v2/sports/basketball/leagues/nba/events/{eventId}/competitions/{eventId}/odds"
Get league-wide injury report
curl "https://site.api.espn.com/apis/site/v2/sports/football/nfl/injuries"
Get real-time news
curl "https://now.core.api.espn.com/v1/sports/news?sport=basketball&league=nba&limit=20"
Get full game package via CDN (richest data)
# Returns gamepackageJSON with drives, plays, win probability, boxscore, odds
curl "https://cdn.espn.com/core/nba/game?xhr=1&gameId=401765432"
curl "https://cdn.espn.com/core/nfl/boxscore?xhr=1&gameId=401671793"
Common Query Parameters
| Parameter | Description | Example |
|---|---|---|
dates | Date filter (YYYYMMDD or range) | 20250315 or 20250301-20250331 |
season | Season year | 2025 |
seasontype | 1=preseason, 2=regular, 3=postseason, 4=offseason | 2 |
week | Week number | 1 |
limit | Results per page | 100 |
page | Page number | 1 |
groups | Conference ID (college sports) | 8 (SEC) |
xhr | Required for CDN endpoints | 1 |
active | Filter active athletes | true |
Season Types
| Type | Value | Description |
|---|---|---|
| Preseason | 1 | Exhibition/preseason games |
| Regular Season | 2 | Regular season |
| Postseason | 3 | Playoffs/postseason |
| Off Season | 4 | Off season |
Betting Provider IDs
When filtering odds by provider:
| Provider | ID |
|---|---|
| Caesars | 38 |
| FanDuel | 37 |
| DraftKings | 41 |
| BetMGM | 58 |
| ESPN BET | 68 |
| Bet365 | 2000 |
Writing Code
When the user wants to write code that calls the ESPN API:
Python (requests or httpx)
import requests
def get_nba_scoreboard(date=None):
url = "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/scoreboard"
params = {}
if date:
params["dates"] = date # YYYYMMDD format
resp = requests.get(url, params=params, timeout=30)
resp.raise_for_status()
data = resp.json()
return data["events"]
JavaScript/TypeScript (fetch)
async function getNBAScoreboard(date?: string) {
const url = new URL("https://site.api.espn.com/apis/site/v2/sports/basketball/nba/scoreboard");
if (date) url.searchParams.set("dates", date);
const resp = await fetch(url.toString());
if (!resp.ok) throw new Error(`ESPN API error: ${resp.status}`);
const data = await resp.json();
return data.events;
}
Best practices for ESPN API code
- Always set a timeout (30s recommended)
- Implement caching for data that does not change frequently (teams, standings, rosters)
- Handle 404s gracefully (invalid IDs, offseason endpoints)
- Handle 429s (rate limiting) with exponential backoff
- The API is undocumented, so always validate response shape before accessing nested fields
- Use
User-Agentheader to identify your app
For Deeper Reference
- Full endpoint catalog: references/endpoints.md
- All sport and league slugs: references/league-slugs.md
- JSON response schemas with examples: references/response-schemas.md
- Common pitfalls and gotchas: references/gotchas.md
- Python fetch helper: scripts/espn_fetch.py
- Bash fetch helper: scripts/espn_fetch.sh