Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
Python API wrapper for the Yahoo Fantasy Sports public API
Author: Wren J. R. (uberfastman)
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.
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).
If you wish to use YFPY within another project, from within your project directory, run
pip install yfpy
or add yfpy
to your project requirements.txt
.
git clone git@github.com:uberfastman/yfpy.git
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.
Application Name
(Required): yfpy
(you can name your app whatever you want, but this is just an example).Application Type
(Required): select the Installed Application
radio button.Description
(Optional): you may write a short description of what the app does.Home Page URL
(Optional): if you have a web address related to your app you may add it here.Redirect URI(s)
(Required): this field must contain a valid redirect address, so you can use https://localhost:8080
API Permissions
(Required): check the Fantasy Sports
checkbox. You can leave the Read
option selected (appears in an accordion expansion underneath the Fantasy Sports
checkbox once you select it).Create App
button.Client ID
and a Client Secret
.auth/private.template.json
, rename it to just private.json
, and copy the Client ID
and Client Secret
values to their respective fields (make sure the strings are wrapped regular quotes (""
), NOT formatted quotes (“”
)). The path to this file will be needed to point YFPY to your credentials.token.json
for you in the same directory where you stored your private.json
credentials, and for all subsequent runs of your app, you should be able to keep retrieving Yahoo fantasy sports data using YFPY without re-verifying, since the generated refresh token should now just renew whenever you use the same token.json
file to authenticate your app.yfpy.query.YahooFantasySportsQuery
class for example usage of all available queries.quickstart/quickstart.py
for example usage output.
RUN QUERIES
section you wish to run.CHECK FOR MISSING DATA FIELDS
section you wish to check for any new/missing data fields returned by the Yahoo Sports Fantasy Football API.YFPY can be used within Docker for a more seamless, platform-agnostic experience.
docker compose up
docker exec -it yfpy-package-1 bash
Then:
python quickstart/quickstart.py
docker exec -i yfpy-package-1 bash -c "python quickstart/quickstart.py"
docker compose -f compose.yaml -f compose.dev.yaml up
See DEPLOYMENT.md for Docker image deployment.
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.
test/unit
directory for example code snippets using pytest.test/integration
directory for example code snippets using pytest.auth/.env.template
in the auth/
directory and rename it to .env
.Client ID
and Client Secret
into the environment variables in .env
so that pytest can use them when hitting the Yahoo Fantasy Sports API.-s
flag.test/integration/conftest.py
are defined in quickstart/quickstart.py
, and can be changed for testing by uncommenting/commenting out the values inside each respective function.pytest -v -s
pytest -v -s -m unit
pytest -v -s -m integration
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.
YFPY requires Python 3.8 or later, and has been tested through Python 3.11.
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
.
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.
FAQs
Python API wrapper for the Yahoo Fantasy Sports public API.
We found that yfpy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.