joeyagreco / leeger

Instant stats for any fantasy football league.
https://pypi.org/project/leeger
MIT License
57 stars 17 forks source link
espn espn-fantasy-api espn-fantasy-football fantasy-football fantasy-football-api fleaflicker fleaflicker-fantasy-api fleaflicker-fantasy-football football myfantasyleague nfl sleeper sleeper-fantasy-api sleeper-fantasy-football statistical-analysis statistics stats yahoo yahoo-fantasy-api yahoo-fantasy-football
leeger logo Instant stats for any fantasy football league. [![PyPi Version](https://img.shields.io/pypi/v/leeger)](https://pypi.org/project/leeger/)
![Last Commit](https://img.shields.io/github/last-commit/joeyagreco/leeger)
![End-to-end Tests](https://github.com/joeyagreco/leeger/actions/workflows/e2e-tests.yml/badge.svg) ![Unit Tests](https://github.com/joeyagreco/leeger/actions/workflows/unit-tests.yml/badge.svg) ![Formatting Check](https://github.com/joeyagreco/leeger/actions/workflows/formatting-check.yml/badge.svg)

Table of Contents

Overview

This library allows you to take data from an existing fantasy football league and get instant stats from that league into either a Python script or an Excel spreadsheet.\ \ This library supports multiple fantasy sites AND manual league data input.\ \ Python stats will be stored in these objects:

Excel sheets will include:

\ The main idea behind this library is:

  1. Load stats into a League object
  2. Pass this League object into various library methods to extract stats

\ For guides on how to use this library, see the information under Supported League Loaders and in the example folder.

Quickstart Guide

1. Download Python

2. Create a basic Python file to use this library

3. Download this library

4. Download your league data using a league loader

5. Run your script

6. Load your league stats into Excel

FAQ

Question: I'm getting this error when I run my script:

TypeError: dataclass() got an unexpected keyword argument 'kw_only'

Answer: This error occurs when the Python version you are using is not 3.10 or greater.\ Make sure you are using Python version 3.10 or a newer version.


Q: How do I use this library to pull stats from my online fantasy league?

A:

  1. Find your fantasy site here and ensure you have everything you need for the site you are using
  2. Follow the example code snippets for your fantasy site to load the League object

Q: How can I get stats into Excel once I have my League object?

A: Follow this example code.


Q: Can I combine years from different fantasy sites that are loaded as separate League objects into a single League object?

A: Yes, the League object supports addition (+) to combine multiple league objects.\ An example of this can be found here.


Q: Can I disable validation on my League object?

A: Yes. While it is not recommended that you disable this, as validation ensures the stats are calculated properly, disabling validation can be done by passing validate=False into any method that takes a League object OR any loadLeague() method from a League Loader.

Installation

Use the package manager pip to install.

pip install leeger

Supported League Loaders

Sites that you can automatically load your league data from.

Name Website Supported Setup Documentation
ESPN https://www.espn.com/fantasy/football/ :heavy_check_mark: ESPN :page_facing_up:
Fleaflicker https://www.fleaflicker.com/ :heavy_check_mark: Fleaflicker :page_facing_up:
MyFantasyLeague http://home.myfantasyleague.com/ :heavy_check_mark: MyFantasyLeague :page_facing_up:
NFL https://fantasy.nfl.com/ :x: :x:
Sleeper https://sleeper.com/fantasy-football/ :heavy_check_mark: Sleeper :page_facing_up:
Yahoo https://football.fantasysports.yahoo.com/ :heavy_check_mark: Yahoo :page_facing_up:

If a fantasy site you use is not listed here and you would like it to be, please open an issue.

Stats Explained

Stats used in this library are documented here.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Development

Run these commands from the root folder

License

MIT

Credit