MLB API documentation
23 baseball data endpoints over REST and MCP. One key, credits per call.
Coming from the MLB Stats API? See how they compare.
Your first call
Sign up for a free key (500 credits every month, no card), swap it in for YOUR_API_KEY, and send this. get_standings costs 2 credits.
Request
curl -X POST https://mcp.fastballapi.com/v1/get_standings \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"season": 2025
}'Response
{
"season": 2025,
"standings": [
{
"team_id": "8",
"abbrev": "MIL",
"display_name": "Milwaukee Brewers",
"wins": 97,
"losses": 65,
"home_wins": 52,
"home_losses": 29,
"away_wins": 45,
"away_losses": 36,
"runs_scored": 806,
...First 14 lines. Full response and every field
REST / cURL
POST to /v1/{tool_name} with your params as JSON body. No MCP client needed:
curl -X POST https://mcp.fastballapi.com/v1/list_teams \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY"With parameters:
curl -X POST https://mcp.fastballapi.com/v1/get_standings \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"season":2025}'Save the raw JSON
Keep your key in an environment variable so it never sits in a script or a chat, and write each response to a file:
export FASTBALLAPI_API_KEY="your key here"
curl -s -X POST https://mcp.fastballapi.com/v1/get_standings \
-H "Content-Type: application/json" \
-H "x-api-key: $FASTBALLAPI_API_KEY" \
-d '{"season":2025}' \
-o get_standings.jsonThe file holds exactly what the API returned. Tools that page their results return a next_offset; send it back as offset for the next page.
ChatGPT and Claude
Both connect to the MCP server with a sign-in instead of a key: you sign in to FastballAPI once and press Allow. Step-by-step for ChatGPT and Claude.
Python
The official client is on PyPI. It has no required dependencies. Set FASTBALLAPI_API_KEY to your key and it is picked up automatically:
pip install fastballapiThen call any endpoint as a method (the example uses pandas, pip install "fastballapi[pandas]"):
from fastballapi import Client, to_dataframe
client = Client()
props = client.get_player_props(
game_id="401815991",
market="batter_home_runs",
)
df = to_dataframe(props, key="props")
print(df[["player_name", "bookmaker", "line", "over_odds", "under_odds"]].head(10))Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"fastballapi": {
"url": "https://mcp.fastballapi.com/mcp?key=YOUR_API_KEY"
}
}
}Claude Code
One command:
claude mcp add fastballapi https://mcp.fastballapi.com/mcp?key=YOUR_API_KEY --transport streamable-httpFind the right call
All 23 questionsWhat timestamps mean, whether lines are pre-game, and what you can do with the data: data timing and rights.
Guides
All guidesWorking Python, JavaScript and cURL for common questions, each run against the live API.
- Where do I get MLB pitch-by-pitch data for a model?get_pitches
- How do I get a pitcher's pitch mix and whiff rate in Python?get_pitch_mix
- How do I build an MLB spray chart in Python?get_spray_chart
- How do I find MLB teams that over- or underperformed their run differential?get_standings
- How do I measure a hitter's run value with runners in scoring position?get_plate_appearances
- How do I backtest MLB closing moneylines and run totals in Python?get_odds
- How do I get MLB pitcher strikeout prop lines and results?get_prop_history
- How do I get MLB scores and the schedule in Python?get_games
- How do I get MLB home run leaders and stat leaders in Python?get_leaders
- How do I get the MLB injury report in Python?get_injuries
- How often does an MLB hitter go over his total bases line?get_prop_history
- How often does an MLB slugger hit a home run when it is priced?get_prop_history
- How often does an MLB hitter go over his hits line?get_prop_history
- How do I get first five innings MLB odds history in Python?get_market_odds
- How do I get NRFI odds history in Python?get_market_odds
Endpoints
23 endpoints by category. Each page has parameters, requests in three formats, a full example response and every response field.
Static reference1 credit/call
Basic lookup2 credits/call
- get_games2 creditsGames with runs, hits and errors by season, date, range or team
- get_schedule2 creditsUpcoming games with the median line across sportsbooks
- get_standings2 creditsStandings from every final game, with run differential and Pythagorean record
- get_injuries2 creditsThe latest injury report
- get_ratings2 creditsOur team Elo ratings, ranked
Stats + aggregation5 credits/call
- get_game5 creditsOne game: every batting and pitching line, each book's line, win probability
- get_player5 creditsSeason batting (AVG, OBP, SLG, OPS, RE24) and pitching (ERA, WHIP, K/9)
- get_player_games5 creditsA player's full batting and pitching game log
- get_leaders5 creditsSeason leaders among qualified batters and pitchers
- get_team_stats5 creditsRuns for and against, team batting and opponents' batting
- get_pitch_mix5 creditsA pitcher's arsenal: usage, velocity, whiff rate per pitch type
- get_odds5 creditsEvery sportsbook's moneyline, run line and total for a game (5) or a day (10)
Multi-table10 credits/call
- get_plate_appearances10 creditsPlate-appearance play-by-play with base-out state, batted ball, win probability, RE24
- get_pitches10 creditsPitch-by-pitch: count, type, velocity, location, result
- get_spray_chart10 creditsWhere a batter or team hits the ball, by trajectory and field
- get_player_props10 creditsPlayer prop lines by sportsbook: the closing line (one pre-game capture per line before October 2026)
- get_prop_history10 creditsA player's prop lines against the result, game by game
- get_alt_lines10 creditsAlternate run lines and totals by sportsbook: every point on each book's ladder, opening and closing, from 2023
Time-series10 credits/call
- get_line_movement10 creditsSnapshots of each sportsbook's line before first pitch
- get_prop_movement10 creditsHow one player's prop line moved before a game, every capture by sportsbook
- get_market_odds10 creditsOpening and closing lines by sportsbook for the first-5-innings and first-inning markets (from May 2023, each game added the morning after it is played)
Reference
Authentication
Every request requires an API key. Pass it via header or query parameter:
x-api-key: YOUR_API_KEY
# or
Authorization: Bearer YOUR_API_KEY
# or (MCP only)
?key=YOUR_API_KEYVerify your email, then create an API key from the dashboard. Free accounts get 500 credits every month.
Base URL
https://mcp.fastballapi.comREST API: POST /v1/{tool} with JSON body. Works with cURL, Python, any HTTP client.
MCP: POST /mcp via Streamable HTTP. Works with Claude Desktop, Claude Code, Cursor, and any MCP client.
Rate limits
| Credit balance | Rate limit |
|---|---|
| 100 credits or more | 60 req/min |
| Under 100 credits | 10 req/min |
The limit is the same on every plan. It is burst protection, not the spend boundary; credits are that, and they are enforced per request. Running low slows you down so you notice before the balance reaches zero.
Error handling
| Code | Meaning | What to do |
|---|---|---|
| 400 | Invalid parameters | Check required fields and value types |
| 401 | Invalid or missing API key | Check your x-api-key header |
| 402 | Insufficient credits | Top up your wallet or upgrade your plan |
| 429 | Rate limit exceeded | Wait and retry (see limits above) |
| 500 | Server error | Retry with idempotency key. Credits auto-refund on server errors. |
Pass x-idempotency-key or x-request-id headers to make retries duplicate-safe.
Data coverage
NCAA Division I baseball (NCAA)
FastballAPI also serves the NCAA. Pass "league": "ncaabase" to any tool that lists it, or connect to https://mcp.fastballapi.com/mcp/ncaabase. NCAA API coverage.
| Data | Status | Coverage | Volume |
|---|---|---|---|
Games and box scores Line scores and every batter's and pitcher's line. | Available | See the season table | Every game, every player |
Pitch-by-pitch Count, pitch type, velocity, location and result for every pitch. Pitch type and velocity are on 96% or more of each season's pitches, and 99.8% or more from 2020. Automatic balls and strikes are not pitches. | Available | See the season table | About 295 pitches per game |
Plate appearances Base-out state, result, batted-ball trajectory and location, runs, RE24. | Available | See the season table | About 76 per game |
Win probability Our model's home win probability after each plate appearance: inning, outs, runners and score, our team ratings and the two starters. | Available | 2015 to current | After every plate appearance |
Odds Moneyline, run line and total by sportsbook; opening and closing lines from July 2020 (sportsbook odds archive), the final pregame line only in the earlier seasons. The daily feed is mostly one book per game since 2024; the other books come from the sportsbook odds archive. Player props are separate (get_player_props, from May 2023). | Partial | 2015 to current | 4 to 13 books per game to 2023; 7 to 8 with opening and closing lines since 2021 |
Ratings Our Elo, before and after every game. | Available | Every season loaded | Every team, every game |
College baseball NCAA Division I games with league=ncaabase: the tournament by round since 2010, scores since 2015, box scores and plate appearances (from the scorer's text) for part of each season since 2020, ratings, opening and closing lines from May 2023 (a median of 5 or 6 books a game). Not every Division I game, and box scores and play-by-play for part of each season only (the college page shows each season). No pitch rows or batted-ball locations. | Partial | 2010 to current | The Division I games we carry |
Injury report Each listed player's status, injury and expected return, captured daily. Daily captures from launch; no history before that. | Partial | From launch | Daily |
Coverage describes the datasets FastballAPI supports. Freshness and operational health are tracked separately.
Odds snapshot definitions
opening: The first line a sportsbook posted for the game, held from 2024 and, from July 2020, in the sportsbook odds archive.
closing: The sportsbook's last line before first pitch.
Odds coverage currently documents the books reported with each game: 4 to 13 books per game from 2015 to 2023, plus opening and closing lines from the sportsbook odds archive since July 2020 (a median of 7 books in 2021 to 2023, 8 since 2024). The daily feed is mostly one book since 2024; the sportsbook odds archive rows carry a median of 8. Before 2024 we hold each sportsbook's final pregame line, stored as the close. From 2024 the daily feed has opening and closing lines, usually from one book. Since July 2020 the sportsbook odds archive adds opening and closing lines per book for nearly every game, a median of 7 books in 2021 to 2023 and 8 since 2024. Daily snapshots before each game from launch.
Response format
REST API
All successful REST responses wrap the result in a data key:
{ "data": { "teams": [...], "count": 30 } }Error responses return:
{ "error": "Insufficient credits", "message": "This tool costs 5 credits, you have 2" }MCP Protocol
MCP responses follow the standard MCP tool result format. The data is returned directly (no data wrapper). Both access methods return identical data, just different envelopes.
Conventions
Seasons: a 4-digit year. Example: 2025.
Game IDs: a game id, e.g. 401569531 (a game id; find them with get_games). Get them from get_games or get_schedule.
Team abbreviations: Standard codes (NYY, LAD, BOS (or a team id); list_teams has them). Use list_teams if unsure.
Pagination: Endpoints use a limit parameter. No cursor or offset. Narrow your filters to get different slices of data.
Credits: Deducted before the request executes. Automatically refunded on server errors. Monthly credits are used first, then wallet balance.