Yahoo Fantasy API
A simply Python client that can be used to make calls to the Yahoo! Fantasy Sports API.
This library provides a fluent API to build and make calls to the Yahoo! Fantasy Sports API. It was developed specifically for NHL use initially, but should be generic enough to support MLB, NBA, and NFL as well.
Installation
pip install yfantasy_api
Usage examples
Obtain team information, including the roster with player stats for March 31st 2021
from yfantasy_api import YahooFantasyApi
league_id = 12345
game_id = 'nhl'
team_id = 1
api = YahooFantasyApi(league_id, game_id)
team = api \
.team(team_id) \
.roster() \
.stats(date='2021-03-31') \
.get()
for player in team.players:
print(player.full_name, player.points)
Obtain draft_results, including player information for each pick.
from yfantasy_api import YahooFantasyApi
league_id = 12345
game_id = 'nhl'
team_id = 1
api = YahooFantasyApi(league_id, game_id)
league = api \
.league() \
.draft_results() \
.players() \
.get()
for draft_result in league.draft_results:
print(f'{draft_result.round} - {draft_result.pick} - {draft_result.player.full_name}')
For working examples of the above scenarios, see examples.py
Development setup
I suggest you use some form of virtual environment to avoid clashing dependencies, but that is obviously your call. My suggested virtual environment is virtualenvwrapper.
git clone git@github.com:hkyplyr/yfantasy-api.git
...
cd yfantasy_api
...
pip install -r requirements.txt
Release History
TODO
Meta
Travis Paquette - @hkyplyr - tpaqu15@gmail.com
Distributed under the MIT license. See LICENSE
for more information.
How to Contribute
- Clone repo and create a new branch: $ git checkout -b short_feature_name.
- Make changes and test
- Submit a Pull Request