# MLB Stats Scraper (`parseforge/mlb-stats-scraper`) Actor

Scrape Major League Baseball data from the official MLB Stats API - schedules, teams, rosters, player stats, and live game feeds. No API key required.

- **URL**: https://apify.com/parseforge/mlb-stats-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** News, Business, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $25.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

![ParseForge Banner](https://github.com/ParseForge/apify-assets/blob/main/banners/banner-default.jpg?raw=true)

## ⚾ MLB Stats Scraper

> 🚀 **Export official Major League Baseball data in seconds.** Pull schedules by date, all 30 MLB teams, full rosters, season player stats, and live game feeds from the official MLB feed. No sign-up, no manual scraping, no setup.

> 🕒 **Last updated:** 2026-05-15 · **📊 25+ fields** per record · **⚾ All 30 MLB teams** · **📅 Schedules + rosters + stats** · **🔴 Live game feed**

The **MLB Stats Scraper** exports official Major League Baseball data and returns up to **25+ structured fields per record**, including game primary key (gamePk), official date, gameType, season + season display, status, both teams (with score, league record, winner flag), venue, day/night designation, double-header indicator, scheduled innings, and a public deep-link to MLB.com Gameday.

The Actor covers **all 30 MLB teams, every regular and postseason game, complete 40-man and active rosters, season-by-season player stats**, and the live game feed (linescore, decisions, full game data). One run gives you the dataset you need for fan-engagement, fantasy, betting analytics, content automation, or research.

| 🎯 Target Audience | 💡 Primary Use Cases |
|---|---|
| Sports media, fantasy-baseball apps, betting analytics teams, fan-engagement platforms, indie sports devs, baseball researchers | Live scoreboards, fixture feeds, roster lookups, player season-stat dashboards, postseason brackets, content automation |

---

### 📋 What the MLB Stats Scraper does

Five lookup modes in a single run:

- 📅 **Schedule.** Games on a chosen date (defaults to today). Filter by gameType (Regular, Wild Card, Division Series, League Championship, World Series, All-Star) or by `seasonType` shortcut (`regular` / `post`).
- 🏟️ **Teams.** All 30 MLB teams with abbreviations, codes, league + division, venue, first-year-of-play, and short name.
- 📋 **Roster.** Active roster for one team (by `teamId`) or batch up to 100 teams in one run.
- 📊 **Player Stats.** Season stats for one or many players, with bio (height, weight, birth date, country, bats/throws), position, and current team.
- 🔴 **Game Detail.** Live feed for any game by `gamePk`, including game data, linescore, and pitching/winning decisions.

Each schedule record includes the canonical MLB identifiers, official date, season + season display, gamedayType, series description with game number, both teams (ID, name, score, league record, winner flag), venue, day/night, double-header type, scheduled innings, and a direct link to `mlb.com/gameday`.

> 💡 **Why it matters:** baseball moves fast, and accurate game and player data underpin every scoreboard, fantasy product, and analytics dashboard. Building your own pipeline means juggling MLB's data feed, normalising IDs across season types, and refreshing for every game day.

---

### 🎬 Full Demo

_🚧 Coming soon: a 3-minute walkthrough showing how to go from sign-up to a downloaded dataset._

---

### ⚙️ Input

<table>
<thead>
<tr><th>Input</th><th>Type</th><th>Default</th><th>Behavior</th></tr>
</thead>
<tbody>
<tr><td><code>mode</code></td><td>string</td><td><code>"schedule"</code></td><td>One of <code>schedule</code>, <code>teams</code>, <code>roster</code>, <code>playerStats</code>, <code>gameDetail</code>.</td></tr>
<tr><td><code>date</code></td><td>string</td><td><code>today</code></td><td>YYYY-MM-DD. Used in schedule mode.</td></tr>
<tr><td><code>teamId</code></td><td>integer</td><td><code>none</code></td><td>MLB team ID for roster mode (e.g. 147 = Yankees, 119 = Dodgers).</td></tr>
<tr><td><code>teamIds</code></td><td>array</td><td><code>[]</code></td><td>Batch roster lookup. Takes precedence over <code>teamId</code>.</td></tr>
<tr><td><code>playerId</code></td><td>string</td><td><code>""</code></td><td>MLB player ID for playerStats mode (e.g. 660271 = Shohei Ohtani).</td></tr>
<tr><td><code>playerIds</code></td><td>array</td><td><code>[]</code></td><td>Batch playerStats lookup. Takes precedence over <code>playerId</code>.</td></tr>
<tr><td><code>gameType</code></td><td>string</td><td><code>""</code></td><td>R/F/D/L/W/A. Filter schedule by game type.</td></tr>
<tr><td><code>seasonType</code></td><td>string</td><td><code>""</code></td><td><code>regular</code> or <code>post</code> shortcut.</td></tr>
<tr><td><code>gamePk</code></td><td>integer</td><td><code>none</code></td><td>Game primary key for gameDetail mode.</td></tr>
<tr><td><code>season</code></td><td>integer</td><td>current</td><td>Season year (e.g. 2024).</td></tr>
<tr><td><code>maxItems</code></td><td>integer</td><td><code>10</code></td><td>Free plan caps at 10, paid plan at 1,000,000.</td></tr>
</tbody>
</table>

**Example: today's schedule, regular season only.**

```json
{
    "mode": "schedule",
    "seasonType": "regular",
    "maxItems": 30
}
````

**Example: Shohei Ohtani's 2024 season stats.**

```json
{
    "mode": "playerStats",
    "playerId": "660271",
    "season": 2024
}
```

> ⚠️ **Good to Know:** `seasonType` is a convenience shortcut. If you supply `gameType` directly (e.g. `W` for World Series), it overrides `seasonType`. The Actor is smart enough to map the right combination for postseason rounds.

***

### 📊 Output

Each schedule record contains **25+ fields**. Download the dataset as CSV, Excel, JSON, or XML.

#### 🧾 Schema (schedule mode)

| Field | Type | Example |
|---|---|---|
| 🆔 `gamePk` | number | `746345` |
| 🔗 `gameGuid` | string | `"abcd-1234..."` |
| 📅 `gameDate` | ISO 8601 | `"2026-05-15T18:05:00Z"` |
| 📅 `officialDate` | string | `"2026-05-15"` |
| 🏷️ `gameType` | string | `"R"` |
| 🗓️ `season` | string | `"2026"` |
| 📺 `gamedayType` | string | `"P"` |
| 🏆 `seriesDescription` | string | `"Regular Season"` |
| 🔢 `seriesGameNumber` | number | `1` |
| 🚦 `status` | object | `{"detailedState": "Scheduled"}` |
| 📊 `awayScore` | number | null | `5` |
| 📊 `homeScore` | number | null | `3` |
| 🏠 `teams.home` | object | `{"id": 147, "name": "New York Yankees", ...}` |
| 🛫 `teams.away` | object | `{"id": 111, "name": "Boston Red Sox", ...}` |
| 🏟️ `venue` | object | `{"id": 3313, "name": "Yankee Stadium"}` |
| 🌗 `dayNight` | string | `"night"` |
| 🔁 `doubleHeader` | string | `"N"` |
| 📐 `scheduledInnings` | number | `9` |
| 🔗 `url` | string | `"https://www.mlb.com/gameday/746345"` |
| 🕒 `scrapedAt` | ISO 8601 | `"2026-05-15T00:00:00.000Z"` |

#### 📦 Sample record

<details>
<summary><strong>⚾ Regular-season game: Yankees vs Red Sox</strong></summary>

```json
{
    "gamePk": 746345,
    "gameDate": "2026-05-15T23:05:00Z",
    "officialDate": "2026-05-15",
    "gameType": "R",
    "season": "2026",
    "seriesDescription": "Regular Season",
    "seriesGameNumber": 1,
    "gamesInSeries": 3,
    "status": {"detailedState": "Final"},
    "awayScore": 5,
    "homeScore": 3,
    "teams": {
        "away": {"id": 111, "name": "Boston Red Sox", "score": 5, "isWinner": true, "leagueRecord": {"wins": 24, "losses": 18}},
        "home": {"id": 147, "name": "New York Yankees", "score": 3, "isWinner": false, "leagueRecord": {"wins": 26, "losses": 17}}
    },
    "venue": {"id": 3313, "name": "Yankee Stadium"},
    "dayNight": "night",
    "doubleHeader": "N",
    "scheduledInnings": 9,
    "url": "https://www.mlb.com/gameday/746345",
    "scrapedAt": "2026-05-15T00:00:00.000Z"
}
```

</details>

***

### ✨ Why choose this Actor

| | Capability |
|---|---|
| ⚾ | **Full league.** All 30 MLB teams across both leagues, with active rosters and season stats. |
| 📅 | **Daily schedule.** Every game on any date, filtered by season type or game type. |
| 🏆 | **Postseason support.** Wild Card, Division Series, League Championship, World Series, and All-Star coded out of the box. |
| 📊 | **Player stats.** Season hitting and pitching splits joined with player bio and current team. |
| 🔴 | **Live feed.** Linescore, decisions, and full game data for any in-progress matchup. |
| 🔁 | **Always fresh.** Each run pulls live data, so scores and lineups reflect the current state. |
| 🚫 | **No sign-up.** Works against the official MLB live feed. No login or token required. |

> 📊 Reliable MLB data is the foundation of every fantasy product, betting model, and fan-facing scoreboard.

***

### 📈 How it compares to alternatives

| Approach | Cost | Coverage | Refresh | Filters | Setup |
|---|---|---|---|---|---|
| **⭐ MLB Stats Scraper** *(this Actor)* | $5 free credit, then pay-per-use | **30 teams**, 5 modes, live + season | **Live per run** | mode, date, gameType, season | ⚡ 2 min |
| Commercial sports data vendors | $$$$/month | Full + extras | Streaming | Many | ⏳ Weeks |
| Manual stats-page scraping | Free | Inconsistent | On demand | None | 🐢 Days |
| Free baseball widgets | Free | Display-only | Live | Limited | 🕒 No raw data |

Pick this Actor when you want structured records, all 30 teams, and zero pipeline maintenance.

***

### 🚀 How to use

1. 📝 **Sign up.** [Create a free account w/ $5 credit](https://console.apify.com/sign-up?fpr=vmoqkp) (takes 2 minutes).
2. 🌐 **Open the Actor.** Go to the MLB Stats Scraper page on the Apify Store.
3. 🎯 **Set input.** Pick a mode, fill the relevant inputs (date, team ID, player ID, or gamePk), and set `maxItems`.
4. 🚀 **Run it.** Click **Start** and let the Actor collect your data.
5. 📥 **Download.** Grab your results in the **Dataset** tab as CSV, Excel, JSON, or XML.

> ⏱️ Total time from signup to downloaded dataset: **3-5 minutes.** No coding required.

***

### 💼 Business use cases

<table>
<tr>
<td width="50%" valign="top">

#### 📺 Sports Media & Publishing

- Daily MLB scoreboard rendering on news sites
- Auto-write game previews with rosters and venues
- Postseason bracket dashboards with live scores
- Push breaking news on walk-offs and no-hitters

</td>
<td width="50%" valign="top">

#### 🎲 Fantasy & Betting Analytics

- Pre-game lineup and roster checks
- Live in-play model inputs from the linescore feed
- Backtest strategies against historical schedules
- Postseason-only filters for derivatives markets

</td>
</tr>
<tr>
<td width="50%" valign="top">

#### 🏟️ Fan-Engagement Apps

- "My team" alerts and push notifications
- Game-day stadium guides with venue + day/night
- Player stat cards in fan apps and Discord bots
- Season-long leaderboard widgets

</td>
<td width="50%" valign="top">

#### 📊 Analytics & Research

- Build sabermetrics dashboards with raw splits
- Train models on schedule + outcome metadata
- Cross-reference player IDs across multiple feeds
- Time-series studies on day vs night performance

</td>
</tr>
</table>

***

### 🔌 Automating MLB Stats Scraper

Control the scraper programmatically for scheduled runs and pipeline integrations:

- 🟢 **Node.js.** Install the `apify-client` NPM package.
- 🐍 **Python.** Use the `apify-client` PyPI package.
- 📚 See the [Apify documentation](https://docs.apify.com/) for full details.

The [Apify Schedules feature](https://docs.apify.com/platform/schedules) lets you trigger this Actor on any cron interval. Refresh today's scoreboard every minute, daily roster snapshots, or weekly stats pulls are all one click.

***

### 🌟 Beyond business use cases

Baseball data powers more than commercial products. The same records support research, education, civic projects, and personal initiatives.

<table>
<tr>
<td width="50%">

#### 🎓 Research and academia

- Sabermetrics coursework with real season data
- Statistical studies on home advantage, day vs night, and travel
- Sport-history dissertations grounded in live records
- Reproducible research pulls with cited timestamps

</td>
<td width="50%">

#### 🎨 Personal and creative

- Hobbyist team tracker dashboards
- Discord bots for fan communities
- Trading-card generators with current rosters
- Side projects and fan portfolios

</td>
</tr>
<tr>
<td width="50%">

#### 🤝 Non-profit and civic

- Youth-baseball league dashboards
- Sport-journalism for local newsrooms
- Inclusion analyses across rosters and birth countries
- Open-data hackathons on America's pastime

</td>
<td width="50%">

#### 🧪 Experimentation

- Train win-probability ML models with live linescores
- Prototype agent pipelines that resolve player IDs
- Validate fan-product hypotheses with real fixture data
- Test live-stream UX concepts with real game feeds

</td>
</tr>
</table>

***

### 🤖 Ask an AI assistant about this scraper

Open a ready-to-send prompt about this ParseForge actor in the AI of your choice:

- 💬 [**ChatGPT**](https://chat.openai.com/?q=How%20do%20I%20use%20the%20MLB%20Stats%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🧠 [**Claude**](https://claude.ai/new?q=How%20do%20I%20use%20the%20MLB%20Stats%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🔍 [**Perplexity**](https://perplexity.ai/search?q=How%20do%20I%20use%20the%20MLB%20Stats%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🅒 [**Copilot**](https://copilot.microsoft.com/?q=How%20do%20I%20use%20the%20MLB%20Stats%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)

***

### ❓ Frequently Asked Questions

#### 🧩 How does it work?

Pick a mode (`schedule`, `teams`, `roster`, `playerStats`, or `gameDetail`), supply the relevant inputs, and click Start. The Actor pulls fresh records from the official MLB live data feed and emits a clean structured row per game, team, player, or live feed entry.

#### ⚾ Which teams are supported?

All 30 Major League Baseball teams across both the American League and National League.

#### 📅 Can I get postseason games only?

Yes. Set `seasonType` to `post` (or use `gameType` like `W` for World Series specifically) and the Actor restricts the schedule to playoff games.

#### 📊 How do I look up player season stats?

Set `mode` to `playerStats` and supply `playerId` (e.g. `660271` for Shohei Ohtani). Optionally set `season` to a year (defaults to current). Use `playerIds` for batch lookups (up to 100 per call).

#### 🔴 Can I pull a live game feed?

Yes. Set `mode` to `gameDetail` and supply `gamePk` for the game you want. The Actor returns live game data, current linescore, and pitching/winning decisions if the game is final.

#### 🏟️ Do I get venue and day/night info?

Yes. The schedule mode returns the full venue object plus `dayNight` and `doubleHeader` flags so you can build accurate game-day dashboards.

#### ⏰ Can I schedule regular runs?

Yes. Use Apify Schedules to run this Actor every minute, hourly, or daily. The dataset always reflects the current state of the live feed.

#### ⚖️ Is this data legal to use?

Only publicly available scoreboard data is collected. Review MLB's terms of use for your specific use case, particularly if you redistribute or commercialise the content.

#### 💳 Do I need a paid Apify plan to use this Actor?

No. The free Apify plan is enough for testing and small runs (10 records per run). A paid plan lifts the limit and unlocks scheduling and higher concurrency.

#### 🔁 What happens if a run fails or gets interrupted?

Apify automatically retries transient errors. If a run still fails, you can inspect the log in the Runs tab, fix the input, and re-run. Partial datasets from failed runs are preserved so you never lose progress.

#### 🆘 What if I need help?

Our support team is here to help. Contact us through the Apify platform or use the Tally form linked below.

***

### 🔌 Integrate with any app

MLB Stats Scraper connects to any cloud service via [Apify integrations](https://apify.com/integrations):

- [**Make**](https://docs.apify.com/platform/integrations/make) - Automate multi-step workflows
- [**Zapier**](https://docs.apify.com/platform/integrations/zapier) - Connect with 5,000+ apps
- [**Slack**](https://docs.apify.com/platform/integrations/slack) - Get score updates in your channels
- [**n8n**](https://docs.apify.com/platform/integrations/n8n) - Self-hosted workflow automation
- [**Pipedream**](https://docs.apify.com/platform/integrations/pipedream) - Event-driven serverless workflows
- [**Airbyte**](https://docs.apify.com/platform/integrations/airbyte) - Pipe baseball data into your warehouse
- [**GitHub**](https://docs.apify.com/platform/integrations/github) - Trigger runs from commits
- [**Google Drive**](https://docs.apify.com/platform/integrations/drive) - Export datasets straight to Sheets

You can also use webhooks to trigger downstream actions when a run finishes. Push fresh schedules into your product backend, or alert your fans in Slack when a walk-off happens.

***

### 🔗 Recommended Actors

- [**🏒 NHL Stats Scraper**](https://apify.com/parseforge/nhl-stats-scraper) - 32-team standings, schedules, player landing
- [**🏆 Sofascore Live Events Scraper**](https://apify.com/parseforge/sofascore-live-scraper) - 13-sport live + scheduled events feed
- [**🥅 TheSportsDB Scraper**](https://apify.com/parseforge/thesportsdb-scraper) - Crowd-sourced sports database across leagues
- [**🛡️ CWE MITRE Scraper**](https://apify.com/parseforge/cwe-mitre-scraper) - Software weakness reference catalogue
- [**📊 OurAirports Scraper**](https://apify.com/parseforge/ourairports-scraper) - Global airport reference dataset

> 💡 **Pro Tip:** browse the complete [ParseForge collection](https://apify.com/parseforge) for more reference-data scrapers.

***

**🆘 Need Help?** [**Open our contact form**](https://tally.so/r/BzdKgA) to request a new scraper, propose a custom data project, or report an issue.

***

> **⚠️ Disclaimer:** this Actor is an independent tool and is not affiliated with, endorsed by, or sponsored by Major League Baseball or any of its clubs. All trademarks mentioned are the property of their respective owners. Only publicly available scoreboard data is collected.

# Actor input Schema

## `mode` (type: `string`):

What to fetch from the official MLB Stats data feed. Default is 'schedule' (today's games when no date is supplied).

## `date` (type: `string`):

Date for schedule mode. Defaults to today.

## `teamId` (type: `integer`):

MLB team ID for roster mode (e.g. 147=Yankees, 119=Dodgers).

## `teamIds` (type: `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` (type: `string`):

MLB player ID for playerStats mode (e.g. 660271 = Shohei Ohtani). Numeric, accepted as string so copy-pasted IDs work.

## `playerIds` (type: `array`):

Array of MLB player IDs for batch season-stats lookup. Takes precedence over single playerId. Max 100 per call.

## `gameType` (type: `string`):

Filter schedule by game type. R=Regular, F=Wild Card, D=Division Series, L=League Championship, W=World Series, A=All-Star.

## `seasonType` (type: `string`):

Convenience filter that maps to gameType: 'regular' = R, 'post' = F,D,L,W. Ignored if gameType is set.

## `gamePk` (type: `integer`):

Game primary key for gameDetail mode.

## `season` (type: `integer`):

Season year (e.g. 2024). Defaults to current year.

## `maxItems` (type: `integer`):

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000

## Actor input object example

```json
{
  "mode": "schedule",
  "teamIds": [],
  "playerIds": [],
  "gameType": "",
  "seasonType": "",
  "maxItems": 10
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of scraped data

## `fullData` (type: `string`):

Complete dataset

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "schedule",
    "date": "",
    "playerId": "",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/mlb-stats-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "schedule",
    "date": "",
    "playerId": "",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/mlb-stats-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "schedule",
  "date": "",
  "playerId": "",
  "maxItems": 10
}' |
apify call parseforge/mlb-stats-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=parseforge/mlb-stats-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "MLB Stats Scraper",
        "description": "Scrape Major League Baseball data from the official MLB Stats API - schedules, teams, rosters, player stats, and live game feeds. No API key required.",
        "version": "0.0",
        "x-build-id": "5SlFJ8haUuZrltHt6"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~mlb-stats-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-mlb-stats-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/parseforge~mlb-stats-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-mlb-stats-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/parseforge~mlb-stats-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-mlb-stats-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "schedule",
                            "teams",
                            "roster",
                            "playerStats",
                            "gameDetail"
                        ],
                        "type": "string",
                        "description": "What to fetch from the official MLB Stats data feed. Default is 'schedule' (today's games when no date is supplied).",
                        "default": "schedule"
                    },
                    "date": {
                        "title": "Date (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Date for schedule mode. Defaults to today."
                    },
                    "teamId": {
                        "title": "Team ID",
                        "minimum": 1,
                        "type": "integer",
                        "description": "MLB team ID for roster mode (e.g. 147=Yankees, 119=Dodgers)."
                    },
                    "teamIds": {
                        "title": "Team IDs (batch lookup, roster mode)",
                        "type": "array",
                        "description": "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.",
                        "default": []
                    },
                    "playerId": {
                        "title": "Player ID",
                        "type": "string",
                        "description": "MLB player ID for playerStats mode (e.g. 660271 = Shohei Ohtani). Numeric, accepted as string so copy-pasted IDs work."
                    },
                    "playerIds": {
                        "title": "Player IDs (batch lookup, playerStats mode)",
                        "type": "array",
                        "description": "Array of MLB player IDs for batch season-stats lookup. Takes precedence over single playerId. Max 100 per call.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "gameType": {
                        "title": "Game Type (schedule mode)",
                        "enum": [
                            "",
                            "R",
                            "F",
                            "D",
                            "L",
                            "W",
                            "A"
                        ],
                        "type": "string",
                        "description": "Filter schedule by game type. R=Regular, F=Wild Card, D=Division Series, L=League Championship, W=World Series, A=All-Star.",
                        "default": ""
                    },
                    "seasonType": {
                        "title": "Season Type (schedule mode shortcut)",
                        "enum": [
                            "",
                            "regular",
                            "post"
                        ],
                        "type": "string",
                        "description": "Convenience filter that maps to gameType: 'regular' = R, 'post' = F,D,L,W. Ignored if gameType is set.",
                        "default": ""
                    },
                    "gamePk": {
                        "title": "Game PK",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Game primary key for gameDetail mode."
                    },
                    "season": {
                        "title": "Season",
                        "minimum": 1900,
                        "maximum": 2100,
                        "type": "integer",
                        "description": "Season year (e.g. 2024). Defaults to current year."
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
