ParseForge Scrapers

MLB Stats Scraper

parseforge/mlb-stats-scraper

News & mediaBusinessAutomation

Scrapes official MLB stats by mode: schedule, teams, roster, player stats, or live game detail. Returns each record as a flat row ready for CSV, JSON, Excel, or XML export.

Run this scraper See the API call
Total users
185
Monthly active
45
Total runs
1.9K
Bookmarked
1
Rating
Not rated yet
Last modified
12 days ago

Overview

ParseForge

MLB Stats Scraper

Scrape official MLB stats for any player, team, roster, schedule, or live game detail. Pull season stats, game feeds, and team data straight from the MLB Stats API. Export to CSV, JSON, Excel, or XML.

The MLB Stats API is the official data feed behind every box score, but pulling it into a flat dataset means handling nested endpoints, pagination, and date logic. This Actor wraps the feed so you request a mode (schedule, teams, roster, player stats, or live game detail), set a few filters, and get back clean rows. No API key, no hand-rolled client.

Who uses it What they scrape MLB Stats API for
Sports analysts Pull season-long player stats to build performance models.
Fantasy baseball players Grab daily schedules and rosters to set lineups.
Sportsbook operators Fetch live game details to feed real-time betting markets.
Data journalists Collect historical schedules and team data for season previews.

What it does

This Actor collects MLB data by mode (schedule, teams, roster, player stats, or game detail) and returns each record as a flat row.

  • ๐Ÿ“… Schedule mode: pull games by date, season, and game type (regular, postseason, or All-Star).
  • ๐Ÿงข Teams mode: get the full list of active MLB teams with their IDs and league info.
  • ๐Ÿ‘ฅ Roster mode: fetch a team's current roster, or batch up to 100 team IDs in one run.
  • ๐Ÿ“Š Player Stats mode: request season stats for a single player, or batch up to 100 player IDs.
  • โšพ Game Detail mode: get the live feed for a specific game by its MLB game PK.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

What you can do with MLB Stats API data

๐Ÿ“ˆ Build a player performance dashboard.

A fantasy analyst runs playerStats mode with a batch of player IDs each morning and feeds the CSV into a Google Sheet that tracks rolling averages.

๐Ÿ“… Monitor today's matchups.

A sportsbook operator runs schedule mode with today's date and the regular season filter to populate a daily odds board.

๐Ÿงข Audit team rosters weekly.

A data journalist runs roster mode for all 30 teams every Monday to track call-ups and injuries for a weekly column.

โšพ Power a live score widget.

A developer runs gameDetail mode for an active game PK every 60 seconds and pushes the live feed to a website widget.

Why choose this scraper

What you get
Official data source Reads directly from the MLB Stats API, the same feed that powers MLB.com.
Five modes, one actor Schedule, teams, roster, player stats, and live game detail in a single tool.
Batch lookups Send up to 100 team IDs or player IDs per run for roster and stats modes.
Flat output Nested API responses are flattened into rows ready for CSV, JSON, Excel, or XML.

How it compares

No other Store actor targets MLB Stats API the same way, so the honest comparison is with the alternatives teams actually weigh.

MLB Stats Scraper Build it in-house By hand
Setup Run it now, zero config Days of engineering None, but hours per pull
When MLB Stats API changes Maintained for you You fix it You re-learn the page
Proxies, retries, anti-bot Built in Your problem Browser only
Output Fixed JSON schema, CSV/Excel export Whatever you build Copy-paste
Cost Pay per result Engineering time Analyst hours

Configure the run

Drive the Actor by picking a mode, then supply a date, team ID, player ID, game PK, or season year. Filters run as each request is made so only matching records reach your dataset. The Input tab lists every parameter.

A first run with the defaults:

{
  "mode": "schedule",
  "maxItems": 10
}

A larger pull:

{
  "mode": "schedule",
  "maxItems": 200
}

Pricing

Pay-per-result: $0.034 per result collected. You pay only for the results written to your dataset.

Results collected Approximate cost
100 results $3.40
1,000 results $34.00
10,000 results $340.00

New Apify accounts start with $5 in free credit.

Free users

Free-plan runs return up to 10 results as a preview. Upgrade your Apify plan to collect up to 1,000,000 results per run.

Run it

  1. Create a free Apify account with $5 in credit.
  2. Open the MLB Stats Scraper.
  3. Set your inputs and any filters, then click Start.
  4. Export the results as CSV, Excel, JSON, or XML from the Dataset tab.

Run it programmatically through the Apify API (run-sync-get-dataset-items) or the ApifyClient for JavaScript and Python.

Use with AI agents (MCP)

Give an AI agent live access to MLB Stats API through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

claude mcp add --transport http apify "https://mcp.apify.com?tools=parseforge/mlb-stats-scraper"

Then prompt it in plain language to run the scraper and read back the results.

Troubleshooting

Why am I getting no results from schedule mode?

Check that the date you supplied has games. If you left the date blank, it defaults to today. During the offseason or on off-days, there may be no games scheduled. Try a date during the regular season.

Why does my player ID return an error?

Make sure the player ID is correct. Run roster mode for the player's team to verify the ID. Also confirm the player is on an active roster or has stats for the season you requested.

Why is my batch lookup slow?

Batch lookups for up to 100 team IDs or player IDs make one API call per ID. Set maxItems to a reasonable number and expect longer runs for large batches.

Why am I getting a 404 for a game PK?

The game PK may be for a future game that does not have a live feed yet, or a past game outside the accessible range. Verify the game PK by running schedule mode for the game's date.

Why does my CSV have nested fields?

Some MLB API responses contain deeply nested objects. The Actor flattens most fields, but very complex nested structures may appear as JSON strings in a cell. Use the JSON export format if you need to parse these programmatically.

FAQ

Question Answer
Do I need an MLB API key to use this scraper? No. This Actor reads from the public MLB Stats API endpoints. No registration or API key is required.
What is a game PK and where do I find it? A game PK is MLB's unique identifier for a single game. You can find it by running schedule mode first. Each game in the schedule output includes its gamePk.
How do I find a team ID? Run the Actor in teams mode to get the full list of MLB teams with their IDs. Common IDs include 147 for the Yankees and 119 for the Dodgers.
How do I find a player ID? Run roster mode for a team to see its current players and their IDs. You can also look up a player on the MLB website. The numeric ID in the URL is their player ID.
Can I get stats for multiple players at once? Yes. Use the playerIds array in playerStats mode to send up to 100 player IDs in a single run.
Can I get rosters for multiple teams at once? Yes. Use the teamIds array in roster mode to send up to 100 team IDs in a single run.
What seasons does this cover? The MLB Stats API includes historical data going back many years. Set the season field to any year from 1900 onward.
Can I filter the schedule by postseason games only? Yes. Set seasonType to 'post' for a shortcut that includes Wild Card, Division Series, League Championship, and World Series games. Or set gameType to a specific round.
What does the live game detail feed include? Game detail mode returns the full live feed: current score, inning, outs, runners on base, count on the batter, and play-by-play events.
How many records can I collect in one run? You can set maxItems up to 1,000,000 records per run. The actual number depends on the mode and the date range or batch size you supply.

Related actors

Browse the full ParseForge collection for more scrapers.

๐Ÿ†˜ Need help? Email parseforge@protonmail.com with your run ID, your input, and what you expected.

โš ๏ธ Disclaimer. This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by MLB Advanced Media, L.P. It collects only publicly available data. You are responsible for using the collected data in compliance with the source's terms of service and applicable data-protection laws, including GDPR, CCPA, and PIPL. Do not use it to collect personal data unlawfully.

Input

FieldTypeWhat it doesDefault
mode string (5 options) What to fetch from the official MLB Stats data feed. Default is 'schedule' (today's games when no date is supplied). schedule
date string Date for schedule mode. Defaults to today. not set
teamId integer MLB team ID for roster mode (e.g. 147=Yankees, 119=Dodgers). not set
teamIds array Array of MLB team IDs for batch roster lookup. Takes precedence over single teamId. Items can be integers or numeric strings. Max 100 per call. []
playerId string MLB player ID for playerStats mode (e.g. 660271 = Shohei Ohtani). Numeric, accepted as string so copy-pasted IDs work. not set
playerIds array Array of MLB player IDs for batch season-stats lookup. Takes precedence over single playerId. Max 100 per call. []
gameType string (7 options) Filter schedule by game type. R=Regular, F=Wild Card, D=Division Series, L=League Championship, W=World Series, A=All-Star. not set
seasonType string (3 options) Convenience filter that maps to gameType: 'regular' = R, 'post' = F,D,L,W. Ignored if gameType is set. not set
gamePk integer Game primary key for gameDetail mode. not set
season integer Season year (e.g. 2024). Defaults to current year. not set
maxItems integer Maximum number of MLB stat records to collect per run. 10

Pricing

from $25.50 per 1,000 results

Charged forWhat it isPrice each
result Single result in the default dataset. $0.0255 to $0.034

Tiered: the lower figure is the price on a higher Apify plan. Billing and the free credit live on Apify.

API

One POST returns the dataset directly. Same shape for every scraper in the library, so swapping the slug is the only change.

POST ยท run and get results
curl -X POST "https://api.apify.com/v2/acts/parseforge~mlb-stats-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "helloWorld": 123
  }'

Examples

Input that runs as-is.

input.json
{
  "helloWorld": 123
}

Reviews

No reviews yet. Be the first.

Issues

We build and maintain this scraper, so a problem with it comes to us. Report it on the Apify listing and the thread stays attached to the scraper where the next person can find it: open an issue.

Broken and urgent, or you would rather not post in public? Write to parseforge@protonmail.com and it reaches the people who wrote it.

Related scrapers

Run MLB Stats Scraper on Apify All scrapers