uberfastman / yfpy

Python API wrapper for the Yahoo Fantasy Sports public API (supports NFL, NHL, MLB, and NBA).
https://pypi.org/project/yfpy/
GNU General Public License v3.0
163 stars 44 forks source link

YahooAPI weekly stats url possible change #25

Closed austinbeauch closed 2 years ago

austinbeauch commented 2 years ago

Hi again @uberfastman, I think Yahoo might've pulled a quick one on you and changed the call for weekly stats. Just want go get your opinion, and if they did indeed make a change I'd be glad to work on it and send another pull request.

I came across this in get_player_stats_by_week, specifically this line. The week specification is given by

;type=week;week=" + str(chosen_week),,

however I was noticing that this wasn't returning any player stats.

Looking at Yahoo's wall of "documentation" that I'm sure you're familiar with, I found their week was specified via

https://fantasysports.yahooapis.com/fantasy/v2/team//roster;week=10

Changing our friendly line 2149/2150 to

;week=" + str(chosen_week),

appeared to solve the problem. Not sure if this is something NHL specific.

Not anything urgent, don't rush to check it out. Thanks again for all your work!

uberfastman commented 2 years ago

@austinbeauch something to note here is that if you remove the type=week parameter, the call will no longer be providing stats for a given week, but will instead provide player stats for the entire season. This is the case for both NHL and NFL.

However, if I recall correctly, Yahoo only actually lets you get player stats by week for NFL. Due to the continuous nature of NHL/MLB/NBA vs. the weekly nature of NFL, they don't delineate player stats by week. Instead you have to use the approach in get_player_stats_by_date in order to get a player's stats for a given date. If you want a whole week then you have to iterate through all the days of the time period you want. Mildly annoying since it requires more calls, but it's just how they do it. You can see this difference is slightly alluded to in the documentation here.

Anyway, thanks for your continued efforts to help me make improvements to yfpy, I always appreciate that, as well as you using it! 😃