This project provides tools and an AI-powered agent to help you dominate your Yahoo Fantasy Hockey league:
To use the Yahoo Fantasy API, you need to create a Yahoo Developer application:
- Go to Yahoo Developer Apps
- Sign in with your Yahoo account
- Click "Create an App"
- Fill in the application details
- Click "Create App"
- You'll receive a Client ID and Client Secret - save these!
To find your league ID:
- Go to your Yahoo Fantasy Hockey league
- Look at the URL - it should look like:
https://hockey.fantasysports.yahoo.com/hockey/12345 - The number at the end (e.g.,
12345) is your League ID
-
Copy the example environment file:
cp .env.example .env
-
Edit
.envand add your credentials:YAHOO_CLIENT_ID=your_client_id_from_step_1 YAHOO_CLIENT_SECRET=your_client_secret_from_step_1 LEAGUE_ID=your_league_id_from_step_2 GAME_KEY=nhl
- Go to Anthropic Console
- Sign up or log in
- Navigate to API Keys
- Create a new API key
- Add it to your
.envfile asANTHROPIC_API_KEY
The AI agent sends recommendations via email.
Option A: Mailtrap (Recommended for Testing)
Mailtrap captures emails without sending them - perfect for testing:
- Go to Mailtrap.io and create a free account
- Create an inbox or use the default one
- Click on your inbox and go to "SMTP Settings"
- Copy the credentials and add to your
.envfile:EMAIL_FROM=test@example.com # Can be any email EMAIL_TO=recipient@example.com # Can be any email EMAIL_PASSWORD=your_mailtrap_password SMTP_SERVER=sandbox.smtp.mailtrap.io SMTP_PORT=2525 - View captured emails in your Mailtrap inbox
Option B: Gmail (For Real Emails)
- Enable 2-factor authentication on your Google account
- Generate an App Password:
- Go to Google App Passwords
- Select "Mail" and your device
- Copy the generated password
- Add to your
.envfile:EMAIL_FROM=your_email@gmail.com EMAIL_TO=your_email@gmail.com EMAIL_PASSWORD=your_gmail_app_password SMTP_SERVER=smtp.gmail.com SMTP_PORT=587
Install all required packages:
# Install dependencies
uv syncBoth scripts require Yahoo OAuth authentication:
# Run either script for first-time authentication
uv run python get_available_players.pyFirst Run: The first time you run the script, it will:
- Open a browser window for Yahoo OAuth authentication
- Ask you to log in to Yahoo and authorize the application
- Redirect to your redirect URI with an authorization code
- You may need to copy the full URL from the browser and paste it back into the terminal
- Save the access token for future use (in
token.json)
Subsequent Runs: Both scripts will use the saved token automatically.
# Run the agent
uv run python fantasy_hockey_agent.py# Default: prefetch enabled
uv run python fantasy_hockey_agent.py
# Disable prefetch (Uses cached data -- useful for testing)
uv run python fantasy_hockey_agent.py --skip-prefetch
# Do a dry run (Does not make any WRITE operations like sending email or saving recommendations)
uv run python fantasy_hockey_agent.py --dry-runThis is a personal project, but feel free to fork and customize for your needs!
This project is for personal use. Please respect Yahoo's API terms of service and rate limits.