Analytics & Charts · 2026-11-26 · 7 min read

Building NFL Win Probability Curves and Drive EPA Charts from Play-by-Play JSON

Turn /v1/games/{id}/win-probability and /v1/games/{id}/drives into interactive SVG charts using real 2025 NFL playoff and Super Bowl LX data.

Why final scores and passing yards hide how a game was actually won

Look at four real games from the 2025 NFL postseason in the OpenPigskin archive. In Super Bowl LX (game_nfl_2025_22_SEA_NE, 2026-02-08 at Levi's Stadium), New England's Drake Maye led all passers with 295 yards, yet Seattle won 29–13 with +3.24 team EPA to New England's -12.836 after holding the Patriots scoreless through three quarters (3–0, 9–0, 12–0).

Contrast that with the NFC Championship (game_nfl_2025_21_LA_SEA, 2026-01-25 at Lumen Field): Seattle edged the Los Angeles Rams 31–27 in an offensive fireworks show where both teams topped +14 EPA (SEA +15.352, LA +14.146; Matthew Stafford threw for 374 yards). Meanwhile, the AFC Championship (game_nfl_2025_21_NE_DEN, NE 10–7 DEN) saw negative EPA on both sides (-14.895 vs. -19.009), and in the AFC Divisional round (game_nfl_2025_20_BUF_DEN, DEN 33–30 BUF), Buffalo actually posted slightly higher total EPA (+5.929) than Denver (+5.665) in a three-point loss.

Win probability curves and drive EPA charts make those four very different game scripts immediately legible in a way a box-score table never can.

Fetch the win probability timeline from /v1/games/{id}/win-probability

GET /v1/games/{id}/win-probability (Developer plan and above) strips away non-scrimmage noise and returns an ordered timeline of { play_id, quarter, clock, home_wp, away_wp, epa, posteam, scoring } points, plus meta.away and meta.home abbreviations.

For the NFC Championship (game_nfl_2025_21_LA_SEA), the endpoint returns 144 win-probability points; for Super Bowl LX (game_nfl_2025_22_SEA_NE), it returns 169 points. Every home_wp value is bounded in [0, 1] with away_wp computed as 1 - home_wp rounded to four decimal places.

bash
curl "https://openpigskinapi.com/v1/games/game_nfl_2025_21_LA_SEA/win-probability" \
  -H "Authorization: Bearer op_live_YOUR_KEY"

Render a zero-dependency SVG win probability curve in TypeScript

Because the response is already ordered chronologically and normalized from 0 to 1, rendering a clean win-probability curve requires no heavy charting library — just linear scaling to an SVG viewBox, a dashed 50% midline and highlighted dots wherever scoring is true.

Plotting game_nfl_2025_21_LA_SEA immediately surfaces the two biggest swings of the NFC Championship: play_id 2297 in Q3 (12:17 remaining, a muffed punt recovered by Seattle for +4.474 EPA and +0.1864 WPA, lifting home_wp to 0.6202) and play_id 3753 late in Q4 (4:59 remaining, an incomplete Matthew Stafford pass defended by Devon Witherspoon worth -2.147 EPA and -0.1813 WPA).

typescript
type WinProbPoint = {
  play_id: number;
  quarter: number;
  clock: string | null;
  home_wp: number;
  away_wp: number;
  epa: number | null;
  posteam: string | null;
  scoring: boolean;
};

export function renderWinProbSvg(points: WinProbPoint[], width = 640, height = 220): string {
  if (points.length < 2) return "";
  const pad = 16;
  const xOf = (i: number) => pad + (i / (points.length - 1)) * (width - pad * 2);
  const yOf = (wp: number) => pad + (1 - wp) * (height - pad * 2);

  const polyline = points
    .map((pt, i) => `${xOf(i).toFixed(1)},${yOf(pt.home_wp).toFixed(1)}`)
    .join(" ");

  const scoringDots = points
    .map((pt, i) =>
      pt.scoring
        ? `<circle cx="${xOf(i).toFixed(1)}" cy="${yOf(pt.home_wp).toFixed(1)}" r="4" fill="#ea580c" data-play-id="${pt.play_id}" />`
        : "",
    )
    .join("");

  const midY = yOf(0.5).toFixed(1);
  return `<svg viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">
  <line x1="${pad}" y1="${midY}" x2="${width - pad}" y2="${midY}" stroke="#94a3b8" stroke-dasharray="4 4" />
  <polyline fill="none" stroke="#0f766e" stroke-width="2.5" points="${polyline}" />
  ${scoringDots}
</svg>`;
}

Build drive efficiency bars with /v1/games/{id}/drives

Win probability shows who was ahead; GET /v1/games/{id}/drives explains how each possession moved the needle. Every drive record includes drive, team, team_id, quarter_start, quarter_end, start_yardline_100, end_yardline_100, plays, yards, epa, result, scoring, away_score and home_score.

In Super Bowl LX's 28 drives, the chart tells the entire story at a glance: Seattle stacked positive-EPA field-goal drives early (Drive 1: 7 plays, 51 yards, +1.126 EPA; Drive 14: 9 plays, 69 yards, +2.389 EPA) and capitalized on New England's Q3 turnover (Drive 19: -3.394 EPA) with a 5-play, 37-yard touchdown drive (Drive 20: +3.516 EPA). New England answered with a 3-play, 65-yard touchdown (Drive 21: +5.01 EPA), before a -7.0 EPA opponent-touchdown possession on Drive 25 sealed the 29–13 result.

python
import os
import urllib.request
import json

GAME_ID = "game_nfl_2025_22_SEA_NE"
req = urllib.request.Request(
    f"https://openpigskinapi.com/v1/games/{GAME_ID}/drives",
    headers={"Authorization": f"Bearer {os.environ['OPENPIGSKIN_KEY']}"},
)
with urllib.request.urlopen(req) as resp:
    payload = json.loads(resp.read().decode("utf-8"))

drives = payload["data"]
top_swings = sorted(drives, key=lambda d: abs(d["epa"]), reverse=True)[:5]

for d in top_swings:
    ypp = round(d["yards"] / d["plays"], 2) if d["plays"] else 0.0
    print(
        f"Drive {d['drive']:>2} ({d['team']}, Q{d['quarter_start']}): "
        f"{d['plays']} plays, {d['yards']} yds ({ypp} y/p), "
        f"EPA {d['epa']:+.3f} -> {d['result']} "
        f"[{d['away_score']}-{d['home_score']}]"
    )

Cross-link chart tooltips to snap-level play descriptions on demand

Keep initial page loads light by rendering the SVG from /win-probability and /drives first, then lazy-loading play descriptions when a user clicks a drive bar or scoring marker. Because both endpoints share canonical drive numbers and play_id integers with /v1/games/{id}/plays, clicking Drive 20 in Super Bowl LX maps directly to GET /v1/games/game_nfl_2025_22_SEA_NE/plays?drive=20.

Get a free API key →← All guides