Rank teams for a stack
A team stack is several players from the same offense. dfs.team_stats sums every scoring category over a team's players on one slate, so you can rank offenses directly instead of adding player rows yourself. Each slate game contributes exactly two rows, and each row names its opponent.
1. Read both sides of every game on the slate
Two rows per game, so a 13-game slate returns 26. The id is derived from the slate game and is unique across leagues, which is why paging works.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/dfs/team_stats?limit=100&slate_id=129036'2. Keep the teams that played
const played = teams.filter((row) => row.fantasy_pts !== null && row.fantasy_pts !== undefined)3. Rank by fantasy points produced
const best = [...played].sort((a, b) => (b.fantasy_pts ?? 0) - (a.fantasy_pts ?? 0))4. Take the eight best offenses
const top = best.slice(0, 8)5. Print the stack board
is_home and opponent_team_id give the matchup without a second call. pts and total_yds are the real box score, so you can separate a team that scored efficiently from one that merely ran many plays.
console.log("Most productive offenses on the slate") console.log(["team_id", "opponent_team_id", "is_home", "fantasy_pts", "pts", "total_yds", "player_count"].join('\t')) for (const row of top) { console.log([String(row.team_id ?? ''), String(row.opponent_team_id ?? ''), String(row.is_home ?? ''), String(row.fantasy_pts ?? ''), String(row.pts ?? ''), String(row.total_yds ?? ''), String(row.player_count ?? '')].join('\t')) }