Skip to main content
leeger logo

Instant stats for any fantasy football league.

PyPi Version
Last Commit
End-to-end Tests Unit Tests Formatting Check

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:

  • A tab for each year with team stats
  • A tab for each year with matchup info
  • A tab for all-time with team stats
  • A tab for all-time with matchup info
  • A tab for all-time with owner stats


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

  • Download the latest supported version of Python here.
  • Currently, Python version 3.10+ is supported

2. Create a basic Python file to use this library

  • Create a file that ends in the extension ".py"
    • Example: my_script.py

3. Download this library

  • Navigate in your terminal to the directory where you created your Python script in Step 2
  • Run the command pip install leeger
    • If you do not have pip installed, you will need to install it

4. Download your league data using a league loader

  • Find the site/s you use for fantasy football here
  • Follow the Setup Documentation
  • Once you have everything you need for your selected site/s, use the code examples found here for your specific site/s to download your league data
    • You can put the code inside the Python script you created in Step 2
  • If you have leagues that are continued in multiple sites, you can pull from multiple sites and add the League objects together to combine the different sites
    • An example of this can be found here

5. Run your script

  • Navigate in your terminal to the directory where you created your Python script in Step 2
  • Run the command py my_script.py
    • Replace my_script.py with whatever you named your script in Step 2

6. Load your league stats into Excel

  • Slightly alter your script from Step 2 to include a function call to load your league stats into Excel
  • Follow this example
  • Make sure that you are passing the League object that you pulled from the league loader/s into the function call to put your 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

  • Format Code: make fmt
  • Run Unit Tests: make test

License

MIT

Credit

Release files for leeger 2.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leeger 2.7.0
File Size Uploaded
leeger-2.7.0.tar.gz 145.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for leeger 2.7.0
File Interpreter ABI Platform
leeger-2.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 365.4 kB

Release files / leeger-2.7.0.tar.gz

Download URL leeger-2.7.0.tar.gz
Size 145.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9d9937885ef108886b8f623e740a29874dbaae965e20f6ec317bcff3b69a816b
BLAKE2b-256 checksum
How to use checksums
a95259a122a5bcb8d44fb25d79f3d982d652cb863dbd618fb0fd9fd00eac25ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.16

Release files / leeger-2.7.0-py3-none-any.whl

Download URL leeger-2.7.0-py3-none-any.whl
Size 220.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a01f91c15a9ad03fa7109b8982cf005433fd5550ab5182ff568aa4d624df9988
BLAKE2b-256 checksum
How to use checksums
3bba4667a2c6b0a8c94a52ea2a9a6af6d7900ee769ac7ca496c671aa98559783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.16

Release history Release notifications | RSS feed

This release

2.7.0 This release

2 release files

2.6.5

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.5

2 release files

2.5.4

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

1 release file

2.5.0

1 release file

2.4.0

1 release file

2.3.0

1 release file

2.2.0

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.0

1 release file

1.15.0

1 release file

1.14.0

1 release file

1.13.1

1 release file

1.13.0

1 release file

1.12.1

1 release file

1.12.0

1 release file

1.11.0

1 release file

1.10.0

1 release file

1.9.0

1 release file

1.8.0

1 release file

1.7.0

1 release file

1.6.1

1 release file

1.6.0

1 release file

1.5.0

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.18.0

1 release file

0.17.0

1 release file

0.16.0

1 release file

0.15.0

1 release file

0.14.0

1 release file

0.13.0

1 release file

0.12.0

1 release file

0.11.0

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page