rbarton65 / espnff

ESPN Fantasy Football API
246 stars 89 forks source link

ESPN Fantasy platform updates broke JSON parsing? #59

Open earlejam opened 5 years ago

earlejam commented 5 years ago

From what I can tell, some big changes to the ESPN fantasy platform may have changed the format of the JSON this package parses. Especially when attempting to get the leage: league = League(league_id, year).

I get a JSONDecodeError("Expecting value", s, err.value) from None followed by json.decoder.JSONDecodeError: Expecting value: line 2 column 2 (char 2). Can anyone else confirm this problem?

danabrey commented 5 years ago

All of the API endpoints that I've tried appear to be redirecting to http://www.espn.com/fantasy/football/. They've either moved their API endpoints to a new location, or got rid of it.

danabrey commented 5 years ago

The new API is based at http://fantasy.espn.com/apis/v3 but the URLs bear no resemblance to v2.

League pages now make a call to e.g. http://fantasy.espn.com/apis/v3/games/ffl/seasons/2018/segments/0/leagues/7168?view=mBoxscore&view=mMatchupScore&view=mSchedule&view=mScoreboard&view=mSettings&view=mStatus&view=mTeam&view=mRoster&view=modular&view=mNav

That path appears to give all the available data for a league, regardless of what you pass as the value of the view GET parameter (obviously, as they're actually overriding it 10+ times in that URL!).

danabrey commented 5 years ago

@rbarton65 Looks like the ESPN relaunch has totally messed this up, would gladly assist in trying to fix this up.

scottenriquez commented 5 years ago

@danabrey do you by chance have a list of the new endpoints? I wrote a .NET package for this that I need to update as well. I haven't started sniffing out the endpoints yet, so I figured I'd check to see if you have.

Also, here's a URL for my league which is public unlike the link above: http://fantasy.espn.com/apis/v3/games/ffl/seasons/2019/segments/0/leagues/526113?view=mBoxscore&view=mMatchupScore&view=mSchedule&view=mScoreboard&view=mSettings&view=mStatus&view=mTeam&view=mRoster&view=modular&view=mNav

Side note: I reached out to my comish, and he said that as part of this redesign, our league got reset to private. Sounds like if you were using a public league like us, you'll need to set it to public again.

danabrey commented 5 years ago

@scottenriquez From what I could see when I last looked, there isn't a "list" of endpoints because that's the only one. Whatever you pass as the value of the "view" GET parameter, you get everything.

Thanks for the pointer about the league being reset to private!

bluesforsalvador commented 4 years ago

I love this project to help me score my league's non-standard scoring system. Is this fixable (need help?) Or shall I go back to keeping score with a spreadsheet =/

danabrey commented 4 years ago

The last activity on this project was in August 2017 so I am sort of assuming that @rbarton65 has moved on to other things, given that that was their last GitHub activity too? It might be a fork-and-fix job, and then a courtesy pull request. I am happy to help but I'm not an experienced Python developer.

thend20 commented 4 years ago

I hacked a few things into this module for my personal use. I was planning to see if I can salvage anything using the v3 endpoints before the start of this season. If I find anything, I'll fork and post it here.

thend20 commented 4 years ago

And look at that, someone already documented and built a "thing" with the new V3 api! https://github.com/mkreiser/ESPN-Fantasy-Football-API . This is in Node however. But, this is good, a lot of the hard work is already done.

kstreepy commented 4 years ago

I would be interested in supporting/working on anything related to this. Found another resource with a Python focus: https://stmorse.github.io/journal/espn-fantasy-v3.html

kstreepy commented 4 years ago

Here is a repo of a python V3 API in progress: https://github.com/cwendt94/ff-espn-api

tflurry commented 4 years ago

@danabrey do you by chance have a list of the new endpoints? I wrote a .NET package for this that I need to update as well. I haven't started sniffing out the endpoints yet, so I figured I'd check to see if you have.

Also, here's a URL for my league which is public unlike the link above: http://fantasy.espn.com/apis/v3/games/ffl/seasons/2019/segments/0/leagues/526113?view=mBoxscore&view=mMatchupScore&view=mSchedule&view=mScoreboard&view=mSettings&view=mStatus&view=mTeam&view=mRoster&view=modular&view=mNav

Side note: I reached out to my comish, and he said that as part of this redesign, our league got reset to private. Sounds like if you were using a public league like us, you'll need to set it to public again.

Are you able to get the url above to work with seasons prior to 2018? I only seem to be able to get it to work with 2018 and 2019.

scottenriquez commented 4 years ago

@tflurry I ran into the same issue and haven't found a way around this.

danabrey commented 4 years ago

Yeah, ESPN just killed any sort of public access to that history. There's no way of accessing it on the front-end anymore either. Shame.

tflurry commented 4 years ago

@scottenriquez @danabrey that's unfortunate... i wonder if we could petition to get them to make that history available... with the threat of leaving ESPN for Yahoo or someone else! lol.. we'd need a lot of signatures..

cgome032 commented 4 years ago

There's actually a second endpoint for the history of your fantasy football league. The url is: https://fantasy.espn.com/apis/v3/games/ffl/leagueHistory/ + "league ID"?seasonId="year"