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

The kind of data this API exposes, based on its documentation. We could not call the endpoint to confirm the exact field names.

MLB Records and Stats data via REST API

Example Response

Illustrative shape only — we were not able to call this endpoint (it requires credentials or exposes no public sample URL), so the fields below show the kind of data this API returns rather than a recorded response.

JSON Response · Illustrative
{
  "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

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://lookup-service-prod.mlb.com/json/named.sport_hitting_tm.bam?league_list_id=mlb&game_type=R&season=2023&team_id=147&player_id=592450";
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

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

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

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth No Auth
HTTPS NO
CORS UNKNOWN
Category Sports & Fitness
Difficulty Beginner
Listing details not endpoint-verified

Similar APIs

View All →