espn-ffb is a project to query fantasy football data from ESPN's API and persist it in your own database. There is a very basic web component with a few views built using Flask that allows you to self-host your own fantasy football league page.
It should work with any databases supported by SQLAlchemy. You can change config.py to your respective database URI.
I have only tested with Postgres and the Docker image will also only work with Postgres.
- Recap - desktop, mobile
- Standings - desktop
- Head-to-head records - mobile
- Matchup history - mobile
- Playoffs - desktop
Two modes are supported:
- Run with Docker (easiest)
- Run locally (requires database instance)
- Python3
- PostgreSQL
- uWSGI (optional, but recommended if running in production)
Edit config.py with your own:
- Database credentials in
DevConfig
andProdConfig
. LEAGUE_ID
swid
(private leagues)espn_s2
(private leagues)
To find your swid
and espn_s2
in Chrome, go to DevTools > Application > Cookies > https://fantasy.espn.com.
There is a known issue with mounted volumes on Docker Desktop, so there are a couple additional steps to take.
- Rename
docker-compose.yml.windows
todocker-compose.yml
. - Create the docker volume pgdata.
docker volume create --name=pgdata
Tested and working fine on Windows 10 with PowerShell 7.0.3 and Docker Desktop 2.3.0.5 48029.
cp .env.sample .env
Edit .env
and replace POSTGRES_PASSWORD
with your preferred password.
docker-compose up -d
To set up the database the first time, you can run the following command:
docker-compose exec espn-ffb sh setup.sh
Open browser to http://localhost:5000.
docker-compose exec espn-ffb sh update.sh
If you are running with Docker, stop here.
pip3 install -r requirements.txt
python3 -m espn_ffb.setup -e {dev|prod}
# run with python3
python3 -m espn_ffb.app -e {dev|prod}
# run with uwsgi
uwsgi --http 0.0.0.0:5000 --ini conf/espn-ffb-{dev|prod}.ini
Open browser to http://localhost:5000.
python3 -m espn_ffb.db.update -e {dev|prod}
./gradlew clean build buildDeb -PbuildNumber=local
sudo dpkg -i build/distributions/espn-ffb*.deb
The .deb
package includes two .service
files:
espn-ffb.service
: Starts espn-ffb Flask appespn-ffb-update.service
: Updates espn-ffb database
Sample recap templates as an example of how to structure written recaps.
python3 -m espn_ffb.scripts.generate_recap -e {dev|prod} -y {year} -w {week}
- yorch - Thank you for the Docker support!
- smfarrelly - Thank you for converting the raw SQL to ORM and for the UI redesign!