REST API
Access over 150 years of Major League Baseball statistics programmatically. All endpoints return JSON and require no authentication.
Base URL
https://your-host/api
All endpoints below are relative to this base. Responses use application/json.
Pagination
List endpoints return a standard pagination envelope:
{
"data": [ ... ],
"page": 1,
"pageSize": 25,
"totalCount": 1234,
"totalPages": 50
}
Use page and pageSize query parameters to navigate.
Maximum pageSize is 100.
Players
GET/api/players
List players filtered by last name initial.
| Parameter | Type | Default | Description |
|---|---|---|---|
letter | string | A | Last name initial (A-Z) |
page | int | 1 | Page number |
pageSize | int | 25 | Results per page (max 100) |
Example:
curl "https://your-host/api/players?letter=R&page=1&pageSize=10"
GET/api/players/{playerId}
Full player detail including career batting/pitching stats, teams played for, and Hall of Fame status.
Example:
curl "https://your-host/api/players/ruthba01"
GET/api/players/{playerId}/batting
Season-by-season batting statistics with team names and computed batting average.
GET/api/players/{playerId}/pitching
Season-by-season pitching statistics with ERA.
GET/api/players/{playerId}/fielding
Season-by-season fielding stats by position (putouts, assists, errors, double plays).
GET/api/players/{playerId}/awards
All awards won (MVP, Cy Young, Gold Glove, etc.).
GET/api/players/{playerId}/postseason/batting
Postseason batting stats by year and round (ALCS, NLCS, WS, etc.).
GET/api/players/{playerId}/postseason/pitching
Postseason pitching stats by year and round.
Teams
GET/api/teams/franchises
List all franchises with all-time records, championships, and pennants.
| Parameter | Type | Default | Description |
|---|---|---|---|
league | string | — | Filter by league (AL, NL) |
activeOnly | bool | false | Only active franchises |
Example:
curl "https://your-host/api/teams/franchises?league=AL&activeOnly=true"
GET/api/teams/franchises/{franchiseId}
Franchise detail with every season's record, division/pennant/World Series wins.
Example:
curl "https://your-host/api/teams/franchises/NYY"
GET/api/teams/seasons/{teamId}/{lgId}/{year}
Complete team season: record, batting/pitching aggregates, full roster (batters and pitchers), and managers. Includes Hall of Fame flags.
Example:
curl "https://your-host/api/teams/seasons/NYA/AL/1927"
Leaders
GET/api/leaders/batting
Batting leaderboard ranked by any stat. Supports career and single-season modes.
| Parameter | Type | Default | Description |
|---|---|---|---|
stat | string | hr | Stat to sort by: hr, h, avg, r, rbi, sb, bb, ops, obp, slg, 2b, 3b, g, ab |
fromYear | int | — | Start year |
toYear | int | — | End year |
league | string | — | League filter (AL, NL) |
minAb | int | 0 | Minimum at-bats |
singleSeason | bool | false | Single season vs. career totals |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
Example: Top single-season home run totals since 2000:
curl "https://your-host/api/leaders/batting?stat=hr&singleSeason=true&fromYear=2000"
GET/api/leaders/pitching
Pitching leaderboard. ERA and WHIP sort ascending (lower is better); all others descending.
| Parameter | Type | Default | Description |
|---|---|---|---|
stat | string | w | Stat to sort by: w, so, sv, era, whip, g, gs, cg, sho, ip, hr, k9, bb9, wpct |
fromYear | int | — | Start year |
toYear | int | — | End year |
league | string | — | League filter (AL, NL) |
minIp | int | 0 | Minimum innings pitched |
singleSeason | bool | false | Single season vs. career totals |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
Example: Career strikeout leaders with at least 1000 IP:
curl "https://your-host/api/leaders/pitching?stat=so&minIp=1000"
Hall of Fame
GET/api/hall-of-fame
List Hall of Fame inductees with vote percentages.
| Parameter | Type | Default | Description |
|---|---|---|---|
year | int | — | Induction year |
category | string | — | Category: Player, Manager, Pioneer/Executive, Umpire |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
GET/api/hall-of-fame/{playerId}/voting
Complete voting history for a player across all ballot years.
Example:
curl "https://your-host/api/hall-of-fame/jeterda01/voting"
Search
GET/api/search
Search across players and franchises by name. Returns both result types with total counts.
| Parameter | Type | Default | Description |
|---|---|---|---|
q | string | required | Search query (min 2 characters) |
limit | int | 10 | Max results per type (max 50) |
Example:
curl "https://your-host/api/search?q=griffey"
Salaries
GET/api/salaries/players/{playerId}
Player salary history with career total. Data available from 1985 onward.
Example:
curl "https://your-host/api/salaries/players/troutmi01"
GET/api/salaries/teams/{teamId}/{year}
Team payroll breakdown for a given season.
Example:
curl "https://your-host/api/salaries/teams/NYA/2014"
GET/api/salaries/leaders
Highest-paid players. Paginated.
| Parameter | Type | Default | Description |
|---|---|---|---|
year | int | — | Filter to a specific year |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
Ballparks
GET/api/parks
List all ballparks. Paginated.
| Parameter | Type | Default | Description |
|---|---|---|---|
state | string | — | Filter by state code |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
GET/api/parks/{parkKey}
Park detail with season-by-season attendance and game counts.
Postseason
GET/api/postseason/series
Postseason series results (World Series, LCS, Division Series, Wild Card). Paginated.
| Parameter | Type | Default | Description |
|---|---|---|---|
year | int | — | Filter by year |
round | string | — | Filter by round (WS, ALCS, NLCS, ALDS, NLDS, ALWC, NLWC) |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
Example: All World Series results:
curl "https://your-host/api/postseason/series?round=WS&pageSize=100"
GET/api/postseason/series/{year}
All postseason series for a given year.
Example:
curl "https://your-host/api/postseason/series/2024"
Awards
GET/api/awards/winners
Award winners with optional filters. Paginated.
| Parameter | Type | Default | Description |
|---|---|---|---|
awardId | string | — | Filter by award (e.g. MVP, Cy Young, Gold Glove) |
year | int | — | Filter by year |
lgId | string | — | Filter by league (AL, NL) |
page | int | 1 | Page number |
pageSize | int | 50 | Results per page (max 100) |
Example: All AL MVP winners:
curl "https://your-host/api/awards/winners?awardId=MVP&lgId=AL"
GET/api/awards/voting/{awardId}/{year}/{lgId}
Full voting breakdown for an award race. Shows every candidate with points won, max possible, first-place votes, and vote share percentage.
Example: 2023 AL MVP voting race:
curl "https://your-host/api/awards/voting/MVP/2023/AL"
Response Codes
| Code | Meaning |
|---|---|
200 | Success |
400 | Bad request (e.g. search query too short) |
404 | Resource not found |
Data Notes
- All data is from the Lahman Baseball Database, covering 1871 to 2025.
- The database is read-only. All endpoints are
GETrequests. - Player IDs follow the Lahman convention (e.g.
ruthba01,jeterda01,troutmi01). - Franchise IDs match Lahman franchise codes (e.g.
NYY,BOS,LAD). - Computed stats (AVG, OBP, SLG, OPS, ERA, WHIP) are calculated server-side and returned as rounded doubles.
- Salary data is available from 1985 onward.
- Innings pitched is stored as outs in the database and converted to innings (outs / 3) in responses.