# MLB Stats Scraper — Baseball Teams, Players, Scores & Standings (`haketa/mlb-stats-scraper`) Actor

Scrape MLB (Major League Baseball) data: league standings, all 30 teams, live game scores, and player rosters with season hitting & pitching stats. Pick a data type, set a season or date range, and export clean baseball stats as JSON, CSV or Excel for analytics, betting, fantasy and apps.

- **URL**: https://apify.com/haketa/mlb-stats-scraper.md
- **Developed by:** [Haketa](https://apify.com/haketa) (community)
- **Categories:** News, Developer tools
- **Stats:** 2 total users, 1 monthly users, 66.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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/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 — Baseball Teams, Players, Scores & Standings

Get **Major League Baseball** data as clean, structured records. Choose what you need — **league standings**, **team info**, **game scores** or **player rosters with season stats** — set a season or a date, and export ready‑to‑use JSON, CSV or Excel.

Built for **sports data teams, bettors and modelers, fantasy‑baseball players, journalists, app developers and researchers** who want reliable MLB stats without hand‑copying tables or wiring up a data feed.

***

### ✨ What you can collect

This scraper covers four data types — pick one per run with the **Data type** setting:

- **🏆 Standings** — full division and league tables: wins, losses, win %, games back, division/league/sport rank, streak, runs scored/allowed, run differential, home/away/last‑10 records, clinched and magic/elimination numbers.
- **⚾ Teams** — all 30 MLB clubs with name, abbreviation, location, league, division, venue, franchise and first year of play.
- **📊 Scores** — games and final scores for any date or date range: home/away teams, scores, winner, game status, series info, venue and start time.
- **🧢 Players** — team rosters with each player's bio (position, bats/throws, height, weight, birth date, birthplace, MLB debut) plus **season hitting and pitching stats**.

***

### 💡 Why use it

- **Four datasets, one actor** — standings, teams, scores and players from a single tool with a consistent, typed output.
- **Real season stats** — player records come with hitting (AVG, HR, RBI, OPS, OBP, SLG, SB …) and pitching (ERA, W‑L, IP, SO, WHIP, saves …) for the season you choose.
- **Any season, any date** — pull the current season live, back‑fill historical seasons, or grab scores for a specific day or week.
- **Clean, structured data** — numbers as numbers, records as `W-L` strings, nested stat objects — ready for spreadsheets, databases, notebooks and BI tools.
- **Fast and lightweight** — efficient requests, parallel roster fetching, and de‑duplicated results out of the box.
- **Export anywhere** — JSON, CSV, Excel, HTML or via the Apify API and integrations (Google Sheets, Zapier, Make, webhooks, S3 …).

***

### 🚀 Quick start

1. Choose a **Data type**: `standings`, `teams`, `scores` or `players`.
2. Set the **Season** (year) — or a **Date** / date range for scores.
3. Click **Start**. Each entity comes back as one clean record.

***

### 📥 Input

| Field | Type | Applies to | Description |
|---|---|---|---|
| **Data type** (`dataType`) | select | all | `standings`, `teams`, `scores` or `players`. |
| **Season** (`season`) | integer | standings, teams, players | Season year (e.g. 2026). Defaults to the current year. |
| **Date** (`date`) | string | scores | Single day `YYYY-MM-DD`. Empty = today. |
| **Start date** (`startDate`) | string | scores | First day of a date range `YYYY-MM-DD`. |
| **End date** (`endDate`) | string | scores | Last day of a date range `YYYY-MM-DD`. |
| **Team IDs** (`teamIds`) | array | players | Limit to specific team IDs. Empty = all 30 teams. |
| **Include player season stats** (`includePlayerStats`) | boolean | players | Add hitting & pitching stats to each player. |
| **Roster type** (`rosterType`) | select | players | `active`, `40Man`, `fullSeason` or `fullRoster`. |
| **Maximum records** (`maxItems`) | integer | all | Cap the number of records. |
| **Concurrency** (`maxConcurrency`) | integer | players | Parallel requests. |
| **Proxy configuration** (`proxyConfiguration`) | object | all | Apify Proxy is recommended. |

#### Example 1 — current standings

```json
{
  "dataType": "standings",
  "season": 2026
}
```

#### Example 2 — all teams

```json
{
  "dataType": "teams",
  "season": 2026
}
```

#### Example 3 — scores for one day

```json
{
  "dataType": "scores",
  "date": "2026-08-25"
}
```

#### Example 4 — scores for a week

```json
{
  "dataType": "scores",
  "startDate": "2026-08-18",
  "endDate": "2026-08-24"
}
```

#### Example 5 — players with stats (all teams)

```json
{
  "dataType": "players",
  "season": 2026,
  "includePlayerStats": true
}
```

#### Example 6 — players for specific teams

```json
{
  "dataType": "players",
  "season": 2026,
  "teamIds": ["147", "119"],
  "includePlayerStats": true
}
```

***

### 📤 Output

Every record is one dataset item and carries a `recordType` field (`standing`, `team`, `game` or `player`) plus a `scrapedAt` timestamp.

#### Standing

```json
{
  "recordType": "standing",
  "season": 2026,
  "league": "American League",
  "division": "American League East",
  "team": "Blue Jays",
  "teamId": 141,
  "wins": 94,
  "losses": 68,
  "winningPercentage": ".580",
  "gamesPlayed": 162,
  "gamesBack": "-",
  "divisionRank": 1,
  "leagueRank": 1,
  "streak": "W4",
  "runsScored": 798,
  "runsAllowed": 721,
  "runDifferential": 77,
  "homeRecord": "54-27",
  "awayRecord": "40-41",
  "lastTenRecord": "5-5",
  "clinched": true,
  "magicNumber": "-",
  "eliminationNumber": "-"
}
```

#### Team

```json
{
  "recordType": "team",
  "teamId": 147,
  "name": "New York Yankees",
  "abbreviation": "NYY",
  "teamName": "Yankees",
  "locationName": "Bronx",
  "league": "American League",
  "division": "American League East",
  "venue": "Yankee Stadium",
  "firstYearOfPlay": "1903",
  "franchiseName": "New York",
  "clubName": "Yankees",
  "active": true,
  "season": 2026
}
```

#### Game (score)

```json
{
  "recordType": "game",
  "gamePk": 776604,
  "officialDate": "2026-08-25",
  "gameType": "R",
  "status": "Final",
  "awayTeam": "Boston Red Sox",
  "awayScore": 4,
  "homeTeam": "Baltimore Orioles",
  "homeScore": 3,
  "winner": "Boston Red Sox",
  "venue": "Oriole Park at Camden Yards",
  "seriesGameNumber": 1,
  "dayNight": "night"
}
```

#### Player

```json
{
  "recordType": "player",
  "playerId": 592450,
  "fullName": "Aaron Judge",
  "team": "New York Yankees",
  "teamId": 147,
  "jerseyNumber": "99",
  "position": "Right Field",
  "positionAbbrev": "RF",
  "batSide": "Right",
  "pitchHand": "Right",
  "birthDate": "1992-04-26",
  "age": 34,
  "height": "6' 7\"",
  "weight": 282,
  "birthCity": "Linden",
  "birthCountry": "USA",
  "mlbDebutDate": "2016-08-13",
  "season": 2026,
  "hittingStats": {
    "gamesPlayed": 130,
    "avg": ".322",
    "homeRuns": 47,
    "rbi": 110,
    "hits": 156,
    "runs": 118,
    "obp": ".447",
    "slg": ".690",
    "ops": "1.137",
    "stolenBases": 9,
    "strikeOuts": 158,
    "walks": 121
  },
  "pitchingStats": null
}
```

#### Field reference

**Standing**

| Field | Description |
|---|---|
| `wins`, `losses`, `winningPercentage` | Overall record and win percentage. |
| `gamesPlayed`, `gamesBack` | Games played and games behind the division leader. |
| `divisionRank`, `leagueRank`, `sportRank` | Rank within division, league and all of MLB. |
| `streak` | Current streak (e.g. `W4`, `L2`). |
| `runsScored`, `runsAllowed`, `runDifferential` | Offense, defense and run differential. |
| `homeRecord`, `awayRecord`, `lastTenRecord` | Split records as `W-L`. |
| `clinched`, `divisionChamp`, `magicNumber`, `eliminationNumber` | Postseason race indicators. |

**Team**

| Field | Description |
|---|---|
| `name`, `abbreviation`, `teamName`, `locationName` | Naming fields. |
| `league`, `division` | League and division. |
| `venue` | Home ballpark. |
| `firstYearOfPlay`, `franchiseName`, `clubName` | Franchise details. |

**Game**

| Field | Description |
|---|---|
| `gamePk` | Unique game ID. |
| `officialDate`, `gameDate` | Game date and start time. |
| `gameType`, `status` | Type (R = regular, etc.) and status (Final, In Progress …). |
| `homeTeam`, `awayTeam`, `homeScore`, `awayScore` | Teams and scores. |
| `winner` | Winning team (when final). |
| `venue`, `seriesGameNumber`, `dayNight` | Venue, series game number and day/night. |

**Player**

| Field | Description |
|---|---|
| `fullName`, `firstName`, `lastName` | Player name. |
| `team`, `jerseyNumber`, `position` | Current team, number and position. |
| `batSide`, `pitchHand` | Bats and throws. |
| `birthDate`, `age`, `height`, `weight`, `birthCity`, `birthCountry` | Bio. |
| `mlbDebutDate`, `draftYear` | Career milestones. |
| `hittingStats` | AVG, HR, RBI, hits, runs, OBP, SLG, OPS, SB, SO, walks … |
| `pitchingStats` | ERA, W‑L, IP, SO, WHIP, saves, games started … |

***

### 💡 Use cases

- **Sports betting & modeling** — build datasets of standings, run differentials and player form to feed prediction and pricing models.
- **Fantasy baseball** — pull player stats and rosters to rank, draft and set lineups.
- **Media & journalism** — power live standings, box scores and player pages with fresh data.
- **App & product development** — back a baseball app, dashboard or Discord bot with clean MLB data.
- **Research & analytics** — study team performance, park effects, demographics and historical trends across seasons.
- **Content & newsletters** — automate weekly recaps of scores, standings and hot players.

***

### 🧭 Handy team IDs

Use these with **Team IDs** for the `players` data type (run `teams` for the full list):

- **147** New York Yankees · **111** Boston Red Sox · **141** Toronto Blue Jays · **110** Baltimore Orioles · **139** Tampa Bay Rays
- **119** Los Angeles Dodgers · **137** San Francisco Giants · **135** San Diego Padres · **109** Arizona Diamondbacks · **115** Colorado Rockies
- **112** Chicago Cubs · **158** Milwaukee Brewers · **113** Cincinnati Reds · **134** Pittsburgh Pirates · **138** St. Louis Cardinals
- **143** Philadelphia Phillies · **121** New York Mets · **144** Atlanta Braves · **146** Miami Marlins · **120** Washington Nationals
- **114** Cleveland Guardians · **116** Detroit Tigers · **142** Minnesota Twins · **118** Kansas City Royals · **145** Chicago White Sox
- **117** Houston Astros · **136** Seattle Mariners · **140** Texas Rangers · **133** Athletics · **108** Los Angeles Angels

***

### 🎯 Tips for best results

- **Pick the right data type.** Each run returns one type — schedule separate runs for standings, scores and players.
- **Set the season.** Standings, teams and player stats are season‑specific; leave it empty to use the current year.
- **Use date ranges for scores.** A single `date` returns that day; `startDate`/`endDate` return a whole span.
- **Keep stats on for players.** `includePlayerStats` adds hitting and pitching numbers in the same run.
- **Narrow with team IDs.** For players, pass `teamIds` to target specific clubs instead of all 30.
- **Filter after export.** Pull broadly, then filter on rank, OPS, ERA, run differential or date in your spreadsheet or database.

***

### 📈 Scaling up

- **Back‑fill history** — loop seasons to build multi‑year standings and player‑stat datasets.
- **Track the season live** — schedule daily runs of scores and standings to keep a database current.
- **Whole‑league player stats** — run `players` with no team filter to pull every roster in one job.

***

### 🔌 Run it your way

- **Apify Console** — choose a data type and click Start.
- **API** — start runs and pull the dataset programmatically.
- **Scheduler** — refresh scores, standings and stats on a schedule.
- **Integrations** — push results to Google Sheets, Zapier, Make, webhooks, S3 and more.

***

### ❓ FAQ

**Which data can I get?**
League standings, team info, game scores, and player rosters with season hitting and pitching stats — one type per run.

**Do I need an account or API key?**
No. Just choose a data type and click Start.

**Can I get past seasons?**
Yes — set **Season** to any past year for standings, teams and player stats, or use a historical date range for scores.

**Do player records include stats?**
Yes — keep **Include player season stats** on to add hitting and pitching numbers for the chosen season.

**How do I get scores for a specific day?**
Set **Date** to that day, or use **Start date** and **End date** for a range.

**Are doubleheaders and suspended games handled?**
Yes — games are de‑duplicated by their unique game ID so a resumed game isn't counted twice.

**In what format is the data?**
Structured JSON by default, exportable to CSV, Excel, HTML and more.

**Can I run it on a schedule?**
Yes — use the Apify Scheduler, or start runs through the Apify API and its integrations.

***

### ⚖️ Legal & responsible use

This tool collects **publicly available** Major League Baseball information such as standings, schedules, scores and player data for legitimate uses like analysis, research, journalism and app development. You are responsible for how you use the data and for complying with all applicable laws and regulations, the source website's terms, and any intellectual‑property rights. This scraper is not affiliated with, endorsed by, or connected to Major League Baseball, MLB Advanced Media, or any team; **MLB**, team names and all related marks are trademarks of their respective owners and are used here for identification only.

***

#### Tags

`mlb` · `mlb scraper` · `baseball` · `baseball stats` · `mlb stats` · `mlb standings` · `mlb scores` · `mlb players` · `player stats` · `sports data` · `sports scraper` · `baseball api` · `fantasy baseball` · `sports betting data` · `box scores` · `team stats`

# Actor input Schema

## `dataType` (type: `string`):

What to scrape: league standings, team info, game scores or player rosters with stats.

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

Season year for standings, teams and players. Defaults to the current year.

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

For the Scores data type: a single day in YYYY-MM-DD format (e.g. 2026-08-25). Leave empty to use today.

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

For the Scores data type: first day of a date range, YYYY-MM-DD. Use with End date.

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

For the Scores data type: last day of a date range, YYYY-MM-DD.

## `teamIds` (type: `array`):

For the Players data type: limit to specific team IDs (e.g. 147 = Yankees, 119 = Dodgers). Leave empty to scrape all 30 teams.

## `includePlayerStats` (type: `boolean`):

For the Players data type: add each player's hitting and pitching stats for the season.

## `rosterType` (type: `string`):

For the Players data type: which roster to pull.

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

Stop after this many records. Leave high to get everything.

## `maxConcurrency` (type: `integer`):

How many requests to run in parallel (used by the Players data type).

## `proxyConfiguration` (type: `object`):

Proxy settings. Apify Proxy is recommended for reliable access.

## Actor input object example

```json
{
  "dataType": "standings",
  "season": 2026,
  "includePlayerStats": true,
  "rosterType": "active",
  "maxItems": 1000,
  "maxConcurrency": 6,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# 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 = {
    "season": 2026,
    "maxItems": 1000,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("haketa/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 = {
    "season": 2026,
    "maxItems": 1000,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("haketa/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 '{
  "season": 2026,
  "maxItems": 1000,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call haketa/mlb-stats-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,haketa/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/5c8wzLxNSpjbePosf/builds/P082M6JI1OhFSErnU/openapi.json
