Closed mgbeck002 closed 5 months ago
@mgbeck002 make sure you are up to date with the most current release, 0.5.22. I tried to reproduce your error and I am not able to.
The following does not produce any sort of error for me
>>> import mlbstatsapi
>>> mlb = mlbstatsapi.Mlb()
>>> print (mlb.get_team_roster(120, rosterType="active", date="2024-06-24"))
The Player data class in 0.5.22 has the attribute parentteamid already implemented
Upgrade and let me know if this issue still persists. If it does, post the output please
Sorry. I assumed it was an issue for all teams. Looks like it's an issue with the Phillies id 143. Specifically this player:
{
person: {
id: 675650,
fullName: "Michael Mercado",
link: "/api/v1/people/675650"
},
jerseyNumber: "63",
position: {
code: "1",
name: "Pitcher",
type: "Pitcher",
abbreviation: "P"
},
status: {
code: "A",
description: "Active"
}
},
import mlbstatsapi
mlb = mlbstatsapi.Mlb()
for team in mlb.get_teams():
try:
mlb.get_team_roster(team.id, rosterType="active", date="2024-06-24")
except TypeError as e:
print(f"Type error for team: {team.id}")
Type error for team: 143
@mgbeck002 thanks for included that information! It turns out you were right with that one edge case, the player Michael Mercado did not have a parentteamid and since it was a mandatory field it was throwing the error. Changed this to an optional field due the the situation and now everything should work. Upgrade to 0.5.23 and this should be fixed for you!
Thanks. That fixed it
Looks like it's a case sensitivity thing.
See the output from this endpoint: https://statsapi.mlb.com/api/v1/teams/120/roster as an example.
This can be reproduced by using the get_team_roster function with the following arguments:
120, rosterType="active", date="2024-06-24"