-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get minor league stats? #87
Comments
Using def player_stat_data_modified(personId, group="[hitting,pitching,fielding]", type="season", sportId=1):
"""Returns a list of current season or career stat data for a given player."""
params = {
"personId": personId,
"hydrate": "stats(group=" + group + ",type=" + type + ",sportId=" + str(sportId) + "),currentTeam",
}
r = statsapi.get("person", params)
stat_groups = []
player = {
"id": r["people"][0]["id"],
"first_name": r["people"][0]["useName"],
"last_name": r["people"][0]["lastName"],
"active": r["people"][0]["active"],
"current_team": r["people"][0]["currentTeam"]["name"],
"position": r["people"][0]["primaryPosition"]["abbreviation"],
"nickname": r["people"][0].get("nickName"),
"last_played": r["people"][0].get("lastPlayedDate"),
"mlb_debut": r["people"][0].get("mlbDebutDate"),
"bat_side": r["people"][0]["batSide"]["description"],
"pitch_hand": r["people"][0]["pitchHand"]["description"],
}
for s in r["people"][0].get("stats", []):
for i in range(0, len(s["splits"])):
stat_group = {
"type": s["type"]["displayName"],
"group": s["group"]["displayName"],
"season": s["splits"][i].get("season"),
"stats": s["splits"][i]["stat"],
}
stat_groups.append(stat_group)
player.update({"stats": stat_groups})
return player
personId = 691725 # Andrew Painter
sportId = 13 # A+
painter = player_stat_data_modified(691725, sportId=13) I will add the |
v1.5 is available on pypi now ( |
Great thanks |
Seems that player_stat_data() only returns major league stats, how can I get current season stats for a minor leaguer?
The text was updated successfully, but these errors were encountered: