GithubHelp home page GithubHelp logo

actionbronson / yfantasy-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hkyplyr/yfantasy-api

0.0 0.0 0.0 175 KB

Python API client that can be used to make calls to the Yahoo! Fantasy Sports API. Developed specifically for NHL, but should support the NFL, MLB, and NBA as well.

Home Page: https://pypi.org/project/yfantasy-api/

License: MIT License

Python 100.00%

yfantasy-api's Introduction

Yahoo Fantasy API

A simply Python client that can be used to make calls to the Yahoo! Fantasy Sports API.

Python package

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

# The request url created is: /team/nhl.l.12345.t.1/roster/players/stats;type=date;date=2021-03-31
from yfantasy_api.api import YahooFantasyApi

league_id = 12345  # This should be the id of the league you are querying
game_id = 'nhl'    # This should be the id of the game you are querying
team_id = 1        # This should be the id of the team you are querying

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)

# Output:
# Brock Nelson 0.00
# Joel Eriksson Ek 0.05
# Nazem Kadri 4.00
# Alex Ovechkin 0.00
# Jake Guentzel 0.00
# ...truncated for brevity...

Obtain draft_results, including player information for each pick.

# The request url created is: /league/nhl.l.12345/draft_results/players
from yfantasy_api.api import YahooFantasyApi

league_id = 12345  # This should be the id of the league you are querying
game_id = 'nhl'    # This should be the id of the game you are querying
team_id = 1        # This should be the id of the team you are querying

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}')

# Output:
# 1 - 1 - Connor McDavid
# 1 - 2 - Alex Ovechkin
# 1 - 3 - Patrick Kane
# 1 - 4 - Steven Stamkos
# 1 - 5 - Sidney Crosby
# ...truncated for brevity...

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 [email protected]:hkyplyr/yfantasy-api.git
...
cd yfantasy_api
...
pip install -r requirements.txt

Release History

TODO

Meta

Travis Paquette - @hkyplyr - [email protected]
Distributed under the MIT license. See LICENSE for more information.

How to Contribute

  1. Clone repo and create a new branch: $ git checkout -b short_feature_name.
  2. Make changes and test
  3. Submit a Pull Request

yfantasy-api's People

Contributors

hkyplyr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.