NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server →

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:

MLB data at a glance

Season valueseason=2026 is the 2026 season, from spring training in February to the World Series in October or November
Season typespreseason (spring training), regular and postseason
Line scoreRuns by inning in period_scores, plus hits and errors for each team
Inningsperiod is the inning; status_detail is top, middle, bottom or end during a game, and clock is null
Extra inningsdecided_in is regulation or extra_innings; a game shortened by weather ends with fewer innings
DoubleheadersThe second game of a doubleheader has the same game_id with -2 at the end; rain delays show as delayed or suspended
Leagues and divisionsconference 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.

4 endpoints

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

Live demo · no API key required
Query parameters
league
date
team
season
season_type
status
game_id
limit
offset

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/baseballgames
Sample response
[
{
"game_id": "mlb-20260923-hou-sea",
"league": "mlb",
"sport": "baseball",
"season": 2026,
"season_label": "2026",
"season_type": "regular",
"date": "2026-09-23",
"start_time": "2026-09-24T02:00:00Z",
"status": "final",
"status_detail": null,
"period": 10,
"clock": null,
"home_team": {
"team_id": "mlb-sea",
"name": "Seattle Mariners",
"abbreviation": "SEA"
},
"away_team": {
"team_id": "mlb-hou",
"name": "Houston Astros",
"abbreviation": "HOU"
},
"home_score": 6,
"away_score": 5,
"period_scores": {
"home": [
0,
0,
3,
0,
1,
0,
0,
0,
0,
2
],
"away": [
0,
0,
4,
0,
0,
0,
0,
0,
0,
1
]
},
"hits": {
"home": 9,
"away": 10
},
"errors": {
"home": 0,
"away": 0
},
"decided_in": "extra_innings",
"winner": "mlb-sea",
"venue": {
"name": "T-Mobile Park",
"city": "Seattle",
"state": "WA",
"country": "US"
},
"neutral_site": false,
"original_date": null,
"updated_at": "2026-10-28T03:15:30Z"
}
]

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

Live demo · no API key required
Query parameters
league
season
conference
division

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/baseballstandings
Sample response
[
{
"league": "mlb",
"sport": "baseball",
"season": 2026,
"season_label": "2026",
"team": {
"team_id": "mlb-mil",
"name": "Milwaukee Brewers",
"abbreviation": "MIL"
},
"conference": "NL",
"division": "NL Central",
"games_played": 162,
"wins": 103,
"losses": 59,
"win_pct": 0.63580245,
"games_behind": 0,
"points_for": 832,
"points_against": 618,
"point_differential": 214,
"streak": "W5",
"home_record": "55-26",
"away_record": "48-33",
"last_10": "8-2",
"league_rank": 1,
"conference_rank": 1,
"division_rank": 1,
"final": false
}
]

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

Live demo · no API key required
Query parameters
league
team
conference
division
active

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/baseballteams
Sample response
[
{
"team_id": "mlb-nyy",
"league": "mlb",
"sport": "baseball",
"abbreviation": "NYY",
"name": "New York Yankees",
"nickname": "Yankees",
"city": "New York",
"conference": "AL",
"division": "AL East",
"venue": {
"name": "Yankee Stadium",
"city": "Bronx",
"state": "New York",
"country": "US"
},
"active": true
}
]

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

Live demo · no API key required
Query parameters
league
team
name
player_id
position
limit
offset

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/baseballplayers?team=NYY
Sample response
[
{
"player_id": "mlb-p-7f7bb5fac7",
"league": "mlb",
"team": {
"team_id": "mlb-nyy",
"name": "New York Yankees",
"abbreviation": "NYY"
},
"name": "Anthony Volpe",
"first_name": "Anthony",
"last_name": "Volpe",
"position": "SS",
"jersey_number": "11",
"height_in": 70,
"height_cm": 178,
"weight_lb": 197,
"weight_kg": 89,
"birth_date": "2001-04-28",
"birth_place": {
"city": "New York",
"state": "NY",
"country": "US"
},
"roster_status": "active",
"experience_years": 4
}
]

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/baseballplayers?team=NYY" \ -H "X-Api-Key: YOUR_API_KEY"

Frequently Asked Questions

  • 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.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • 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.
  • 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.
  • 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 with league=mlb. API Ninjas is not affiliated with or endorsed by MLB.
  • Yes. Every final game has runs per inning in period_scores, plus hits and errors for both teams, so you can draw a full line score. On paid plans they update throughout games in progress, with the inning in period and top, middle, bottom or end in status_detail.
  • A game that goes past nine innings has decided_in=extra_innings and a run total for every inning. Rain delays show as status=delayed and suspended games as suspended. The second game of a doubleheader has the same id with -2 at the end.
  • Yes. Spring training games have season_type=preseason, and the Wild Card Series through the World Series have season_type=postseason, all in the season of the same year (season=2026).
  • Call /v1/baseballstandings?league=mlb&division=AL East. Rows are ordered by division rank and include games_behind, win_pct, streak, last_10 and the playoff seed in the American or National League in conference_rank.

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.