Find the highest-scoring games on a slate
Stacking means rostering several players from one game, and it pays when that game turns into a shootout. dfs.game_stats totals the fantasy points every player in a game produced under the slate's scoring rules, split by side, with the real final score on the same row. Ranking a past slate this way shows which games were worth stacking.
- What it is
- Ranks the games in a slate's pool by the total fantasy points every player in them produced, split home and away.
- When to use it
- Use it to decide which games were worth stacking, to score a game-environment model after the fact, or to correlate fantasy output with real scoring.
- What you get back
- One row per game — the fantasy total, both sides of it, the real final score, and how many players the pool held from that game.
1.Read every game in the slate's pool
An NFL main slate holds 10 to 13 games, so one call covers it. The row id is the slate_game id, not the underlying game id — game_id is a separate column, and it is the one that joins to team and player rows.
const games = (await api.dfs.game_stats.list({ slate_id: 129036, limit: 50 })).game_statsThe complete program
Every step as one runnable file. It reads STAT_API_KEY from the environment, and is the same file that ships in the cookbook project for each SDK.
import { StatApi } from '@stat-api/client'
const api = new StatApi() // reads STAT_API_KEY from the environment
// Read every game in the slate's pool
const games = (await api.dfs.game_stats.list({ slate_id: 129036, limit: 50 })).game_stats
// Keep the games that finished
const played = games.filter((row) => row.total_fpts !== null && row.total_fpts !== undefined)
// Rank by total fantasy points
const best = [...played].sort((a, b) => (b.total_fpts ?? 0) - (a.total_fpts ?? 0))
// Take the five biggest games
const top = best.slice(0, 5)
// Print the game board
console.log("Highest-scoring games on the slate")
console.log(["game_id", "total_fpts", "home_fpts", "away_fpts", "home_pts", "away_pts", "player_count"].join('\t'))
for (const row of top) {
console.log([String(row.game_id ?? ''), String(row.total_fpts ?? ''), String(row.home_fpts ?? ''), String(row.away_fpts ?? ''), String(row.home_pts ?? ''), String(row.away_pts ?? ''), String(row.player_count ?? '')].join('\t'))
}