-
-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Hi Todd et al.,
I'm unable to retrieve Minor League (MiLB) player data, but can for Major League (MLB) players.
The link I used for Major League players returned data via https://statsapi.mlb.com/api/v1/sports/1/players?season=2024
Using this same link, but replacing sportID
with 21 instead of 1, the API returned no players at all. https://statsapi.mlb.com/api/v1/sports/21/players?season=2024
At least using https://statsapi.mlb.com/api/v1/sports/21/ returns a 200 response, but otherwise, using optional fields like players does not work. When I use the wrapper API, it returns MLB players, which doesn't match the sportID
I used.
# Set my params
params = {
"stats": "season",
"group": "pitching",
"season": "2024",
"sportId": "21",
"limit": 50,
"offset": 0,
}
# Fetch the stats
response = statsapi.get("stats", params=params)
# Are there stats available?
if "stats" in response and len(response["stats"]) > 0:
splits = response["stats"][0].get("splits", [])
df = pd.json_normalize(splits)
else:
print("No MiLB season data found for the given parameters.")
# What are the stats?
display(df.head())
The above code returns:
Shouldn't MLB have supplied this data for the Google X MLB Hackathon? Otherwise, I'm not sure if any fields were missing or incorrect.
I'd appreciate your help!
Thank you,
Ebod