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
fantasy-football fantasy-leagues fantasy-sports fantasy-sports-api fantasy-sports-leagues fantasyfootball hacktoberfest python python-api-wrapper python3 yahoo yahoo-api yahoo-fantasy yahoo-fantasy-baseball yahoo-fantasy-basketball yahoo-fantasy-football yahoo-fantasy-hockey yahoo-fantasy-sports

YFPY - Yahoo Fantasy Sports API Wrapper

Python API wrapper for the Yahoo Fantasy Sports public API

Author: Wren J. R. (uberfastman)

GitHub release (latest SemVer) GitHub tag (latest SemVer) GitHub Workflow Status (with event)

PyPI PyPI PyPI PyPI


Do you like the YFPY API wrapper? Star the repository on GitHub and please consider helping support its ongoing development:

Cryptocurrency Address
Bitcoin (BTC) bc1qataspvklhewtswm357m0677q4raag5new2xt3e
Ethereum (ETH) 0x5eAa522e66a90577D49e9E72f253EC952CDB4059


READ THE DOCS HERE!
Detailed documentation on YFPY can be found at https://yfpy.uberfastman.com.

Table of Contents


About

YFPY is a comprehensive wrapper around the Yahoo Fantasy Sports API. It allows for easy retrieval and parsing of almost any data you might wish to extract and use from any Yahoo fantasy league to which your Yahoo account has access (or for public leagues). The primary focus of this wrapper is on fantasy football (NFL), but it also supports usage with fantasy hockey (NHL), fantasy baseball (MLB), and fantasy basketball (NBA).


Installation

Pip

Manual


Setup

Yahoo Developer Network App

In order to use YFPY with private fantasy leagues, you must set up an app on your Yahoo account to allow access. Follow the step-by-step guide below for instructions on how to do so, or see Getting Started in the Yahoo Developer Network docs for more details.

Note: If you are only planning on using YFPY to pull "read only" data from public leagues, you do not need to do this.


Usage

Authentication

Querying the Yahoo Fantasy Sports API

Docker

YFPY can be used within Docker for a more seamless, platform-agnostic experience.

Docker Development (optional)
Docker Image Deployment

See DEPLOYMENT.md for Docker image deployment.


Testing

YFPY has a collection of fully functional code snippets that can be run using pytest. These snippets demonstrate how to use YFPY to retrieve your Yahoo Fantasy Sports data.

Unit

Integration

Running


Dependencies

Platform

YFPY has only been tested extensively on macOS, but is written to be platform-agnostic, and seems to work without issue on Windows and Linux.

Python

YFPY requires Python 3.8 or later, and has been tested through Python 3.11.

Development

Direct project dependencies can be viewed in requirements.txt, and additional development and build dependencies (not including transitive dependencies) can be viewed in requirements-dev.txt.


Troubleshooting

Yahoo Fantasy Sports API

Occasionally when you use the Yahoo Fantasy Sports API, there are hangups on the other end that can cause data not to transmit, and you might encounter an error similar to this:

Traceback (most recent call last):
  File "yfpy-app.py", line 114, in <module>
    var = app.run()
  File "/Users/your_username/PATH/T0/LOCAL/PROJECT/yfpy-app.py", line 429, in run
    for team in team_standings:
IndexError: list index out of range

Typically, when the above error (or a similar error) occurs, it simply means that one of the Yahoo Fantasy Sports API calls failed and so no data was retrieved. This can be fixed by simply re-running data query.