This is a node module created to wrap the Yahoo! Fantasy Sports API (link). At the moment, not all subresources are available, nor are any of the 'collection' elements. I do hope to add them, and they have been added to the code. If the token expires, the module will return a 'token_expired' error.
The API is designed to act as a helper for those interacting with the Y! Fantasy API. The goal is for ease of use for the user, both in terms of querying endpoints and parsing responses. I've noticed that in working with the API, the data is not always the easiest to understand, so hopefully what I have created here will help people out.
You can install the module via npm by running:
$ npm install yahoo-fantasy
In version 2.0, OAuth2.0 became the only way to communicate with the Yahoo! API. This was done for a number of reasons, but I do believe this will make it a better module in terms of both security, and should make it easier to use. The OAuth token from Yahoo! lasts for only an hour, so if the response returned from Yahoo! is an error, you'll have to refresh the authentication token from within your app.
You can view the source code for this project on Github. At the very least it will give you an idea of how you can use this module.
In fixing this bug I realized that my "team" set up was really only useful for MLB fantasy, so I rewrote team mapping to work better across all sports and give additional details that weren't previously reported. This will cause errors if you are using the team.manager attribute in your code.
Fixed a bug where leagueFetch was throwing an error, thanks danielspector!
Fixed a bug where player stats by week url was not being created properly, thanks withsmilo!
Fixed a bug where collections that contained subresources would return no data.
Added "Transactions" collection with functionality to add players, drop players, and add/drop players, thanks again [githubsmilo](https://github.com/githubsmilo)!
Fixed a bug in player.draft_analysis, thanks githubsmilo!
Added weeks param for league.scoreboard
Added weeks param for team.matchups
Fixed a bug where individual players weren't mapping properly
Minor code cleanup
Added the ability to specify a date or week when querying the roster resource.
Cleaned up the player normalization model
Fixed a bug where the team.roster call was erroring
Fixes to how POST data is handled
Significantly restructured the code to have more consistency and set it up better for future plans, namely POST methods and proper unit testing
* Removed the "refresh user token" and instead return the error to the user who can handle the refresh within their application.
Additional player attributes added, thanks ryus08!
Added a method to refresh the user's token if it has expired.
Hotfix to fix "Teams" collection - use error first convention
Made helper classes more consistent
Added collections for games, leagues, players, and teams
Added 'Team Matchups' subresource
Added 'League Scoreboard' subresource
Minor code cleanup and improvements
Refactored module to fix a bug where user sessions were not necessarily unique because of require caching.