STAT-API

See where a player's fantasy points came from

A fantasy score is a sum, and the parts are what you can model. dfs.player_stats publishes every scoring category as its own column: passing_yds_fpts, rushing_td_fpts, reception_fpts, and 23 more. The raw box-score numbers sit beside them, so you can check the arithmetic yourself. Nothing is nested in JSON, and nothing needs parsing.

  1. 1. Read one player's slate history

    player_id is a standalone filter, so one player's rows across every slate come back in a single call. Player 301 is a quarterback, whose score splits across the most categories — take any id from the salary-board recipe.

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/dfs/player_stats?limit=200&player_id=301'
  2. 2. Keep the games that were played

    const played = rows.filter((row) => row.fantasy_pts !== null && row.fantasy_pts !== undefined)
  3. 3. Best game first

    const best = [...played].sort((a, b) => (b.fantasy_pts ?? 0) - (a.fantasy_pts ?? 0))
  4. 4. Take the single best game

    const top = best.slice(0, 1)
  5. 5. Split the score into its categories

    The category columns sum to fantasy_pts. Compare them against the raw columns on the same row — passing_yds, rushing_tds, receptions — to see exactly which rule produced which points.

    console.log("Where the points came from")
    console.log(["fantasy_pts", "passing_yds_fpts", "passing_td_fpts", "rushing_yds_fpts", "rushing_td_fpts", "receiving_yds_fpts", "reception_fpts"].join('\t'))
    for (const row of top) {
      console.log([String(row.fantasy_pts ?? ''), String(row.passing_yds_fpts ?? ''), String(row.passing_td_fpts ?? ''), String(row.rushing_yds_fpts ?? ''), String(row.rushing_td_fpts ?? ''), String(row.receiving_yds_fpts ?? ''), String(row.reception_fpts ?? '')].join('\t'))
    }
  6. 6. Compare against the raw box score

    The same row carries the underlying yardage and touchdown counts.

    console.log("The raw stats behind those points")
    console.log(["passing_yds", "passing_tds", "rushing_yds", "rushing_tds", "receptions", "receiving_yds", "receiving_tds"].join('\t'))
    for (const row of top) {
      console.log([String(row.passing_yds ?? ''), String(row.passing_tds ?? ''), String(row.rushing_yds ?? ''), String(row.rushing_tds ?? ''), String(row.receptions ?? ''), String(row.receiving_yds ?? ''), String(row.receiving_tds ?? '')].join('\t'))
    }