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.
Until all raw SQL is converted to ORM, this will only work with PostgreSQL, but you can modify the queries in query.py to work with other databases supported by SQLAlchemy.
- 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 PostgreSQL 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.
cp .env.sample .env
Edit .env
and replace POSTGRES_PASSWORD
with your preferred password.
docker-compose up -d
Open browser to http://localhost:5000.
To set up the database the first time, you can run the following command:
docker-compose run espn-ffb sh ./setup.sh
docker-compose run 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!