Baseball Reference Scraper - Player Stats
Pricing
from $5.00 / 1,000 results
Baseball Reference Scraper - Player Stats
Scrape Baseball-Reference.com for player stats, career data, and team rosters. Extract batting, pitching, and biographical info using structured data-stat attributes and microdata.
Baseball Reference Scraper
Scrape MLB player statistics, career data, and team rosters from Baseball-Reference.com. Extract batting stats, pitching stats, biographical information, and full team rosters using Baseball-Reference's structured data-stat attributes and schema.org microdata.
Features
- Player Search - Search for players by name and get links to their profile pages
- Player Stats - Extract full career batting and pitching stats for any player
- Team Roster - Get complete team rosters with player stats for any season
- Structured Data - Leverages
data-statattributes and JSON-LD schema.org markup for reliable extraction - Biographical Info - Player name, position, bats/throws, height, weight, birth date, birth place, debut date
- Career Totals - Includes career total rows alongside season-by-season breakdowns
- Two-Way Players - Handles players with both batting and pitching stats (e.g., Shohei Ohtani)
Modes
Player Search (playerSearch)
Search for players by name. Returns matching player names and profile URLs.
Input:
query- Player name to search (e.g., "Mike Trout", "Rodriguez")limit- Maximum number of results (default: 50)
Output:
{"type": "searchResult","playerName": "Mike Trout","url": "https://www.baseball-reference.com/players/t/troutmi01.shtml","directMatch": true,"query": "Mike Trout"}
Player Stats (playerStats)
Get full career statistics for a specific player. Returns batting and/or pitching stats by season plus career totals.
Input:
playerUrl- Full Baseball-Reference player URLseason- Optional year to filter to a specific seasonlimit- Maximum number of season rows to return
Output:
{"type": "playerStats","playerName": "Mike Trout","position": "Centerfielder","bats": "Right","throws": "Right","height": "6-1","weight": "235 lbs","birthDate": "1991-08-07","team": "Los Angeles Angels","battingSeasons": [{"season": "2012","team": "LAA","gamesPlayed": 139,"atBats": 559,"hits": 182,"homeRuns": 30,"rbi": 83,"battingAverage": ".326","ops": ".963"}],"battingCareerTotals": {"gamesPlayed": 1240,"homeRuns": 378,"battingAverage": ".299"}}
Team Roster (teamRoster)
Get the full roster and stats for a team in a given season.
Input:
teamUrl- Full Baseball-Reference team page URL (e.g.,https://www.baseball-reference.com/teams/LAA/2024.shtml)limit- Maximum number of players to return
Output:
{"type": "rosterPlayer","playerName": "Mike Trout","position": "CF","team": "Los Angeles Angels","season": "2024","gamesPlayed": 29,"homeRuns": 10,"battingAverage": ".220","url": "https://www.baseball-reference.com/players/t/troutmi01.shtml"}
Common Team URL Codes
| Team | Code | Example URL |
|---|---|---|
| New York Yankees | NYY | /teams/NYY/2024.shtml |
| Los Angeles Dodgers | LAD | /teams/LAD/2024.shtml |
| Los Angeles Angels | LAA | /teams/LAA/2024.shtml |
| Boston Red Sox | BOS | /teams/BOS/2024.shtml |
| Chicago Cubs | CHC | /teams/CHC/2024.shtml |
| Houston Astros | HOU | /teams/HOU/2024.shtml |
| Atlanta Braves | ATL | /teams/ATL/2024.shtml |
| San Francisco Giants | SFG | /teams/SFG/2024.shtml |
Batting Stats Extracted
Games (G), Plate Appearances (PA), At Bats (AB), Runs (R), Hits (H), Doubles (2B), Triples (3B), Home Runs (HR), RBI, Stolen Bases (SB), Caught Stealing (CS), Walks (BB), Strikeouts (SO), Batting Average (AVG), On-Base Percentage (OBP), Slugging Percentage (SLG), OPS, OPS+, Total Bases (TB), GDP, HBP, Sacrifice Hits, Sacrifice Flies, Intentional Walks
Pitching Stats Extracted
Wins (W), Losses (L), Win-Loss %, ERA, Games (G), Games Started (GS), Complete Games (CG), Shutouts (SHO), Saves (SV), Innings Pitched (IP), Hits Allowed, Earned Runs, Home Runs Allowed, Walks, Strikeouts, WHIP, ERA+, H/9, HR/9, BB/9, SO/9, SO/W
Proxy Configuration
Baseball-Reference may rate-limit aggressive scraping. Residential proxies are recommended for large-scale runs. The default configuration uses Apify residential proxies.
Technical Notes
- Uses
got-scraping+cheeriofor fast HTML parsing (no browser needed) - Extracts data from
data-statattributes on table cells for reliable field mapping - Parses JSON-LD
schema.org/Persondata for biographical information - Handles HTML comments (Baseball-Reference hides some tables inside comments)
- Respects rate limits with built-in delays and retry logic
- Pay-per-event charging: billed per result returned