Baseball API
The Baseball API covers Major League Baseball: get the schedule from spring training to the World Series, live scores with the inning and half-inning on paid plans, final line scores with runs by inning, hits and errors, standings by division with games behind and playoff seeds, and every team's roster. league=mlb is the default, so no league parameter is needed. The free plan covers the current season's schedule, final scores, standings and rosters.
Available endpoints:
- /v1/baseballgames - Schedules, live and final scores
- /v1/baseballstandings - Standings
- /v1/baseballteams - Teams, divisions and venues
- /v1/baseballplayers - Rosters and player profiles
League guides: MLB API. One API key works for every sports API.
Baseball data at a glance
| Line score | Runs per inning in period_scores, with home_score and away_score as runs and hits and errors for both teams |
|---|---|
| Innings | period is the current or last inning played. During a game, status_detail says whether it is the top, middle, bottom or end of the inning |
| No game clock | Baseball is untimed, so clock is always null |
| Extra innings | A tie after nine innings continues: decided_in is extra_innings and period_scores has a value for every inning |
| Weather | Rain delays show as delayed, suspended games as suspended, and a postponed game keeps its game_id with the first date in original_date |
| Doubleheaders | Both games of a doubleheader have their own id; the second ends in -2 |
| Standings | conference is AL or NL and division e.g. NL West, with games_behind, runs scored and allowed, last_10 and the playoff seed in conference_rank |
League
| League | What you get | League value |
|---|---|---|
| MLB | Schedules, live and final line scores by inning with hits and errors, standings by division, teams and rosters | mlb |
https://api.api-ninjas.com/v1/baseballgames
Returns schedules, live scores and final scores. Ask for one day, a team's season or one game; with no parameters you get today's games. Paid plans see games in progress with the score, inning updated throughout the game; the free plan sees their status and the final score once they end. The free plan covers the current season. Developer plans add the three previous seasons, and the Business tier and above gets the full season archive.
Parameters
Every parameter is optional; league defaults to mlb.
leagueoptionalOptional:
mlb, the default.dateoptionalGame day in the league's home time zone (YYYY-MM-DD). Defaults to today when no team or season is given.
teamoptionalTeam id, abbreviation or name (e.g.
NYY): that team's games in the season.seasonoptionalSeason, as the year it starts (
2026= 2026-27 for seasons that span two years). Defaults to the current season. On its own, returns the season's games 50 per page; useoffsetfor the next page.season_typeoptionalOnly games of this part of the season.
statusoptionalOnly games with this status.
game_idoptionalReturn one game.
limitoptional Premium onlyGames per page (1-500). Default
50.offsetoptionalGames to skip, for paging. Default
0.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/baseballgames endpoint returns a JSON array of games in start order, or an error.
game_idUnique id of the game, e.g.
mlb-20260923-hou-sea. It never changes, even when a game is moved to another date.leaguemlb.sportAlways
baseball.seasonSeason, as the year it starts:
2026is the 2026 season.season_labelDisplay form of the season, e.g.
2026.season_typepreseason(spring training),regularorpostseason.dateGame day in US Eastern time (YYYY-MM-DD), so a West Coast night game keeps its US date.
start_timeScheduled start in UTC (ISO 8601).
statusscheduled,in_progress,final,postponed,canceled,suspended(including abandoned soccer matches) ordelayed(e.g. a rain delay).status_detailPremium onlyDuring a game:
top,middle,bottomorendof the inning. Otherwisenull. While a game is in progress, the free plan seesThis field is for premium subscribers only.periodLive values: PremiumCurrent inning, or the last one played once the game is final. Extra innings continue the count (
10,11, ...). While a game is in progress, the free plan seesThis field is for premium subscribers only.clockAlways
null: baseball has no game clock. Useperiodandstatus_detailfor the inning.home_team, away_teamThe teams:
team_id,nameandabbreviation, named as they were that season.home_score, away_scoreLive values: PremiumCurrent or final score (runs);
nullbefore the game starts. While a game is in progress, the free plan seesThis field is for premium subscribers only.period_scoresLive values: PremiumScore per inning for
homeandaway, with every extra inning. While a game is in progress, the free plan seesThis field is for premium subscribers only.hits, errorsLive values: PremiumHits and errors for
homeandaway, completing the line score.decided_inFor final games:
regulationorextra_innings.winnerteam_idof the winner once the game is final;nullbefore that.venueWhere the game is played:
name,city,stateandcountry(ISO 3166-1 alpha-2).neutral_sitetruewhen neither team is at home, e.g. international games, the Super Bowl and soccer cup finals.original_dateFor a game moved to another date: the date it was first scheduled for. Otherwise
null.updated_atWhen any field of the game last changed (UTC).
Live Demo
Get a free API key to get started — no credit card required.
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/baseballgames" \
-H "X-Api-Key: YOUR_API_KEY"https://api.api-ninjas.com/v1/baseballstandings
Returns the league table for a season, ordered by league rank, or by conference or division rank when you filter. Tables update throughout the season, shortly after each game ends. The free plan covers the current season. Developer plans add the three previous seasons, and the Business tier and above gets the full season archive.
Parameters
leagueoptionalOptional:
mlb, the default.seasonoptionalSeason, as the year it starts. Defaults to the current season.
conferenceoptionalOnly this conference, e.g.
AL.divisionoptionalOnly this division, e.g.
NL West.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/baseballstandings endpoint returns a JSON array of team rows, or an error. Fields that do not apply to a league are left out.
league, sport, season, season_labelLeague, sport and season of the table.
teamteam_id,nameandabbreviation, named as they were that season.conference, divisionThe league as
ALorNL, and the division, e.g.AL East.games_played, wins, lossesRecord.
win_pct, games_behindWinning percentage and games behind the division leader.
points_for, points_against, point_differentialRuns scored and allowed, and the run differential.
streakCurrent streak, e.g.
W2orL1.home_record, away_recordHome and road records, e.g.
4-1.last_10Record over the last 10 games.
league_rank, conference_rank, division_rankRank in the majors, in the AL or NL (
conference_rank, the playoff seed) and in the division.finaltrueonce the regular season is over and the table no longer changes.
Live Demo
Get a free API key to get started — no credit card required.
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/baseballstandings" \
-H "X-Api-Key: YOUR_API_KEY"https://api.api-ninjas.com/v1/baseballteams
Lists teams with their league, conference, division and home venue. Available on every plan.
Parameters
leagueoptionalOptional:
mlb.teamoptionalTeam id, abbreviation or name (e.g.
NYY): return one team.conferenceoptionalOnly teams in this conference.
divisionoptionalOnly teams in this division.
activeoptionalfalselists former teams that appear in past seasons.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/baseballteams endpoint returns a JSON array of teams, or an error.
team_idUnique id, e.g.
mlb-nyy. Use it, the abbreviation or the name in other endpoints.leagueThe team's league.
sportAlways
baseball.abbreviation, name, cityIdentity of the team.
nickname, conference, divisionNickname, current conference and division.
venueHome venue:
name,city,state,country.activetruefor current teams.
Live Demo
Get a free API key to get started — no credit card required.
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/baseballteams" \
-H "X-Api-Key: YOUR_API_KEY"https://api.api-ninjas.com/v1/baseballplayers
Returns current rosters and player profiles, by team or by name. Rosters refresh every day. Available on every plan.
Parameters
Provide team or name, or a player_id.
leagueoptionalOptional:
mlb, the default.teamoptionalTeam id, abbreviation or name: that team's current roster.
nameoptionalFull or partial player name. Case and accents are ignored.
player_idoptionalReturn one player.
positionoptionalOnly this position, e.g.
SS.limitoptional Premium onlyPlayers per page (1-500). Default
50.offsetoptionalPlayers to skip, for paging. Default
0.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/baseballplayers endpoint returns a JSON array of players, or an error. League-specific fields are left out where they do not apply.
player_idUnique id, e.g.
mlb-p-7f7bb5fac7. It stays the same when a player changes teams.leagueLeague of the player's current roster.
teamCurrent team:
team_id,nameandabbreviation;nullfor a player whoseroster_statusisnot_on_roster.name, first_name, last_namePlayer name.
position, jersey_numberPosition abbreviation (e.g.
SP,RP,C,SS,CF) and jersey number.height_in, height_cm, weight_lb, weight_kgHeight and weight.
birth_date, birth_placeDate of birth and birthplace (
city,state,country).roster_statusactive,suspendedornot_on_roster.college, experience_yearsCollege and years of professional experience, where they apply.
Live Demo
Get a free API key to get started — no credit card required.
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/baseballplayers?team=NYY" \
-H "X-Api-Key: YOUR_API_KEY"Frequently Asked Questions
Can I use the Baseball API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Baseball API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Baseball API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Baseball API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.Is there a free baseball API?
Yes. The free plan covers the current MLB season: the full schedule, final scores with runs, hits and errors, standings, teams and rosters. Paid plans add live scores by inning and the three previous seasons.Which baseball league is covered?
Major League Baseball: spring training, the regular season and the postseason.league=mlbis the default, so no league parameter is needed. See the MLB API guide for the season, standings and roster details.How do I build a box score line?
Useperiod_scoresfor the runs in each inning,home_scoreandaway_scorefor the total runs, andhitsanderrorsfor the H and E columns. Extra innings add more entries toperiod_scores.Why is clock always null for baseball?
Baseball has no game clock. During a game,periodis the inning andstatus_detailistop,middle,bottomorend, which together tell you exactly where the game is.How do I get the standings for one division?
Call/v1/baseballstandings?division=AL East. Rows are ordered by division rank and includegames_behind,win_pct,streak,last_10and the playoff seed in the AL or NL inconference_rank.
Explore API integration use cases for recommended APIs and workflow examples.
API Ninjas is not affiliated with or endorsed by the NFL, the NBA, the NHL or any other league, competition or team. League, competition and team names are trademarks of their owners and are used only to identify them.