Baseball Reference Scraper - Player Stats avatar

Baseball Reference Scraper - Player Stats

Under maintenance

Pricing

from $5.00 / 1,000 results

Go to Apify Store
Baseball Reference Scraper - Player Stats

Baseball Reference Scraper - Player Stats

Under maintenance

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.

Pricing

from $5.00 / 1,000 results

Rating

0.0

(0)

Developer

lulz bot

lulz bot

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

16 hours ago

Last modified

Categories

Share

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-stat attributes 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 URL
  • season - Optional year to filter to a specific season
  • limit - 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

TeamCodeExample URL
New York YankeesNYY/teams/NYY/2024.shtml
Los Angeles DodgersLAD/teams/LAD/2024.shtml
Los Angeles AngelsLAA/teams/LAA/2024.shtml
Boston Red SoxBOS/teams/BOS/2024.shtml
Chicago CubsCHC/teams/CHC/2024.shtml
Houston AstrosHOU/teams/HOU/2024.shtml
Atlanta BravesATL/teams/ATL/2024.shtml
San Francisco GiantsSFG/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 + cheerio for fast HTML parsing (no browser needed)
  • Extracts data from data-stat attributes on table cells for reliable field mapping
  • Parses JSON-LD schema.org/Person data 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