MLB Stats API - Baseball Data avatar
MLB Stats API - Baseball Data

Pricing

from $0.01 / 1,000 results

Go to Apify Store
MLB Stats API - Baseball Data

MLB Stats API - Baseball Data

Comprehensive MLB baseball statistics including player stats, game logs, standings & historical data. Perfect for fantasy sports, betting & analytics.

Pricing

from $0.01 / 1,000 results

Rating

0.0

(0)

Developer

John Rippy

John Rippy

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

3 days ago

Last modified

Share

MLB Stats API

"Complete MLB Data in Clean JSON" by John Rippy | johnrippy.link


Simple Access to Official MLB Statistics

The MLB Stats API exists but is complex and poorly documented. Hundreds of endpoints, nested responses, and frequent changes make it frustrating to use.

What if you could get clean, simple MLB data with one API call?

The MLB Stats API actor wraps the official MLB API and returns clean, structured data:

  • All 30 MLB teams with details
  • Full 40-man rosters with player info
  • Current division standings
  • Complete game schedules
  • Individual player statistics (batting & pitching)
  • Box scores with play-by-play
  • League leaders by category

No API key required. No authentication needed. Just simple JSON responses.


Why Use This Instead of Direct API Access

1. Clean Data Structure

Raw MLB API returns inconsistent, deeply nested JSON. We normalize everything.

Raw MLB API:

{
"people": [{
"id": 660271,
"fullName": "Shohei Ohtani",
"stats": [{
"type": {"displayName": "season"},
"splits": [{
"stat": {"homeRuns": 54}
}]
}]
}]
}

Our API:

{
"player": "Shohei Ohtani",
"playerId": 660271,
"team": "Los Angeles Dodgers",
"homeRuns": 54,
"battingAverage": ".310"
}

2. No Authentication Needed

We handle all the complexity. You just make requests.

3. Stable Endpoints

MLB changes their API frequently. We maintain compatibility.

4. Both Batting and Pitching Stats

Get comprehensive stats for any player in one call.


Available Tasks

TaskDescriptionRequired Params
teamsAll 30 MLB teams with basic infoNone
team_rosterFull 40-man roster with playersteamId
team_scheduleTeam's season scheduleteamId
standingsCurrent division standingsNone
player_statsIndividual player statisticsplayerId
game_boxscoreFull game box scoregameId
scheduleLeague schedule by datedate
leadersLeague leaders by categoryleaderCategory

Quick Start Examples

Example 1: Get Current Standings

{
"task": "standings"
}

Example 2: Get Team Roster

{
"task": "team_roster",
"teamId": 119
}

Example 3: Get Player Stats

{
"task": "player_stats",
"playerId": 660271,
"season": "2024"
}

Example 4: Today's Schedule

{
"task": "schedule",
"date": "2025-04-15"
}

Team IDs Reference

TeamIDTeamID
Arizona Diamondbacks109Milwaukee Brewers158
Atlanta Braves144Minnesota Twins142
Baltimore Orioles110New York Mets121
Boston Red Sox111New York Yankees147
Chicago Cubs112Oakland Athletics133
Chicago White Sox145Philadelphia Phillies143
Cincinnati Reds113Pittsburgh Pirates134
Cleveland Guardians114San Diego Padres135
Colorado Rockies115San Francisco Giants137
Detroit Tigers116Seattle Mariners136
Houston Astros117St. Louis Cardinals138
Kansas City Royals118Tampa Bay Rays139
Los Angeles Angels108Texas Rangers140
Los Angeles Dodgers119Toronto Blue Jays141
Miami Marlins146Washington Nationals120

Output Examples

Standings Response

{
"task": "standings",
"success": true,
"data": {
"season": "2024",
"standings": [
{
"division": "AL East",
"teams": [
{
"rank": 1,
"team": "Baltimore Orioles",
"teamId": 110,
"wins": 91,
"losses": 71,
"pct": ".562",
"gamesBack": "-",
"wildCard": "-",
"runsScored": 765,
"runsAllowed": 640,
"runDifferential": 125,
"streak": "W3",
"last10": "7-3"
}
]
}
]
}
}

Player Stats Response

{
"task": "player_stats",
"success": true,
"data": {
"player": {
"id": 660271,
"name": "Shohei Ohtani",
"team": "Los Angeles Dodgers",
"position": "DH",
"jerseyNumber": 17,
"bats": "L",
"throws": "R",
"batting": {
"gamesPlayed": 159,
"atBats": 636,
"runs": 134,
"hits": 197,
"doubles": 38,
"triples": 6,
"homeRuns": 54,
"rbi": 130,
"stolenBases": 59,
"battingAverage": ".310",
"obp": ".390",
"slg": ".646",
"ops": "1.036"
}
}
}
}

Pay-Per-Event Pricing

You only pay for what you use. No API key costs. No rate limit fees.

EventDescriptionPrice
api_requestEach task executed$0.01

Cost Examples

UsageMonthly Cost
100 requests$1
1,000 requests$10
10,000 requests$100

Free tier available for testing.


Use Cases

Fantasy Baseball

  • Player tracking: Monitor stats for your roster
  • Injury updates: Check player status
  • Waiver wire: Compare available players
  • Trade analysis: Compare player statistics

Sports Analytics

  • Team performance: Analyze wins, losses, run differentials
  • Sabermetrics: Calculate WAR, wOBA, FIP, etc.
  • Trend analysis: Track performance over time
  • Predictive models: Feed data into ML models

Apps & Websites

  • Live scores: Display current standings
  • Schedule displays: Show upcoming games
  • Stats pages: Build player stat cards
  • Team pages: Roster and team info

Media & Content

  • Article research: Get accurate stats for articles
  • Broadcast support: Quick stats lookup
  • Social content: Stats for posts and graphics

API Integration

Using the Apify API (JavaScript)

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const run = await client.actor('localhowl/mlb-stats-api').call({
task: 'player_stats',
playerId: 660271
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].data.player);

Using cURL

curl -X POST "https://api.apify.com/v2/acts/localhowl~mlb-stats-api/runs?token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"task": "standings"
}'

Webhook Integration

Webhook Payload Format

{
"event": "task_completed",
"timestamp": "2025-04-15T12:00:00.000Z",
"actor": "mlb-stats-api",
"task": "standings",
"success": true,
"data": { ... }
}

Automation Ideas

  • Daily standings: Update your database every morning
  • Game alerts: Trigger when your team plays
  • Stat tracking: Log player stats to Google Sheets
  • Discord bot: Post updates to your server

Limitations

  • Historical data: Limited to current and recent seasons
  • Real-time: Not truly live (refresh every few minutes during games)
  • Rate limits: Built-in delays to respect MLB servers
  • Offseason: Limited data during winter months

Support


Built by John Rippy | johnrippy.link


Keywords

mlb api, baseball api, mlb stats, baseball statistics, mlb standings, mlb scores, baseball data, mlb player stats, fantasy baseball api, sports data api, mlb schedule, baseball scraper, mlb data feed, sports analytics, sabermetrics