MLB API
A baseball API for Major League Baseball: get the schedule, live scores with the 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, from spring training through the World Series. The free plan covers the current season's schedule, final scores, standings and rosters.
MLB is served by the Baseball API (league=mlb is the default, so no league parameter is needed). The same API key works for every sports API.
Available endpoints:
- /v1/baseballgames - MLB schedules, live and final scores
- /v1/baseballstandings - MLB standings
- /v1/baseballteams - MLB teams
- /v1/baseballplayers - MLB rosters and players
MLB data at a glance
| Season value | season=2026 is the 2026 season, from spring training in February to the World Series in October or November |
|---|---|
| Season types | preseason (spring training), regular and postseason |
| Line score | Runs by inning in period_scores, plus hits and errors for each team |
| Innings | period is the inning; status_detail is top, middle, bottom or end during a game, and clock is null |
| Extra innings | decided_in is regulation or extra_innings; a game shortened by weather ends with fewer innings |
| Doubleheaders | The second game of a doubleheader has the same game_id with -2 at the end; rain delays show as delayed or suspended |
| Leagues and divisions | conference is AL or NL, and division is e.g. AL East |
MLB standings fields
wins, losses, win_pct, games_behind (division leader), runs scored and allowed in points_for and points_against, streak, last_10, home and road records, division_rank, league_rank and the playoff seed in the AL or NL in conference_rank.
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.
Full parameter and response reference: /v1/baseballgames.
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.
Full parameter and response reference: /v1/baseballstandings.
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.
Full parameter and response reference: /v1/baseballteams.
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.
Full parameter and response reference: /v1/baseballplayers.
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 MLB API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the MLB 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 MLB 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 MLB 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 an official MLB API?
MLB does not offer a documented public API for commercial developers. The API Ninjas Baseball API provides MLB schedules, live and final scores with line scores, standings and rosters withleague=mlb. API Ninjas is not affiliated with or endorsed by MLB.Does the MLB API include runs by inning, hits and errors?
Yes. Every final game has runs per inning inperiod_scores, plushitsanderrorsfor both teams, so you can draw a full line score. On paid plans they update throughout games in progress, with the inning inperiodandtop,middle,bottomorendinstatus_detail.How are extra innings, rain delays and doubleheaders shown?
A game that goes past nine innings hasdecided_in=extra_inningsand a run total for every inning. Rain delays show asstatus=delayedand suspended games assuspended. The second game of a doubleheader has the same id with-2at the end.Are spring training and the postseason included?
Yes. Spring training games haveseason_type=preseason, and the Wild Card Series through the World Series haveseason_type=postseason, all in the season of the same year (season=2026).How do I get the standings for one division?
Call/v1/baseballstandings?league=mlb&division=AL East. Rows are ordered by division rank and includegames_behind,win_pct,streak,last_10and the playoff seed in the American or National League 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.