dtsong / sleeper-api-wrapper

A Python API wrapper for Sleeper's API: https://docs.sleeper.app/
MIT License
61 stars 21 forks source link

League.get_scoreboards does not support leagues with custom_scoring #10

Open mrnelson6 opened 1 year ago

mrnelson6 commented 1 year ago

I am using a league with custom scoring rules so the League.get_scoreboards does not support our league.

League.get_matchups() correctly returns the score values for players and a team on a given week but the corresponding scoreboard manipulates these values.

FWIW the points type and week feels like non-useful parameters on the get_scoreboards function since the matchups object already contains the information for the week and the scoring which could be specific to a league

wfordh commented 1 year ago

Looking over the code, I think there's a way we can simplify the League.get_scoreboards() function since it seems the spirit of the function is to get the matchup ID with the team names and scores while getting the matchups returns the roster ID instead of the team name.

Digging into the code there are a few flags. Internally this get_scoreboards() function is calling get_team_score() which uses the Stats() class and also has 2019 hardcoded as the year for a call to the get_week_stats() function of the Stats class.

The thing here is that although the stats API is still up and you can make calls to it (verified it just now), it's no longer documented in Sleeper's official docs. IMO it's an open question as to whether or not we should continue including the Stats() class in the package at all because of this. Maybe just adding a warning when it's imported would be enough.

Thanks for pointing this out though, hopefully one of us can clean it up and validate it somehow, though I'm not personally in a league with custom scoring. It does seem like the functions could be simplified and leverage what is in the matchups object, at the least.

wfordh commented 1 year ago

@mrnelson6 would you be able to provide an example of what the custom scoring looks like? I want to make sure I account for it correctly as I work on this

mrnelson6 commented 10 months ago

Hi @wfordh! Thanks for the response. Sorry you caught me right after I take my scheduled break for thinking about fantasy football.

So I am actually in a league where each year every player can increment/decrement any of the scoring/roster values by 1, so literally anything on the sleeper scoring page is a valid change. For example this year we had changes to make it so that each point a defense gives up is worth +2 points, every reception between 5-9 yards is +1. Incomplete passes are +2, rushing yards are worth 0.

So the take away is that I was wanting to use an API that would just use the league's scoring value and not require configuration itself. Which the League.get_matchups was returning.

Interesting that they deprecated the stats page. I was hoping we were going to see the list of APIs grow and not reduce.

I'll be ramping on this over the next couple weeks so I'll let you know if I get any more info

wfordh commented 10 months ago

No problem and same, as you can see the lack of dev work from me between then and now.

That's some fascinating scoring! I guess for now I'd recommend sticking with League.get_matchups() since it sounds like it's working for your purposes. I'm trying to crank through some updates before the season starts and will try to get League.get_scoreboards() working at a more sensible level. Hopefully we can get a release out 🤞

Yeah I think I saw a tweet from them once upon a time that their 3rd party stats provider wanted them to take it down, so it may not have been up to them. But I agree, would love to see the list grow!

Sounds good