MLB Stats API
"Complete MLB Data in Clean JSON" by John Rippy | johnrippy.link
🏆 2025 Zapier Automation Hero of the Year — Project Phoenix: A 95-step AI sales pipeline cutting development time by 50%. Read more →
---
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
---
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
---
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
---
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.Cost Examples
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
- Email: john@johnrippy.link
🏆 2025 Zapier Automation Hero of the Year — Project Phoenix: A 95-step AI sales pipeline cutting development time by 50%. Read more →
- GitHub: Report issues on the repository
---
Built by John Rippy | johnrippy.link🏆 2025 Zapier Automation Hero of the Year — Project Phoenix: A 95-step AI sales pipeline cutting development time by 50%. Read more →
---
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