# MLB Stats Scraper - Scores, Standings, Rosters & Leaders (`sian.agency/mlb-stats-scraper`) Actor

Export MLB data: game scores and schedules, division standings, team rosters, season leaders and full box scores. Six datasets, one actor, no API key needed.

- **URL**: https://apify.com/sian.agency/mlb-stats-scraper.md
- **Developed by:** [SIÁN OÜ](https://apify.com/sian.agency) (community)
- **Categories:** News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.41 / 1,000 schedule & scores

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## ⚾ MLB Stats Scraper — Scores, Standings, Rosters & Leaders

[![Actor](https://img.shields.io/badge/Apify-Actor-brightgreen)](https://apify.com/sian.agency/mlb-stats-scraper)
[![Pricing](https://img.shields.io/badge/Pay%20per%20result-%240.004%20per%20record-blue)](https://apify.com/sian.agency/mlb-stats-scraper)
[![Datasets](https://img.shields.io/badge/6%20datasets-in%20one%20actor-orange)](https://apify.com/sian.agency/mlb-stats-scraper)
[![Support](https://img.shields.io/badge/Support-Issues%20%26%20Reviews-purple)](https://apify.com/sian.agency/mlb-stats-scraper/issues)

### 🔎 What is the MLB Stats Scraper — and when should you use it?

The **MLB Stats Scraper** turns MLB scores, standings, teams, rosters, season leaders and box scores into clean, structured rows you can filter, export and feed straight into a spreadsheet, database or AI agent. No account, no portal API key, no browser automation to maintain.

**Use it when you need:** any of six MLB datasets for a season or date range. Schedule rows carry both clubs, both scores, status, venue and series position. Standings carry record, win percentage, games back, streak, division and league rank, and runs scored and allowed. Rosters and box scores carry player id, name, jersey number and position, with per-game batting lines on the box score. Season leaders come ranked with the value and the player's club, and player ids are identical across all six so the datasets join without name matching.

**Use something else when:** you want a different sport, betting markets, or live pitch-level tracking. Use [Sports Data Scraper](https://apify.com/sian.agency/sports-data-scraper?fpr=sian) for multi-sport fixtures and results beyond baseball. Use [Basketball API Scraper](https://apify.com/sian.agency/basketball-api-scraper?fpr=sian) for basketball games, teams and player statistics. Use [Football API Scraper](https://apify.com/sian.agency/football-api-scraper?fpr=sian) for football fixtures, results and league tables. Use [Sports Betting Odds Scraper](https://apify.com/sian.agency/sports-betting-odds-scraper?fpr=sian) for bookmaker odds across sports and markets. This actor covers MLB's public statistics service only. Live pitch-by-pitch feeds and Statcast tracking live on different services and are not available here at any price.

### 🤖 Use with AI agents

Already connected to the [Apify MCP server](https://mcp.apify.com)? Just ask for this Actor by name: sian.agency/mlb-stats-scraper

**Your agent can pay for its own runs.** This Actor is eligible for [agentic payments](https://docs.apify.com/platform/actors/publishing/monetize), so an agent can discover it, run it and settle the bill over [x402](https://www.x402.org/) (USDC on Base) or [Skyfire](https://www.skyfire.xyz/) — without an Apify account or API token of its own. Billing is the same either way: per successful row, never for errors.

Otherwise copy this prompt into Claude, ChatGPT, Cursor or any MCP-enabled assistant:

```text
I want MLB scores, standings, rosters, leaders and box scores using the Apify Actor `sian.agency/mlb-stats-scraper`.

Use it when I need: any of six MLB datasets for a season or date range. Schedule rows carry both clubs, both scores, status, venue and series position. Standings carry record, win percentage, games back, streak, division and league rank, and runs scored and allowed. Rosters and box scores carry player id, name, jersey number and position, with per-game batting lines on the box score. Season leaders come ranked with the value and the player's club, and player ids are identical across all six so the datasets join without name matching.

Don't use it when: you want a different sport, betting markets, or live pitch-level tracking — use sports-data-scraper or basketball-api-scraper or football-api-scraper or sports-betting-odds-scraper instead.

How to call it: set `operation` to one of
  schedule  -> needs `startDate` + `endDate` (YYYY-MM-DD), ~90-100 games for a week in season
  standings -> needs `season`, returns 30 club standings
  teams     -> needs `season`, returns all 30 clubs with league, division and venue
  roster    -> needs `teamId` + `season`, returns ~26 players
  leaders   -> needs `leaderCategory` + `season`, returns up to ~315 ranked players
  boxscore  -> needs `gamePk`, returns ~52 player lines for one game
Run `teams` first for a club id and `schedule` first for a game id; both come back in
the output. `season` is a four-digit year and historical seasons work on every route.
Win percentage, games back, division rank, jersey number and the leader value are
STRINGS at the source ('.599', '-', '1', '39', '40') and are passed through unchanged..

Start with this input:
{
  "operation": "schedule",
  "season": "2026",
  "startDate": "2026-08-01",
  "endDate": "2026-08-07",
  "maxResults": 200
}

Ask me which dataset I want, and for which season or date range, then run the Actor and summarise the results as a table.
```

**Things you can ask your agent for:**

- *Pull this week's games and tell me which were decided by one run.*
- *Get the current standings and show me every division race inside three games.*
- *Pull the home run leaders and cross-reference them against their club's run differential.*
- *Get the box score for this game and list every player who reached base more than once.*

Machine-readable API, MCP config and OpenAPI definition for this Actor are published at [apify.com/sian.agency/mlb-stats-scraper.md](https://apify.com/sian.agency/mlb-stats-scraper.md).

### Overview

Six MLB datasets from one actor: game scores and schedules, division standings, every club,
team rosters, season leaders, and per-player box score lines.

No API key, no account and no quota — the source is Major League Baseball's own public
statistics service. Player IDs are the same across every dataset, so a roster row, a leader row
and a box score line all join on `playerId` without any name matching.

### Features

- **Six typed datasets**, each with its own charge event, so pulling standings is not billed at box-score rates.
- **Current and historical seasons** on the same routes — change the season and pull 2019 as easily as this year.
- **League figures passed through unchanged.** Win percentage arrives as `.599` and the division leader's games back as `-`, exactly as MLB publishes them, so your numbers match the official ones.
- **Honest nulls.** A pitcher who never batted has empty batting stats, not zeros — the actor will not invent plate appearances.
- **Stable joins.** `playerId` and `teamId` are consistent across all six datasets.
- **An HTML run report** with the records, what you paid, and a fix for anything that failed.

### Quick start

1. Open the Actor and press **Start** — the default pulls a week of games and scores.
2. Change `operation` to pick a different dataset.
3. Read the results in the **Output** tab, or export to JSON, CSV or Excel.

```json
{
  "operation": "schedule",
  "season": "2026",
  "startDate": "2026-08-01",
  "endDate": "2026-08-07"
}
```

### Getting started

Pick the dataset with `operation`, then fill in the field that dataset needs:

| Operation | Needs | Returns |
|---|---|---|
| `schedule` | `startDate`, `endDate` | ~90–100 games for a week in season |
| `standings` | `season` | 30 club standings |
| `teams` | `season` | all 30 clubs |
| `roster` | `teamId`, `season` | ~26 players |
| `leaders` | `leaderCategory`, `season` | up to ~315 ranked players |
| `boxscore` | `gamePk` | ~52 player lines for one game |

Run `teams` first if you need a club's ID, and `schedule` first if you need a game ID — both come
back in the output.

### Input configuration

| Field | Type | Default | What it does |
|---|---|---|---|
| `operation` | select | `schedule` | Which of the six datasets to pull |
| `season` | string | `2026` | Four-digit season year |
| `startDate` | string | `2026-08-01` | Schedule window start, `YYYY-MM-DD` |
| `endDate` | string | `2026-08-07` | Schedule window end, `YYYY-MM-DD` |
| `teamId` | integer | `147` | Club for the roster dataset |
| `gamePk` | integer | `822781` | Game for the box score dataset |
| `leaderCategory` | select | `homeRuns` | Statistic to rank players by |
| `maxResults` | integer | `200` | Cap on records returned, and so on what a run charges |

### Output

Every row carries `rowType`, so the six datasets sit together unambiguously.

| Field | Type | Appears on | Example |
|---|---|---|---|
| `rowType` | string | all | `game` |
| `season` | string | all | `2026` |
| `gamePk` | integer | game, boxscore | `822781` |
| `gameDate` | string | game | `2026-08-01T19:07:00Z` |
| `gameStatus` | string | game | `Final` |
| `homeTeam` / `awayTeam` | string | game | `Toronto Blue Jays` |
| `homeScore` / `awayScore` | integer | game | `5` / `1` |
| `venueName` | string | game, team | `Rogers Centre` |
| `teamId` / `teamName` | integer / string | most | `139` / `Rays` |
| `wins` / `losses` | integer | standing | `82` / `55` |
| `winningPercentage` | **string** | standing | `.599` |
| `gamesBack` | **string** | standing | `-` |
| `streakCode` | string | standing | `L1` |
| `divisionRank` / `leagueRank` | **string** | standing | `1` |
| `runsScored` / `runsAllowed` | integer | standing | `618` |
| `playerId` / `playerName` | integer / string | roster, leader, boxscore | `656941` / `Kyle Schwarber` |
| `jerseyNumber` | **string** | roster, boxscore | `39` |
| `positionAbbreviation` / `positionName` | string | roster, boxscore | `C` / `Catcher` |
| `statCategory` / `statValue` / `rank` | string / **string** / integer | leader | `homeRuns` / `40` / `1` |
| `battingHits` / `battingAtBats` / `battingRuns` / `battingRbi` | integer, nullable | boxscore | `2` |
| `seasonAvg` | string | boxscore | `.284` |
| `sourceUrl` / `scrapedAt` | string | all | — |

The fields marked **string** are text at the source. We pass them through rather than reformatting,
so they match the official figure exactly — convert on your side if you need arithmetic.

### Use cases

- **Daily scores feed** — pull a date range each morning for a site, newsletter or bot.
- **Standings tracker** — record standings on a schedule so you can watch a division race develop over weeks rather than reading a single day's table.
- **Fantasy and betting models** — feed leaders and box score lines into a model, joining on stable player IDs.
- **Roster and transaction monitoring** — watch a club's roster for changes in players, positions and status.
- **Sports journalism and research** — pull historical seasons on the same routes with one consistent output shape.

### Integration examples

**JavaScript**

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

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });

const run = await client.actor('sian.agency/mlb-stats-scraper').call({
    operation: 'standings',
    season: '2026',
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
const leaders = items.filter((r) => r.divisionRank === '1');
console.log(leaders.map((t) => `${t.teamName}: ${t.wins}-${t.losses}`).join('\n'));
```

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("sian.agency/mlb-stats-scraper").call(run_input={
    "operation": "schedule",
    "startDate": "2026-08-01",
    "endDate": "2026-08-07",
})

games = list(client.dataset(run["defaultDatasetId"]).iterate_items())
finals = [g for g in games if g.get("gameStatus") == "Final"]
print(f"{len(finals)} completed games")
```

**cURL**

```bash
curl -X POST "https://api.apify.com/v2/acts/sian.agency~mlb-stats-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"operation":"leaders","season":"2026","leaderCategory":"homeRuns"}'
```

**Automation workflows** — the Actor runs as a step in n8n, Make or Zapier through Apify's
connectors. A common pattern is a nightly schedule that pulls the day's games and appends them to
a sheet or database.

### FAQ

**Do I need an API key or account?**
No. The source is Major League Baseball's own public statistics service — no key, no login, no quota.

**Which seasons can I pull?**
Current and historical. Teams, standings, rosters and leaders all take a season year; the schedule
takes any date range.

**Why is win percentage text rather than a number?**
Because that is how the league publishes it — `.599`, and `-` for the division leader's games back.
We pass those through unchanged so they match the official figure. Convert on your side if you need
arithmetic.

**What happens if there are no games in my date range?**
You get an empty result and a note in the log, not an error. Out of season there genuinely are no
games, and that is a real answer.

**Why are some batting stats empty rather than zero?**
Because that player did not bat in that game — usually a pitcher. Writing zeros would invent plate
appearances that never happened.

**How many records does one run return?**
30 clubs or standings, about 26 players on a roster, roughly 90–100 games for a week of schedule,
up to about 315 season leaders, and about 52 player lines per box score.

**Is this affiliated with MLB?**
No. It reads MLB's public statistics service and is not affiliated with, endorsed by or sponsored
by Major League Baseball.

### Troubleshooting

| What you see | What it means | What to do |
|---|---|---|
| No records, run succeeded | Nothing exists for that request — often out of season | Use dates inside the regular season, or check the season year |
| `Season "..." is not a four-digit year` | Rejected before anything was charged | Use `2026`, not `26` or `2026-01` |
| `Start date is after end date` | The window is inverted | Swap the two dates |
| `Team ID "..." is not a positive number` | Unknown club | Run the `teams` operation to list every club's ID |
| `That record does not exist` | The team or game ID isn't real | Take IDs from `teams` or `schedule` output |
| Fewer rows than expected on a free plan | Free Apify accounts are capped at 25 rows per run | Add credits or a payment method to lift the cap |

### Legal

This Actor reads only data that Major League Baseball publishes openly through its public
statistics service. It does not log in, does not bypass authentication, and does not collect
personal data.

MLB and Major League Baseball are trademarks of MLB Advanced Media, L.P. This tool is not
affiliated with, endorsed by or sponsored by Major League Baseball. You are responsible for
ensuring your use of the data complies with applicable law and the source's terms.

### Support

- 🐛 **Issues:** https://apify.com/sian.agency/mlb-stats-scraper/issues
- ⭐ **Reviews:** https://apify.com/sian.agency/mlb-stats-scraper/reviews
- 🌐 **More actors:** https://apify.com/sian.agency?fpr=sian
- 🚀 **New to Apify?** https://apify.com/pricing?fpr=sian

Related sports actors: [Sports Data Scraper](https://apify.com/sian.agency/sports-data-scraper),
[Basketball API Scraper](https://apify.com/sian.agency/basketball-api-scraper),
[Football API Scraper](https://apify.com/sian.agency/football-api-scraper),
[Tennis Point by Point Scraper](https://apify.com/sian.agency/tennis-point-by-point-scraper),
[Sports Betting Odds Scraper](https://apify.com/sian.agency/sports-betting-odds-scraper).

### Keywords for LLM Discovery

mlb api, mlb stats api, baseball data api, mlb scraper, baseball statistics scraper, mlb scores
api, baseball scores data, mlb standings api, division standings data, mlb schedule api, baseball
schedule scraper, mlb box score api, box score data, mlb roster api, team roster scraper, mlb
leaders api, home run leaders data, batting average leaders, era leaders, baseball player stats,
mlb player data, statsapi, mlb game data, baseball analytics data, fantasy baseball data, mlb
historical stats, season leaders api, run differential data, winning percentage data, baseball
venue data, mlb team data, sports data extraction, baseball research dataset

# Actor input Schema

## `operation` (type: `string`):

Six datasets: schedule and scores, standings, teams, rosters, season leaders and box scores.

## `season` (type: `string`):

Four-digit season year. Applies to teams, standings, rosters and leaders. Historical seasons work on the same routes.

## `startDate` (type: `string`):

First date of the schedule window, YYYY-MM-DD. Used by the Schedule & Scores operation.

## `endDate` (type: `string`):

Last date of the schedule window, YYYY-MM-DD. A week returns roughly 90 to 100 games in season.

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

Which club to pull a roster for. Run the Teams operation first to see every club's ID; 147 is the New York Yankees.

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

Which game to pull a box score for. Game IDs come from the Schedule & Scores operation.

## `leaderCategory` (type: `string`):

Which statistic to rank players by. Used by the Season Leaders operation.

## `maxResults` (type: `integer`):

Upper bound on records returned, and therefore on what a run can charge.

## Actor input object example

```json
{
  "operation": "schedule",
  "season": "2026",
  "startDate": "2026-08-01",
  "endDate": "2026-08-07",
  "teamId": 147,
  "gamePk": 822781,
  "leaderCategory": "homeRuns",
  "maxResults": 200
}
```

# Actor output Schema

## `mlbStatsApiRecord` (type: `string`):

Every record this run returned.

## `scrapingSummary` (type: `string`):

HTML summary showing successful and failed results with key metrics

# 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 = {
    "operation": "schedule",
    "season": "2026",
    "startDate": "2026-08-01",
    "endDate": "2026-08-07",
    "teamId": 147,
    "gamePk": 822781,
    "leaderCategory": "homeRuns",
    "maxResults": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("sian.agency/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 = {
    "operation": "schedule",
    "season": "2026",
    "startDate": "2026-08-01",
    "endDate": "2026-08-07",
    "teamId": 147,
    "gamePk": 822781,
    "leaderCategory": "homeRuns",
    "maxResults": 200,
}

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

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

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

```

## CLI example

```bash
echo '{
  "operation": "schedule",
  "season": "2026",
  "startDate": "2026-08-01",
  "endDate": "2026-08-07",
  "teamId": 147,
  "gamePk": 822781,
  "leaderCategory": "homeRuns",
  "maxResults": 200
}' |
apify call sian.agency/mlb-stats-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,sian.agency/mlb-stats-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/TYBZXOzeyWpAKHBql/builds/PrbSeofLdQPs3foKh/openapi.json
