MLB Records and Stats API

⭐ Beginner's Pick Sports & Fitness / No Auth Required Beginner HTTP
Free to Use Varies (check documentation)

Overview

MLB Records and Stats API provides current and historical statistics for Major League Baseball, including player batting and pitching records, team stats, and season standings. It is a free, no-auth API which makes it beginner-friendly for sports data projects. The base URL follows a predictable REST structure.

💡

Beginner Tip

All statistical data is returned as strings even for numeric values, so remember to convert with parseInt() or parseFloat() when doing calculations.

Available Data

MLB Records and Stats data via REST API
JSON-formatted response data
Freely accessible without authentication

Example Response

JSON Response
{
  "match_id": 4521,
  "home_team": "Team A",
  "away_team": "Team B",
  "score": {
    "home": 2,
    "away": 1
  },
  "status": "Full Time",
  "date": "2025-01-15",
  "league": "Premier League"
}

Field Reference

name_display_first_last Player full name in First Last format
avg Batting average for the season (returned as a string, e.g., ".301")
hr Total home runs hit during the season
rbi Runs batted in for the season
ops On-base plus slugging percentage, a composite offensive stat
team_abbrev Three-letter abbreviation for the player team

Implementation Example

const url = "https://appac.github.io/mlb-data-api-docs/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

404 Not Found The player ID or season year does not exist in the dataset
Verify the player ID by searching the player list endpoint first, and use a valid MLB season year
Numeric values are strings The API serializes all fields as strings
Use parseFloat(data.avg) or parseInt(data.hr) when performing math operations
CORS error in browser Some endpoints may not include CORS headers
Route requests through a simple Express proxy or use a server-side function

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 20/20
🔒 Security 5/15
🛠 Developer XP 20/20
✓ Reliability 7/15
Response Time 72ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS NO
CORS UNKNOWN
Category Sports & Fitness
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →