Skip to content

Livematches in play

Demo: Matchboard, opens in a new tab

Baseball · USA · 30 teams

MLB API with the live count, every at-bat and every pitch

An MLB API for live scores with the inning, the count, outs and runners on base, and for every at-bat and pitch with its Statcast type, speed and zone, on league id 201220. Umpire crews, ballpark weather and postseason series have endpoints of their own, and the seasons go back to 2003.

  • Seasons since 2003
  • 30 teams
  • League id 201220
  • Every pitch from Pro

MLB

GET /v2/leagues/201220

League id
201220
Category
USA
Archive
Seasons since 2003
Teams
30 teams
Live channel
league:201220

In the data

The MLB in the API

What league id 201220 holds, and how its seasons are laid out.

Seasons from 2003, and what sits apart

/v2/leagues/201220/seasons lists every MLB season from 2003 to 2027, newest first, and the league card dates the 2027 season from 25 March to 30 October. The tables rank clubs by winPercentage with gamesBehind, count runs as their scoreUnit and carry no draws column. The preseason, the All-Star Game and the summer camp are competitions of their own, named MLB, Preseason, MLB All Star Game and MLB Summer Camp, so their games stay out of these seasons.

The count, as the source sends it

While a game is on, the fixture's inningState holds the inning and its half (top or bottom), the count of balls and strikes, the outs, and a flag for each of the three bases. The source resends it about once a minute rather than after every pitch, so the count can trail the field by up to a minute; on Business and Enterprise each new state is pushed whole over the WebSocket. The score keeps the R/H/E line: runs per inning from period1, extra innings from period10 on, then hits and errors.

At-bats, pitches, umpires and weather

From Pro, /v2/fixtures/{id}/points lists every at-bat with inning, half, batter and pitcher, and the home side's chance of winning, as the source rates it, before and after the at-bat. An at-bat's id opens /v2/fixtures/{id}/at-bats/{atBatId}/pitches, where each pitch has its Statcast pitchType, speedKmh, zone and the count after it, and the last one carries the result. On every plan, /umpires names the crew by station and /weather gives the ballpark conditions in metric units, observed first, then the forecast.

First request

The MLB in three calls

Every call starts from the league id, 201220. The seasons list gives the season ids, newest first, and the season id is what the tables, rounds, leaderboards and statistics ask for.

The answers use the usual { data, meta } envelope and the same field names as every other baseball competition, so the code works unchanged for the next league you add.

# Every season, newest first, with its season id
curl "https://api.datasportsapi.com/v2/leagues/201220/seasons" \
  -H "Authorization: Bearer $DATASPORTSAPI_API_KEY"

# The season's tables, by win percentage
curl "https://api.datasportsapi.com/v2/leagues/201220/standings?season={seasonId}&group=all" \
  -H "Authorization: Bearer $DATASPORTSAPI_API_KEY"

# The days with games, and how many on each
curl "https://api.datasportsapi.com/v2/leagues/201220/calendar?season={seasonId}" \
  -H "Authorization: Bearer $DATASPORTSAPI_API_KEY"
GET /v2/leagues/201220 · trimmed
{ "data": {
    "id": 201220, "name": "MLB", "sport": "baseball",
    "category": "USA",
    …
} }

History

How much of the MLB each plan reads

The archive goes back to 2003. Each plan reads back a set time from today; nothing live or upcoming is ever held back.

TopicHistoryWhat it covers of the MLB
FreeLast 7 daysLive and upcoming games, the table and statistics of a season still being played, and finished games from the last 7 days.
StarterLast 30 daysLive and upcoming games, the table and statistics of a season still being played, and finished games from the last 30 days.
ProLast 6 monthsLive and upcoming games, the table and statistics of a season still being played, and finished games from the last 6 months.
BusinessLast 12 monthsLive and upcoming games, the table and statistics of a season still being played, and finished games from the last 12 months.
EnterpriseFull historyThe whole archive: seasons since 2003.

Questions

MLB API, answered

Anything else? The full FAQ covers quota, plans and the data in general.

Does the MLB API have pitch-by-pitch data?

Yes, from Pro. Take an at-bat's id from /v2/fixtures/{id}/points and pass it to /v2/fixtures/{id}/at-bats/{atBatId}/pitches: each pitch comes with its Statcast type, its release speed in km/h (multiply by 0.6214 for mph), its zone, 1 to 9 inside the strike zone and 11 to 14 outside, and the balls, strikes and outs after it. Plays between pitches, such as a stolen-base attempt, appear as rows of kind steal.

Whose win probability comes with each at-bat?

The source's. homeWinProbabilityBefore and homeWinProbabilityAfter on each at-bat are its figures on a 0 to 100 scale, passed on as they come; they are neither our model nor bookmaker odds, and the away side's chance is 100 minus the home one.

Are the preseason and the All-Star Game included?

Yes, as competitions with ids and seasons of their own: MLB, Preseason from 2023, MLB All Star Game from 2020, and MLB Summer Camp. /v2/search?q=mlb&type=league lists them, each id ready for /v2/leagues/{id}, and because they sit apart, league 201220's tables count only its own games.

How far back does MLB data go?

To the 2003 season. How far back a key can read is set by its plan, counted back from today: Free 7 days, Starter 30 days, Pro 6 months, Business 12 months, and Enterprise the whole archive. Live and upcoming games, and the table and statistics of a season still being played, are open on every plan.

Can I follow MLB games live on the free plan?

Yes. Live and upcoming games are never held back by a plan, so a Free key follows every MLB game in play through /v2/livescores or /v2/fixtures/{id}, with score, status and clock current to the second, within the plan's request quota. On Business and Enterprise, the WebSocket channel league:201220 pushes every change instead.

Keep reading

Other competitions

Everything in the baseball data Sports statistics API Live scores API

Build on the MLB today.

1,000 free requests a day during the beta. No card, no sales call.