This site uses one functional cookie to keep feature rollouts consistent for you. Nothing is set until you choose. See the privacy notice.
Dev notes
Head-to-head matchups for my ESPN fantasy football league: team scores, each starter's actual and projected points, and a win probability that ESPN's API doesn't give you — so I built one.
The NBA matchups page compares seven stat categories per team and counts who won more of them. NFL fantasy is a single number: total points scored by the active roster for the week. That collapses the team-level comparison to one bar, but it pushes all the interesting detail down to the player level — sixteen starters per side, each with an actual score and a projection, rather than seven category totals.
ESPN's fantasy football endpoint takes scoringPeriodId as the week number, and rosterForCurrentScoringPeriod only carries stats for whatever period you asked for. Omit the param entirely and ESPN defaults to the league's current week — which turned out to be the better design than guessing at it client-side.
My first pass estimated the live NFL week from the calendar date, then self-corrected once the real scoreboard loaded — a useEffect that called setWeek when the guess and the server disagreed. react-hooks/set-state-in-effect flagged it, and the fix was better than a workaround: the API already tells you the current week when you don't ask for a specific one, so there was never a reason to guess. The selected week is now either the visitor's explicit choice or null, and null means read the answer off the payload's status.currentMatchupPeriod.
There's no fantasy win-probability field anywhere in the payload. The closest thing already in the codebase is impliedProbability on the ZeroProof betting board, which turns an American price into a 0–1 probability. A fantasy matchup has no price, so I built the equivalent from what a matchup does have: each side's current score plus what its unfinished starters are still projected to add. The margin between those two projected finals feeds a normal-CDF approximation whose spread widens with how many points are still unplayed — a lead means less on Monday morning than it does once Sunday's games are done.
There's no dataset of "this matchup was actually a 62% favorite" to check the model against, so the tests pin invariants instead of exact numbers: equal projections split 50/50, a settled matchup with any lead reads near-certain, and swapping home and away complements the result. The test that actually verifies the design intent compares two matchups with the identical projected margin — one with most of the week's points still unplayed, one with almost none — and asserts the early one sits closer to a coin flip. That's the property the whole model exists to have.
A live ticker of the plays contributing to each score was out of scope for this PR. It needed a second, unrelated ESPN surface — the public game-summary API rather than the fantasy league endpoint — and it's only meaningful while games are live, which makes it harder to verify than everything else here. Shipping the scores and win probability first, and building the ticker as its own stacked PR, kept this one small enough to actually finish. It shipped shortly after — see the update below.
Update — Sept 22, 2026
Shipped as a stacked follow-up, and it landed simpler than the plan for it described.
The original plan for this ticker said each play would carry the fantasy points it contributed — "+6.4 pts" next to the play text. Once I actually looked at what ESPN's public game-summary API returns, that number doesn't exist anywhere upstream. Computing it would mean re-implementing my league's entire scoring-rule table (points per passing yard, per rushing touchdown, per reception, and so on) against each play's raw stat line — a second scoring engine, running client-side, that could silently drift from the number ESPN's own fantasy API already reports. That's a worse trade than just not having the number.
What shipped instead: the real play text ESPN already writes — "Dyami Brown 9 Yd pass from Trevor Lawrence (Cam Little Kick)" — tagged with whichever fantasy team rosters the player it mentions. Attribution is a plain substring match against each starter's exact name, not a player-id join, because the play-by-play text carries names, not ids. It's honest about what it is: the actual event, not a derived number I'd have to keep in sync with ESPN's.
Q1 10:51 TD Dyami Brown 9 Yd pass from Trevor Lawrence (Cam Little Kick)
Paul's Perfect TeamThe scoring-play feed lives on a completely different ESPN host (site.api.espn.com) from the fantasy league endpoint, and it identifies teams by abbreviation, not the fantasy payload's numeric proTeamId. I expected to need a lookup table hand-built from a reference site. Instead the public site API's own team-list endpoint uses the identical numbering — id 4 is CIN on both surfaces, confirmed against a real rostered Bengals player — so the map is just those 32 pairs, not a scraped or guessed table.
Update — October 2, 2026
The projected finals on this page had been reading high for a few weeks. Chasing that down turned into a fix, a rework of the plays ticker, and a second tab: a trade analyzer that needed the fixed projections before it was worth building.
My first suspect was the source. Some players carry two week-4 lines in the payload, and one of Quinshon Judkins' read 21.6 against a 12.5 projection, which looked like a double-counted or stale projection being picked up by afind that grabs whichever comes first. It wasn't. The second line isstatSourceId: 0, Thursday night's actual, and the reader already filters on source.
{ id: "1120264", statSourceId: 1, statSplitTypeId: 1, appliedTotal: 12.47 } <- projection
{ id: "01401872964", statSourceId: 0, statSplitTypeId: 1, appliedTotal: 21.6 } <- TNF actualA side's remaining projection was every starter'smax(0, projected - actual), whether or not their game was over. A receiver projected for 15 who finished with 9 still "owed" 6 points that were never coming. On a finished week every under-performer adds to the total, so the projected final ran well above the real score.
Week 3, Barbarians vs Paul's Perfect Team (final) actual 123.9 - 135.6 projected before 164.5 - 179.8 projected after 123.9 - 135.6
A projection is for a whole game, so a starter can only still earn the share of it their game has left. A new/api/nfl/games route reads the public scoreboard and turns each team's game into that share: all of it before kickoff, the clock's share while it's live, none once it's final or on a bye. A past week skips the call and projects nothing. The live branch is unit-tested, but I haven't watched it against a real in-progress game yet.
The ticker now collapses, filters by position, score type, matchup, NFL team and fantasy team, and a click on a play rings the starters it mentions in the matchup cards and scrolls to the first one. The cards went to one per row so a whole lineup and full names fit. The ring gets a star badge with screen-reader text next to it, so the highlight isn't carried by color alone.
The route's axe scan passed on the first run, in 2.7 seconds, which was too fast. It scans once the page's main landmark appears, before the plays arrive. A scan that waited for the plays and clicked one found what the fast one never saw: my new tint under muted text, and team pills that had been failing in light mode since the ticker first shipped.
color-contrast (serious) <span class="... text-muted">proj 9.2</span> <span class="... rounded-full ... text-[10px] font-semibold ...">Paul's Perfect Team</span>
The trade analyzer scores a trade by each team's best possible starting lineup, week by week, before and after the swap, because two decent backs for one star looks like a win on a sum and is usually a loss on Sunday. The lineup solver fills the narrowest slots first. Order matters once FLEX and OP overlap: give OP first pick and it can take the running back the FLEX slot needed.
slots: QB, FLEX (RB/WR/TE), OP (QB/RB/WR/TE) players: QB 20, QB 9, RB 10 OP first: QB 20 + OP RB 10 + FLEX (nobody) = 30 narrowest: QB 20 + FLEX RB 10 + OP QB 9 = 39
For future weeks I needed a per-game number. ESPN's season-projection stat turned out to be a rest-of-season total: its total divided by its average is the number of games ESPN expects someone to play from now on. That's 14 for a healthy starter after week 3, and fewer for anyone on the injury report.
Jahmyr Gibbs ACTIVE 365.3 / 26.1 = 14 games Breece Hall OUT 212.4 / 16.3 = 13 games
So each future week is that total, minus this week's projection, spread over the games the player's team actually has left, and zero on a bye. Expected missed games come out of the number without me guessing at injury timelines. Strength of schedule is ESPN's points-allowed rank by position for each remaining opponent, 1 the toughest and 32 the softest, shown next to the projections rather than multiplied into them. Three weeks of defense data is too thin to scale anyone's points by.
Update — October 3, 2026
The analyzer needed to handle superflex, PPR against non-PPR, TE premium and positional scarcity. Before building any of it I looked at how KeepTradeCut, FantasyCalc, DynastyProcess and FantasyPros do it. Most of what they do turned out to be workarounds for a problem this page doesn't have.
A trade calculator that gives every player one number has to invent something for a 2-for-1. KeepTradeCut applies a curve relative to the best player in the deal. DynastyProcess has an exponent you can tune. FantasyCalc adds a fixed value for the roster spot. This analyzer already scores each team's actual best lineup before and after, which those curves exist to approximate. What it was missing was the roster spot itself: a 2-for-1 between full rosters forces a drop on one side and opens a waiver pickup on the other. Both are now part of the result, but only for spots the trade itself opens or overfills.
Every projection carries its raw stat line, and scoring that against the league's settings reproduces ESPN's points exactly. So a what-if format doesn't need a multiplier: switching to half PPR takes half a point off each projected reception, and a TE premium adds to tight-end receptions only. Superflex is a lineup slot rather than points, so turning it off just closes the slot.
Kelce, week 4: Σ stats[id] × points[id] = 11.79 = ESPN appliedTotal what-if value = league value + (ppr' - ppr) × rec + [TE] (tep' - tep) × rec
FantasyPros' superflex chart prices quarterbacks at about twice their 1QB value, but that number is calibrated for twelve teams. My league has six, and Kyler Murray is sitting on waivers projected for 247 points over the rest of the season, better than about half the rostered quarterbacks. So scarcity here is measured against the actual waiver wire. A "value over waiver" row counts what each side receives above the best healthy free agent at each position, week by week, net of what it gives up.
The first version filled an opened spot with whichever free agent improved the lineup most. On a real trade (Bijan and McCaffrey for Gibbs) that was a kicker. Upgrading the kicker is worth having, but my team could already do it by cutting a bench player, so the trade didn't cause it. A pickup now has to come from a position the side traded away.
before: Paul's Perfect Team picks up Eddy Pineiro (+18.6) ROS -> +8.1 after: Paul's Perfect Team picks up Jaylen Warren (+3.2) ROS -> -7.3
"Even" also changed from a flat half point to half a point per week. Across thirteen weeks, a flat half point meant almost no trade ever came out even.
Update — October 3, 2026
The live branch of the projected finals still hasn't met a real in-progress game, so its unit tests were the only evidence it worked. I ran Stryker over the clock share, the scoreboard parser and the win probability to find out how much those tests were worth. The full story is on thetesting write-up. Two findings belong here.
Deleting if (period > 4) return 0 broke no test, because the clamp already returns 0 once the quarters left go negative. I removed it, and a 15-minute playoff OT case now pins the behaviour on the clamp. Postponed games got a test too. ESPN marks thempost at period 0, which naive clock math would read as a whole game still to play.
The stat lookup could drop its week check and every test still passed, because every fixture only had one week of stats. ESPN can send a season projection beside the weekly one, and reading that would be the “projections too high” bug again, at around 300 points a game. A fixture with the season line first now catches it. The three files hold a 100% mutation score, and CI re-checks them whenever they change.