A Nix flake-based project for analyzing ESPN Fantasy Football data using the ESPN Fantasy Football API.
- Nix with flakes enabled
- An ESPN Fantasy Football league ID
- (Optional) ESPN cookies for private leagues
nix developThis will set up a Node.js environment with all necessary dependencies.
npm installSet your ESPN league ID as an environment variable:
export ESPN_LEAGUE_ID=123456npm start
# or
node src/index.jsIf your league is private, you'll need to provide ESPN authentication cookies:
- Open your browser and go to espn.com
- Log in to your ESPN account
- Open Developer Tools (F12)
- Go to Application > Cookies > https://espn.com
- Find and copy the values for:
espn_s2SWID
Set them as environment variables:
export ESPN_LEAGUE_ID=123456
export ESPN_S2="your_espn_s2_cookie_value_here"
export ESPN_SWID="your_swid_cookie_value_here"
npm startOr create a .env file (make sure it's in .gitignore):
ESPN_LEAGUE_ID=123456
ESPN_S2=your_espn_s2_cookie_value_here
ESPN_SWID=your_swid_cookie_value_here.
├── flake.nix # Nix flake configuration
├── package.json # Node.js dependencies
├── src/
│ └── index.js # Main application code
└── README.md # This file
The development shell includes:
- Node.js 20
- npm package manager
All dependencies are managed through Nix, ensuring reproducible builds across different systems.
To build the project as a Nix package:
nix buildThis creates a result symlink to the built package.
For detailed API documentation and available methods, see the ESPN Fantasy Football API repository.
Common methods you might want to use:
client.getLeagueInfo()- Get league informationclient.getTeams()- Get all teams in the leagueclient.getBoxscoreForWeek(week)- Get boxscores for a specific weekclient.getFreeAgents()- Get available free agents
MIT