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

$0.08/1K 🔥 Fast MLB baseball scraper! Teams, schedule, scores & standings from the official StatsAPI. No key. JSON, CSV, Excel or API in seconds. Pull thousands of data points for apps, betting & fantasy ⚡

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

## Pricing

from $0.08 / 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.

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 Baseball Stats Scraper ⚾

Scrape **MLB teams, daily schedules with live scores, and season standings** straight from the official MLB StatsAPI — clean structured JSON, **no API key**, and **datacenter-proxy friendly** (runs cheap, no residential proxy needed).

Built for **sports apps, betting models, fantasy baseball tools, and stats dashboards** that need reliable Major League Baseball data without touching a flaky HTML page or paying for a gated API.

***

### What it does

Pick a **mode** and go:

| Mode | Returns | Input used |
|------|---------|------------|
| `teams` | Every current MLB club (30 teams) | — |
| `schedule` | All games for a date, with scores + status | `date` (YYYY-MM-DD) |
| `standings` | Division standings for a season | `season` (YYYY) |

Data comes from `statsapi.mlb.com` — the same clean JSON feed that powers official scoreboards.

***

### Example output

**Teams** (`mode: teams`)

```json
{
  "type": "team",
  "id": 147,
  "name": "New York Yankees",
  "abbreviation": "NYY",
  "location": "Bronx",
  "league": "American League",
  "division": "American League East",
  "venue": "Yankee Stadium",
  "scraped_at": "2026-07-16T12:00:00+00:00"
}
```

**Schedule** (`mode: schedule`, `date: 2024-07-04`)

```json
{
  "type": "game",
  "game_pk": 744834,
  "date": "2024-07-04T15:05:00Z",
  "status": "Final",
  "home_team": "Washington Nationals",
  "home_score": 1,
  "away_team": "New York Mets",
  "away_score": 0,
  "venue": "Nationals Park",
  "scraped_at": "2026-07-16T12:00:00+00:00"
}
```

**Standings** (`mode: standings`, `season: 2024`)

```json
{
  "type": "standing",
  "team": "Yankees",
  "wins": 94,
  "losses": 68,
  "win_pct": 0.58,
  "games_back": "-",
  "division_rank": "1",
  "scraped_at": "2026-07-16T12:00:00+00:00"
}
```

***

### Input

| Field | Type | Default | Notes |
|-------|------|---------|-------|
| `mode` | select | `teams` | `teams`, `schedule`, or `standings` |
| `date` | string | `2024-07-04` | YYYY-MM-DD, used in `schedule` mode |
| `season` | string | `2024` | Four-digit year, used in `standings` mode |
| `maxItems` | integer | `500` | Cap on records pushed (max 2000) |

***

### Pricing

Runs on **512 MB** and finishes in seconds. Expect roughly **~$1 per 1,000 records** on the Apify platform (usage-based) — a single teams or standings pull is a fraction of a cent. No proxy costs because the endpoint is datacenter-friendly.

***

### Why this scraper

- **No API key, no signup** — point and run.
- **Clean JSON in, clean JSON out** — no HTML parsing to break on redesigns.
- **Chrome-124 fingerprint** via `curl_cffi`, with a stdlib `urllib` fallback for maximum reliability.
- **Fail-loud** — a mode that returns zero rows aborts the run instead of silently shipping empty data.
- **Nullable schema** — every field is optional, so partial upstream data never crashes your pipeline.

#### Comparison

| | This actor | Official API direct | Generic HTML scrapers |
|--|--|--|--|
| API key required | ❌ No | ✅ Yes (rate-limited) | ❌ No |
| Structured, flattened output | ✅ | ⚠️ Deeply nested | ⚠️ Fragile |
| Proxy needed | ❌ Datacenter OK | — | ✅ Often residential |
| Scores + standings + teams in one | ✅ | ⚠️ Multiple calls | ❌ |

***

### Related actors

- [NHL Stats Scraper](https://apify.com/ninhothedev/nhl-stats-scraper)
- [ESPN Sports Scraper](https://apify.com/ninhothedev/espn-sports-scraper)
- [F1 Scraper](https://apify.com/ninhothedev/f1-scraper)
- [Sports Scraper](https://apify.com/ninhothedev/sports-scraper)

***

**Keywords:** MLB scraper, baseball stats API, MLB schedule scraper, MLB standings scraper, baseball scores API, MLB teams data, sports data scraper, fantasy baseball data, sports betting data, MLB StatsAPI

# Actor input Schema

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

What to scrape: 'teams' returns every MLB club, 'schedule' returns all games (with scores and status) for the given date, 'standings' returns division standings for the given season.

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

Date to fetch games for in YYYY-MM-DD format. Only used when mode is 'schedule'.

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

Four-digit season year to fetch standings for, e.g. 2024. Only used when mode is 'standings'.

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

Maximum number of records to push to the dataset. Protects against unexpectedly large result sets.

## Actor input object example

```json
{
  "mode": "teams",
  "date": "2024-07-04",
  "season": "2024",
  "maxItems": 500
}
```

# Actor output Schema

## `results` (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 = {
    "date": "2024-07-04",
    "season": "2024"
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/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 = {
    "date": "2024-07-04",
    "season": "2024",
}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/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 '{
  "date": "2024-07-04",
  "season": "2024"
}' |
apify call ninhothedev/mlb-stats-scraper --silent --output-dataset

```

## MCP server setup

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