Run an NBA possession simulation summary
Start every NBA workflow with the free `/api/v1/nba/weeks` discovery call to read `free_game_id`, then run `/api/v1/sim/nba/run` with `summary: true` and a fixed Common Random Numbers `seed` for deterministic team and player projections.
- What it is
- Discovers the free NBA showcase game (`free_game_id: 6029936`) via `/api/v1/nba/weeks` and summarizes simulated team totals, win rates, and top player DFS projections.
- When to use it
- Use this when you need calibrated full-game NBA team scores, win/cover odds, and player mean points/rebounds/assists/DK fantasy points from a repeatable CRN seed.
- What you get back
- Game total mean and SD, home/away win percentages, team scoring means, and the top 5 projected NBA players sorted deterministically.
1.Discover the free NBA showcase game
Call `/api/v1/nba/weeks` for the 2026 season (free for every tier) and read `free_game_id` (`6029936`, DET @ BOS).
const weeks = await api.nba.weeks({ season: 2026 })The 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
// Discover the free NBA showcase game
const weeks = await api.nba.weeks({ season: 2026 })
// Run the NBA possession simulator
const simRes = await api.sim.nba.run({ game_id: weeks.free_game_id, n_draws: 200, seed: 42, include: { summary: true, distributions: false, scorebox: false, pbp: false, scenarios: false, simulations: false } })
// Print calibrated summary and top NBA players
const summary = simRes.output.summary
if (!summary) throw new Error('missing output.summary')
console.log(`Game ${summary.game_id} | season ${summary.season} | draws ${summary.n_draws}`)
console.log(`Total mean=${summary.sim_total_mean.toFixed(2)} sd=${summary.sim_total_sd.toFixed(2)} | home_win_pct=${(summary.home_win_prob * 100).toFixed(2)}% away_win_pct=${(summary.away_win_prob * 100).toFixed(2)}%`)
console.log(`Teams away=${summary.away_team.team_code}:${summary.away_team.points_mean.toFixed(2)} home=${summary.home_team.team_code}:${summary.home_team.points_mean.toFixed(2)}`)
const sortedPlayers = [...summary.players].sort((a, b) => b.dk_pts_mean - a.dk_pts_mean || a.player_id - b.player_id)
for (const p of sortedPlayers.slice(0, 5)) {
console.log(`Player ${p.name} (${p.team_code}) | pts=${p.pts_mean.toFixed(2)} reb=${p.reb_mean.toFixed(2)} ast=${p.ast_mean.toFixed(2)} dk=${p.dk_pts_mean.toFixed(2)}`)
}Verified output across all 4 SDKs
TypeScript, Python, Go, and Java execute cleanly and print byte-identical output:
Game 6029936 | season 2026 | draws 200
Total mean=220.41 sd=19.45 | home_win_pct=43.50% away_win_pct=56.50%
Teams away=BOS:110.95 home=DET:109.46
Player Jayson Tatum (BOS) | pts=26.15 reb=8.48 ast=5.24 dk=48.53
Player Cade Cunningham (DET) | pts=25.19 reb=4.68 ast=6.96 dk=45.56
Player Jalen Duren (DET) | pts=16.38 reb=9.42 ast=1.69 dk=33.71
Player Payton Pritchard (BOS) | pts=16.40 reb=3.71 ast=4.42 dk=31.33
Player Paul George (BOS) | pts=16.17 reb=4.69 ast=3.30 dk=30.50