Baseball API
Complete reference for all baseball endpoints including leagues, teams, players, games, live scores, odds, and statistics.
Authentication
All API requests require authentication using an API key. You can send the API key in one of two ways:
HTTP Header (Recommended)
X-Api-Key: your_api_key_hereQuery Parameter
?api_key=your_api_key_hereExample Request (cURL)
curl -X GET "https://api.api4sports.com/api/baseball/leagues" \ -H "X-Api-Key: your_api_key_here"
/baseball/countriesGet all baseball countries
Returns a list of all countries that have baseball leagues.
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/countries" \ -H "X-Api-Key: your_api_key_here"
Response
{
"message": "Success",
"data": [
{
"id": 44,
"name": "England",
"logo": "https://api.api4sports.com/logos/football/logo_country/england.png"
},
{
"id": 1,
"name": "United States",
"logo": "https://api.api4sports.com/logos/baseball/logo_country/usa.png"
},
{
"id": 2,
"name": "Japan",
"logo": "https://api.api4sports.com/logos/baseball/logo_country/japan.png"
}
]
}/baseball/leaguesGet all baseball leagues
Returns a list of all active baseball leagues with pagination support (based on your subscription plan).
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
itemsPerPage | string | query | No | Number of items per page. Use "*" to get all results without pagination. Default: 15 |
page | integer | query | No | Page number for pagination. Default: 1 |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/leagues?itemsPerPage=15&page=1" \ -H "X-Api-Key: your_api_key_here"
Response
{
"message": "Success",
"data": [
{
"id": 11590,
"name": "MLB",
"country": "United States",
"year": "2024",
"country_id": 1,
"logo": "https://api.api4sports.com/logos/baseball/logo_leagues/mlb.png",
"country_logo": "https://api.api4sports.com/logos/baseball/logo_country/usa.png",
"importance": 5,
"date_start": "2024-03-28",
"date_stop": "2024-10-30"
}
],
"pagination": {
"current_page": 1,
"per_page": 15,
"total": 50,
"last_page": 4,
"from": 1,
"to": 15
}
}/baseball/countries/{countryId}/leaguesGet leagues by country
Returns all baseball leagues for a specific country (based on your subscription plan).
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
countryId | integer | path | Yes | Country ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/countries/1/leagues" \ -H "X-Api-Key: your_api_key_here"
Response
{
"message": "Success",
"data": [
{
"id": 11590,
"name": "MLB",
"country": "United States",
"year": "2024",
"country_id": 1,
"logo": "https://api.api4sports.com/logos/baseball/logo_leagues/mlb.png",
"country_logo": "https://api.api4sports.com/logos/baseball/logo_country/usa.png",
"importance": 5,
"date_start": "2024-03-28",
"date_stop": "2024-10-30"
}
]
}/baseball/leagues/{leagueId}/teamsGet teams by league
Returns all baseball teams for a specific league (based on your subscription plan).
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
leagueId | integer | path | Yes | League ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/leagues/11590/teams" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": [
{
"id": 1,
"name": "New York Yankees",
"slug": "new-york-yankees",
"logo": "https://api.api4sports.com/logos/baseball/teams/new-york-yankees.png",
"active": true,
"venue_name": "Yankee Stadium",
"venue_city": "New York",
"venue_capacity": 54251
}
]
}/baseball/playersGet baseball players
Returns all baseball players from teams in leagues you have access to (based on your subscription plan).
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
team_id | integer | query | No | Filter by team ID |
league_id | integer | query | No | Filter by league ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/players?team_id=1" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": [
{
"id": 1,
"name": "Aaron Judge",
"number": "99",
"position": "RF",
"bats_hand": "R",
"throws_hand": "R",
"age": 31,
"height": "6-7",
"weight": "282",
"active": true,
"team_id": 1,
"team_name": "New York Yankees",
"team_logo": "https://api.api4sports.com/logos/baseball/teams/new-york-yankees.png",
"league_id": 1,
"league_name": "MLB",
"league_logo": "https://api.api4sports.com/logos/baseball/leagues/mlb.png",
"stats": [
{
"season": 2024,
"type": "batting",
"position": "RF",
"rank": 5,
"games_played": 150,
"team_id": 1,
"team_name": "New York Yankees",
"league_id": 1,
"at_bats": 550,
"runs": 95,
"hits": 160,
"doubles": 30,
"triples": 3,
"home_runs": 40,
"total_bases": 320,
"runs_batted_in": 100,
"walks": 75,
"strikeouts": 120,
"stolen_bases": 10,
"caught_stealing": 3,
"batting_avg": "0.291",
"on_base_percentage": "0.370",
"slugging_percentage": "0.582"
},
{
"season": 2024,
"type": "pitching",
"position": "SP",
"rank": 10,
"games_played": 32,
"team_id": 1,
"team_name": "New York Yankees",
"league_id": 1,
"games_started": 30,
"wins": 15,
"losses": 8,
"saves": 0,
"quality_starts": 20,
"holds": 0,
"innings_pitched": "195.2",
"earned_runs": 65,
"strikeouts": 220,
"walks": 50,
"strikeouts_per_9_innings": "10.1",
"pitches_per_start": "95.5",
"earned_run_average": "2.99",
"walk_hits_per_inning_pitched": "1.05"
},
{
"season": 2024,
"type": "fielding",
"position": "Totals",
"rank": 25,
"games_played": 150,
"team_id": 1,
"team_name": "New York Yankees",
"league_id": 1,
"full_innings": 1200,
"total_chances": 350,
"putouts": 300,
"assists": 45,
"errors": "0.986",
"double_plays": 5,
"fielding_percentage": "0.986",
"range_factor": "2.30",
"zone_rating": "0.9"
}
]
}
]
}/baseball/gamesGet baseball games
Returns baseball games from leagues in your subscription. Requires date range (from/to). Max 6 months range.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
from | string($date) | query | Yes | Start date (YYYY-MM-DD). Required. |
to | string($date) | query | Yes | End date (YYYY-MM-DD). Required. Max 6 months range. |
league_id | integer | query | No | Filter by league ID |
team_id | integer | query | No | Filter by team ID (home or away) |
items_per_page | integer | query | No | Number of items per page (max 500, default 100) |
page | integer | query | No | Page number. Default: 1 |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/games?from=2024-05-01&to=2024-05-31&league_id=1" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": [
{
"id": 12345,
"date": "2024-05-15",
"time": "19:05",
"status": "finished",
"stage": "Regular Season",
"live": false,
"extra_innings": false,
"total_score": "5-3",
"league": {
"id": 1,
"name": "MLB"
},
"tournament": {
"id": 100,
"name": "MLB 2024",
"season": "2024"
},
"home_team": {
"id": 1,
"name": "New York Yankees",
"logo": "https://api.api4sports.com/logos/baseball/logo_teams/yankees.png"
},
"away_team": {
"id": 2,
"name": "Boston Red Sox",
"logo": "https://api.api4sports.com/logos/baseball/logo_teams/redsox.png"
},
"home_score": {
"total": 5,
"hits": 10,
"errors": 1,
"innings": {
"1": 0,
"2": 1,
"3": 2,
"4": 0,
"5": 1,
"6": 0,
"7": 0,
"8": 1,
"9": 0
}
},
"away_score": {
"total": 3,
"hits": 8,
"errors": 2,
"innings": {
"1": 1,
"2": 0,
"3": 0,
"4": 2,
"5": 0,
"6": 0,
"7": 0,
"8": 0,
"9": 0
}
},
"venue": {
"id": 50,
"name": "Yankee Stadium"
}
}
],
"pagination": {
"current_page": 1,
"per_page": 100,
"total": 500,
"last_page": 5,
"from": 1,
"to": 100
}
}/baseball/liveGet live baseball games
Returns all live baseball games grouped by league (based on your subscription plan).
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/live" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": [
{
"league_id": 11590,
"league_name": "MLB",
"league_logo": "/images/baseball/leagues/mlb.png",
"games": [
{
"id": 12345,
"date": "2024-05-15",
"time": "19:05",
"status": "IN PROGRESS",
"stage": "Regular Season",
"extra_innings": false,
"total_score": "5-3",
"venue": {
"name": "Yankee Stadium",
"city": "New York"
},
"home_team": {
"id": 1,
"name": "New York Yankees",
"logo": "/images/baseball/teams/nyy.png",
"score": {
"total": 5,
"hits": 10,
"errors": 1,
"innings": [
0,
1,
2,
0,
1,
0,
0,
1,
null
],
"extra": null
}
},
"away_team": {
"id": 2,
"name": "Boston Red Sox",
"logo": "/images/baseball/teams/bos.png",
"score": {
"total": 3,
"hits": 8,
"errors": 2,
"innings": [
1,
0,
0,
2,
0,
0,
0,
0,
null
],
"extra": null
}
}
}
]
}
]
}/baseball/teams/{team_id}/injuriesGet team injuries
Returns injury reports for a specific team.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
team_id | integer | path | Yes | Team ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/teams/88/injuries" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": [
{
"id": 1,
"player_id": 123,
"player_name": "John Means",
"report_date": "2024-05-15",
"status": "Sidelined",
"description": "Elbow - ALCS?",
"team_id": 88,
"team_name": "Baltimore Orioles",
"team_logo": "/images/baseball/teams/bal.png"
}
]
}/baseball/teams/{team_id}/statsGet team statistics
Returns batting, pitching and fielding statistics for a specific team.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
team_id | integer | path | Yes | Team ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/teams/88/stats" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": {
"team_id": 88,
"team_name": "Baltimore Orioles",
"team_logo": "/images/baseball/teams/bal.png",
"batting": {
"rank": 1,
"games_played": 162,
"at_bats": 5416,
"runs": 677,
"hits": 1273,
"doubles": 251,
"triples": 19,
"home_runs": 191,
"runs_batted_in": 643,
"batting_avg": "0.235",
"on_base_percentage": "0.305",
"slugging_percentage": "0.394"
},
"pitching": {
"rank": 1,
"games_played": 162,
"quality_starts": 54,
"innings_pitched": "1432.2",
"hits": 1433,
"earned_runs": 733,
"home_runs": 217,
"walks": 523,
"strikeouts": 1351,
"wins": 75,
"losses": 87,
"saves": 38,
"earned_run_avg": "4.60"
},
"fielding": {
"rank": 1,
"games_played": 162,
"total_chances": 6100,
"putouts": 4300,
"assists": 1700,
"errors": 100,
"fielding_pct": "0.984"
}
}
}/baseball/oddsGet pre-match odds
Returns pre-match odds for baseball games within the specified date range. Max 5 days range.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
from | date | query | Yes | Start date (YYYY-MM-DD) |
to | date | query | Yes | End date (YYYY-MM-DD). Max 5 days range. |
game_id | integer | query | No | Filter by specific game ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/odds?from=2024-05-15&to=2024-05-20" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": [
{
"game_id": 2602,
"game_date": "2024-05-15T19:05:00Z",
"home_team": "New York Yankees",
"away_team": "Boston Red Sox",
"bookmakers": [
{
"name": "DraftKings",
"markets": [
{
"type": "moneyline",
"home": -145,
"away": 125
},
{
"type": "runline",
"home": -1.5,
"home_odds": 140,
"away": 1.5,
"away_odds": -165
},
{
"type": "total",
"line": 8.5,
"over": -110,
"under": -110
}
]
}
]
}
]
}/baseball/leagues/{league_id}/standingsGet standings by league
Returns the current standings for a specific baseball league, grouped by division.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
league_id | integer | path | Yes | League ID |
Example Request
curl -X GET "https://api.api4sports.com/api/baseball/leagues/11590/standings" \ -H "X-Api-Key: your_api_key_here"
Response
{
"success": 1,
"result": {
"league": {
"id": 11590,
"name": "MLB",
"logo": "/images/baseball/leagues/mlb.png"
},
"standings": {
"AL East": [
{
"position": 1,
"team_name": "Baltimore Orioles",
"team_logo": "/teams/bal.png",
"wins": 101,
"losses": 61,
"pct": 0.623,
"gb": "-"
},
{
"position": 2,
"team_name": "Tampa Bay Rays",
"team_logo": "/teams/tb.png",
"wins": 99,
"losses": 63,
"pct": 0.611,
"gb": "2.0"
}
],
"AL Central": [
{
"position": 1,
"team_name": "Minnesota Twins",
"team_logo": "/teams/min.png",
"wins": 87,
"losses": 75,
"pct": 0.537,
"gb": "-"
}
]
}
}
}Error Codes
Unauthorized
API key is missing or invalid
Forbidden
No active plan or no access to this sport/league
Not Found
The requested resource was not found
Validation Error
The request parameters are invalid
Too Many Requests
Daily request limit exceeded
