toddrob99 / MLB-StatsAPI

Python wrapper for MLB Stats API
GNU General Public License v3.0
513 stars 98 forks source link

gameType param not working for sports_players endpoint? #94

Closed Yurockkk closed 1 year ago

Yurockkk commented 1 year ago

Hi Todd,

Thanks for this very convenient wrapper library! I'm trying to get a list of players who made it to the post season and using the sports_players endpoint with gameType set to P (Playoffs). However, It doesn't seem to care about this param and always return the same result... for example:

pass in R (Regular Season), it returns 1539 players:

statsapi.get('sports_players', 
    {
        'season':2022,
        'gameType': 'R',
        'ver': 'v1',
        'sportId': 1
    }).get('people')

pass in P (Playoffs), it also returns 1539 players...:

statsapi.get('sports_players', 
    {
        'season':2022,
        'gameType': 'P',
        'ver': 'v1',
        'sportId': 1
    }).get('people')

Any workaround to fetch this player list?

Thank you.

toddrob99 commented 1 year ago

Interesting... You're right, the gameType param doesn't do anything. It's in the old copy of the documentation I have as a reference, but even the example given in the documentation doesn't work. It gives the example of https://statsapi.mlb.com/api/v1/sports/1/players?season=2017&gameType=W but that returns the same number of players as gameType=R for 2017. I guess you could find the teams in the postseason from the schedule endpoint and get the players for each team. Not sure if there's a straightforward workaround.

Yurockkk commented 1 year ago

Alright, I'll try to get it from schedule_postseason endpoint and will share here if I found a straightforward workaround

Thanks!

toddrob99 commented 1 year ago

Please do, and I'll close for now.