Baseball-Reference APIbaseball-reference.com ↗
Access MLB player stats, team rosters, box scores, league leaders, and NCAA D1 college baseball data from Baseball-Reference via a single REST API.
What is the Baseball-Reference API?
This API exposes 7 endpoints covering MLB and NCAA Division I baseball data from Baseball-Reference, including career and season-level player stats, team rosters, full game box scores with play-by-play, season schedules, league leaders, and college conference rosters. The get_player_stats endpoint returns batting, pitching, and fielding rows broken out by season, while get_box_score delivers per-player lines and play-by-play for any game identified by its game ID.
curl -X GET 'https://api.parse.bot/scraper/21934c77-6ae3-4dcd-b3f8-d736f3a15615/get_player_stats?player_id=ohtansh01' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace baseball-reference-com-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
"""Walkthrough: Baseball-Reference SDK — bounded, re-runnable; every call capped."""
from parse_apis.baseball_reference_api import (
BaseballReference, LeaderCategory, TeamId, ResourceNotFound
)
client = BaseballReference()
# Get a player's career stats by their Baseball-Reference ID.
player = client.players.get(player_id="ohtansh01")
print(f"Player: {player.name}, Born: {player.birth_date}, Bats/Throws: {player.bats_throws}")
# Inspect batting seasons — each row is one year of stats.
for season in player.batting_stats[:3]:
print(f" {season.year_id} ({season.team_name_abbr}): {season.b_hr} HR, {season.b_batting_avg} AVG")
# Get 2024 batting leaders using the LeaderCategory enum.
board = client.leaderboards.get(year=2024)
print(f"\n2024 {board.category} leaders:")
for stat_name, entries in list(board.leaders.items())[:2]:
top = entries[0]
print(f" {stat_name}: {top.player} ({top.team}) — {top.value}")
# Construct a team by abbreviation and fetch its schedule.
dodgers = client.team(team_id=TeamId.LAD)
sched = dodgers.schedule(year=2024)
first_game = sched.schedule[0]
print(f"\nFirst game: vs {first_game.opp_ID}, Result: {first_game.win_loss_result} ({first_game.R}-{first_game.RA})")
# Typed-error catch: look up a non-existent player.
try:
client.players.get(player_id="nonexist99")
except ResourceNotFound as exc:
print(f"\nExpected error caught: {exc}")
# College: list SEC conference teams, then get one team's pitching.
sec = client.conferences.get(league_id="82d1384a")
print(f"\n{sec.league_name} — {len(sec.teams)} teams")
first_team_entry = sec.teams[0]
college_team = client.collegeteams.get(team_id=first_team_entry.id)
for pitcher in college_team.pitching[:2]:
print(f" {pitcher.player}: {pitcher.W}W-{pitcher.L}L, {pitcher.earned_run_avg} ERA")
print("\nExercised: players.get / leaderboards.get / team.schedule / conferences.get / collegeteams.get")
Get comprehensive player statistics including batting, pitching, and fielding for careers and individual seasons. Returns season-by-season rows for each stat category the player has data for. The player page includes biographical info (position, bats/throws, birth date) and standard stat tables. Players with only batting or only pitching will have the other array empty.
| Param | Type | Description |
|---|---|---|
| player_idrequired | string | Baseball-Reference player ID (e.g., 'ohtansh01', 'troutmi01', 'jeterde01') |
{
"type": "object",
"fields": {
"name": "string — player's display name",
"position": "string — primary position (when available)",
"player_id": "string — the requested player ID",
"birth_date": "string — birth date in YYYY-MM-DD format (when available)",
"bats_throws": "string — batting/throwing hand info (when available)",
"batting_stats": "array of season batting stat rows",
"fielding_stats": "array of season fielding stat rows",
"pitching_stats": "array of season pitching stat rows"
},
"sample": {
"data": {
"name": "Shohei Ohtani",
"player_id": "ohtansh01",
"birth_date": "1994-07-05",
"bats_throws": "Left",
"batting_stats": [
{
"age": "23",
"b_hr": "22",
"b_war": "2.7",
"b_games": "104",
"year_id": "2018",
"b_batting_avg": ".285",
"team_name_abbr": "LAA"
}
],
"fielding_stats": [
{
"age": "23",
"f_games": "82",
"year_id": "2018",
"f_position": "DH"
}
],
"pitching_stats": [
{
"age": "23",
"p_l": "2",
"p_w": "4",
"p_war": "1.3",
"year_id": "2018",
"team_name_abbr": "LAA",
"p_earned_run_avg": "3.31"
}
]
},
"status": "success"
}
}About the Baseball-Reference API
Player and Team Data
The get_player_stats endpoint accepts a Baseball-Reference player_id (e.g., ohtansh01, troutmi01) and returns the player's display name, position, birth date, bats/throws info, and three separate stat arrays: batting_stats, pitching_stats, and fielding_stats, each containing season-by-season rows. The get_team_stats endpoint takes a four-digit year and a three-letter team_id (e.g., LAD, NYY) and returns the full-season roster with appearance data, plus team_batting and team_pitching arrays covering every player who appeared for that club.
Schedules and Box Scores
get_team_schedule returns a full regular-season game list for a given team and year, with each row including date, opponent, score, and a boxscore link. For individual games, get_box_score accepts a structured game_id — formatted as the three-letter home team code followed by a date string and game number (e.g., LAN202403210) — and returns per-player batting and pitching lines keyed by team table ID, plus a play_by_play array covering every play in the game.
League Leaders and College Coverage
get_league_leaders accepts a year and an optional category of batting or pitching, returning up to 10 leaders per statistical category (e.g., Home Runs, Batting Average) with rank, player name, and team. For college data, get_college_conference_teams lists all Division I teams in a conference given a league_id hash (e.g., 82d1384a for the 2025 SEC), and get_college_team_stats returns roster entries, batting rows, and pitching rows for any team whose team_id hash was discovered from that conference listing.
The Baseball-Reference API is a managed, monitored endpoint for baseball-reference.com — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when baseball-reference.com changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official baseball-reference.com API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Build a fantasy baseball dashboard that pulls season batting and pitching splits for any player using
get_player_stats. - Track a team's win/loss record and run differential across an entire season with
get_team_schedule. - Reconstruct full game narratives by combining
get_box_scorebatting lines and play-by-play entries. - Display MLB home run and strikeout leaders for a given year using
get_league_leaderswith the pitching or batting category. - Compare team ERA and batting average across a season roster via
get_team_statspitching and batting arrays. - Scout NCAA Division I prospects by pulling college team rosters and stats for any SEC or other conference team.
- Populate a historical stats database by iterating known player IDs through
get_player_statsfor multi-decade career records.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does Baseball-Reference have an official developer API?+
What does `get_box_score` return beyond the basic score, and how do I identify a game?+
batting object and a pitching object, each keyed by team table ID with arrays of individual player lines, plus a full play_by_play array. Game IDs follow the pattern of the three-letter home team code plus date plus game number — for example, LAN202403210 for a Dodgers home game. Team schedules from get_team_schedule include boxscore links that contain the game ID.How do I find the correct college team ID to use with `get_college_team_stats`?+
0294f3dc for LSU). The intended workflow is to call get_college_conference_teams first with a known league_id — the 2025 SEC uses 82d1384a — and extract the id field from the returned teams array. League IDs for conferences outside the confirmed SEC example may require discovery.