Yahoo Fantasy Baseball
Query your Yahoo Fantasy Baseball league: view data and optimize your daily lineup via the Yahoo Fantasy Sports API. Read-only — no roster modifications are made.
Requirements
- - Python 3.10+
- INLINECODE0 — Yahoo Fantasy Sports API wrapper
Installation: Before first use, run --setup to create a local .deps/ virtual environment and install dependencies from requirements.txt. Subsequent runs reuse the existing venv. To force a clean reinstall, delete the .deps/ directory and run --setup again.
CODEBLOCK0
Setup
1. Create a Yahoo Developer App
- 1. Go to https://developer.yahoo.com/apps/
- Click "Create an App"
- Set Redirect URI to
oob (out-of-band — Yahoo displays the auth code on screen instead of redirecting to a URL) - Copy the Consumer Key and Consumer Secret
2. Authenticate
CODEBLOCK1
Follow the prompts to enter your Consumer Key and Secret. A browser window opens for Yahoo OAuth authorization. Tokens are cached automatically — you only need to do this once.
3. Find Your League
CODEBLOCK2
4. Set Defaults
CODEBLOCK3
The skill auto-detects your team within the league. You can also set it explicitly:
CODEBLOCK4
Quick Start
CODEBLOCK5
Commands
Data Commands (Read)
CODEBLOCK6
Daily Management
CODEBLOCK7
Groups your roster into ACTIVE (team playing), NOT PLAYING (team off), INJURED, and BENCH. Shows each player's eligible positions, game start times (local timezone), and flags probable starting pitchers. Displays "First pitch" time at the top so you know when to finalize your lineup. The today command is a shortcut for day with today's date.
CODEBLOCK8
Fetches daily player stats for all rostered players across every team in the league and identifies standout performances. Output is split into two sections:
- 1. Top Performers — players in active lineup slots who scored the most fantasy points
- Left on the Bench — benched players with notable performances (points that didn't count)
Each player shows their fantasy points, key stat line, and achievement badges (e.g., "Multi-HR", "10+ K", "Gem", "CGSO"). Defaults to yesterday; use --date for a specific date.
CODEBLOCK9
Cross-references active fantasy roster players against confirmed MLB batting lineups (from MLB Stats API hydrate=lineups). Flags position players who are in a starting fantasy slot but NOT in their team's confirmed real-life lineup (e.g., scratched, resting, benched vs lefty/righty). Pitchers are excluded (they don't appear in batting lineups). Players whose team's lineup hasn't been posted are NOT flagged — only players whose lineup IS posted and who are absent. Lineups are typically posted 1-3 hours before game time.
CODEBLOCK10
Three analysis categories:
- 1. Lineup changes — optimal batter assignment via constraint solver (position-aware, fills restrictive slots before UTIL). Outputs grouped swap instructions showing who starts, who gets benched, and any intermediate position reshuffles needed (e.g., a UTIL player sliding to 1B to make room). Also checks confirmed MLB batting lineups — players confirmed not in their team's lineup are treated as unavailable (score 0) and will be moved to bench. Players whose games have already started are locked in place (Yahoo locks roster slots at first pitch) and excluded from the solver.
- Pitcher rotation — probable starters on bench, active pitchers on off days. Only alerts for games that haven't started yet.
- IL management — players with IL designations (IL, IL10, IL15, IL60) not in IL slots, cleared players still in IL. DTD players are excluded since Yahoo does not allow moving them to IL.
Each move includes team, opponent, and score context. Moves to BN may include a reason indicator:
- -
⚠️ — player not in confirmed MLB lineup (urgent — they won't play) - INLINECODE13 — player's game has already started (locked by Yahoo)
- INLINECODE14 — player's team is off today
Early-season preseason rank blending: The optimizer blends Yahoo's preseason overall rank (OR) into player scores during the first weeks of the season, when current-year stats are too small a sample to be reliable. The blending schedule:
- - Weeks 1–2: Full weight — preseason rank contributes up to 15 bonus points (rank 1 gets the max, last-ranked gets 0)
- Weeks 3–6: Linear taper — preseason influence decreases by ~20% per week
- Week 7+: Zero weight — scoring is based entirely on current-season stats
This prevents the optimizer from overreacting to small early-season slumps (e.g., benching a star who went 0-for-8 in the first series). The preseason ranks are fetched via one additional Yahoo API call (sort=OR, status=T) per optimize run.
Common Flags
| Flag | Description |
|---|
| INLINECODE16 | League ID (overrides config default) |
| INLINECODE17 |
Team ID (overrides config/auto-detect) |
|
--season YEAR | Season year (for historical data) |
|
--week N | Scoring week number |
|
--date | Specific date — accepts MM/DD/YYYY, M/D/YYYY, MM-DD-YYYY, or YYYY-MM-DD (roster, day commands) |
|
--format text\|json\|discord | Output format (default: text) |
|
--status FA\|A\|T\|W\|ALL | Player status filter: FA (free agents), A (available=FA+W), T (taken), W (waivers), ALL (every player) |
|
--sort OR\|AR\|PTS\|NAME\|{stat} | Sort order: OR = overall/preseason rank (default), AR = actual/current rank, PTS = points, NAME = alphabetical, or stat abbreviation. See stat sort reference below |
|
--sort-type season\|lastweek\|lastmonth | Sort period (used with --sort) |
|
--stat-season YEAR | Season year for stat columns (auto-detects: falls back to previous year if league hasn't started) |
|
--since 3d\|1w\|24h\|2w | Filter transactions by time window (h=hours, d=days, w=weeks, m=months) |
Sort Reference
Built-in sort modes:
| Value | Description |
|---|
| INLINECODE27 | Overall Rank (preseason/projected) |
| INLINECODE28 |
Actual Rank (by real performance) |
|
PTS | Fantasy Points |
|
NAME | Alphabetical |
Batting stats:
| Abbrev | Description |
|---|
| INLINECODE31 | Runs |
| INLINECODE32 |
Hits |
|
1B | Singles |
|
2B | Doubles |
|
3B | Triples |
|
HR | Home Runs |
|
RBI | Runs Batted In |
|
SB | Stolen Bases |
|
BB | Walks |
|
K | Strikeouts |
|
AVG | Batting Average |
|
OBP | On-base Percentage |
|
SLG | Slugging Percentage |
|
OPS | On-base + Slugging |
|
AB | At Bats |
|
PA | Plate Appearances |
|
TB | Total Bases |
|
XBH | Extra Base Hits |
Pitching stats:
| Abbrev | Description |
|---|
| INLINECODE49 | Wins |
| INLINECODE50 |
Losses |
|
SV | Saves |
|
HLD | Holds |
|
SV+H | Saves + Holds |
|
BSV | Blown Saves |
|
ERA | Earned Run Average |
|
WHIP | Walks + Hits per Inning Pitched |
|
IP | Innings Pitched |
|
QS | Quality Starts |
|
K9 | Strikeouts per 9 Innings |
|
BB9 | Walks per 9 Innings |
Output Format
Text (Default)
roster:
CODEBLOCK11
today / day:
CODEBLOCK12
optimize:
CODEBLOCK13
Players on teams whose games are already in progress or finished are locked and excluded from optimization — they will not appear in the move list.
scoreboard:
CODEBLOCK14
transactions:
CODEBLOCK15
JSON
All commands support --format json for structured output.
Discord
All commands support --format discord which wraps text output in code blocks.
Output Fields
- - name — Player's full name
- playerid — Yahoo player ID (numeric)
- positions — Eligible fantasy positions (e.g., OF, SP, Util)
- selectedposition — Current lineup slot
- team — Real MLB team abbreviation
- status — Injury designation (IL, IL-60, DTD, etc.)
- gametime — Game start time in local timezone (today/day commands)
- firstpitch — Earliest game start time across all games (today/day commands, JSON top-level)
- percentowned — Ownership percentage (free agents)
- playerposition — Display position (draft results)
Limitations
- - Rate limits: Yahoo enforces API rate limits. Avoid rapid-fire requests.
- Season scope: Data is scoped to the configured season. Use
--season for historical data. - OAuth tokens: Tokens auto-refresh but may eventually expire, requiring re-authentication via
auth. - MLB schedule: The
today, day, optimize, and lineup-check commands use the MLB Stats API for schedule data (off days, probable pitchers, confirmed batting lineups). This data is not available from the Yahoo Fantasy API.
Credential Storage
Preferred: Environment variables. Set YAHOO_CONSUMER_KEY and YAHOO_CONSUMER_SECRET via OpenClaw config or your shell environment. The skill will use these automatically — no need to run auth. Note: credentials are still written to oauth2.json on disk because the underlying yahoo_oauth library requires a file for token management. File permissions are set to 0600 on Unix.
Alternative: Interactive setup. Run the auth command to enter credentials interactively. Tokens are stored in ~/.openclaw/credentials/yahoo-fantasy/:
- -
oauth2.json — OAuth consumer key/secret and tokens (managed by yahoooauth, file permissions set to 0600 on Unix) - INLINECODE77 — Default leagueid, team_id, season
Legacy YFPY .env credentials are auto-migrated to oauth2.json on first use.
Notes
- - Data is sourced from the Yahoo Fantasy Sports API via the yahoo-fantasy-api library.
- MLB schedule and probable pitcher data comes from the MLB Stats API (stdlib only, no dependencies).
- Run
--setup to create a local venv at .deps/ and install dependencies before first use. - Auto-detect identifies your team using
league.team_key(). If detection fails, use config --team <ID> to set it manually.
Yahoo Fantasy Baseball
通过Yahoo Fantasy Sports API查询您的Yahoo Fantasy棒球联盟:查看数据并优化每日阵容。只读模式——不进行阵容修改。
系统要求
- - Python 3.10+
- yahoofantasyapi — Yahoo Fantasy Sports API封装库
安装: 首次使用前,运行--setup创建本地.deps/虚拟环境并从requirements.txt安装依赖。后续运行会复用现有虚拟环境。如需强制重新安装,请删除.deps/目录后再次运行--setup。
bash
python3 yahoo-fantasy-baseball.py --setup
设置
1. 创建Yahoo开发者应用
- 1. 访问 https://developer.yahoo.com/apps/
- 点击创建应用
- 将重定向URI设置为oob(带外模式——Yahoo会在屏幕上显示授权码而非重定向到URL)
- 复制消费者密钥和消费者密钥密文
2. 身份验证
bash
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py auth
按照提示输入您的消费者密钥和密文。浏览器窗口将打开进行Yahoo OAuth授权。令牌会自动缓存——只需执行此操作一次。
3. 查找您的联盟
bash
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py leagues
4. 设置默认值
bash
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py config --league 12345
该技能会自动检测您在联盟中的球队。您也可以显式设置:
bash
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py config --league 12345 --team 3
快速开始
bash
查看您的阵容
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py roster
每日阵容状态(谁在比赛,谁休息)
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py today
指定日期的阵容状态
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py day --date 2026-03-25
获取优化建议
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py optimize
联盟排名
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py standings
命令
数据命令(只读)
bash
身份验证与配置
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py auth
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py config --league 12345 --team 3 --season 2026
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py config
联盟与球队
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py leagues [--season YEAR]
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py teams
阵容与打线
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py roster [--date YYYY-MM-DD]
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py lineup [--week N]
排名与对阵
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py standings
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py matchup [--week N]
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py scoreboard [--week N]
球员与选秀
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py players [--search NAME] [--position POS] [--status FA|A|T|W|ALL] [--sort OR|AR|PTS|NAME|HR|ERA|...] [--sort-type season|lastweek|lastmonth] [--stat-season YEAR] [--count N]
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py draft [--team ID]
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py transactions [--type add,drop,trade] [--since 3d]
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py injuries
打线检查 — 确认的MLB打线与梦幻阵容对比
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py lineup-check [--date YYYY-MM-DD]
日常管理
bash
今日:带MLB赛程感知的阵容状态(day命令的快捷方式,默认使用今天日期)
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py today
指定日期:指定日期的阵容状态
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py day --date 2026-03-25
将您的阵容分组为:活跃(球队在比赛)、未比赛(球队休息)、受伤和替补。显示每位球员的合格位置、比赛开始时间(本地时区),并标记可能的先发投手。顶部显示首球时间,以便您知道何时最终确定阵容。today命令是day命令的快捷方式,默认使用今天日期。
bash
杰出表现:昨天所有联盟球队中的最佳表现者
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py standouts [--date YYYY-MM-DD] [--min-points N] [--count N]
获取联盟中每支球队所有在册球员的每日球员数据,并识别出杰出表现。输出分为两个部分:
- 1. 最佳表现者 — 活跃阵容位置中获得最多梦幻积分的球员
- 替补遗珠 — 替补席上有显著表现的球员(未计入的积分)
每位球员显示其梦幻积分、关键数据线和成就徽章(例如多轰、10+ K、宝石、完封)。默认显示昨天数据;使用--date指定具体日期。
bash
打线检查:验证活跃球员是否在确认的MLB打线中
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py lineup-check
python3 /home/claw/.openclaw/workspace/skills/yahoo-fantasy-baseball/yahoo-fantasy-baseball.py lineup-check --date 2026-04-01
将活跃梦幻阵容球员与确认的MLB击球打线(来自MLB Stats API hydrate=lineups)进行交叉比对。标记那些在梦幻先发阵容中但不在其球队确认的真实打线中的位置球员(例如,被划掉、休息、因左/右投手被替补)。投手被排除在外(他们不出现在击球打线中)。球队打线尚未公布的球员不会被标记——仅标记那些打线已公布但缺席的球员。打线通常在比赛开始前1-3小时公布。
bash
优化:带建议的智能阵容分析