See who actually scored on a slate
dfs.player_stats reports what each player on a slate actually scored under that operator's scoring rules, together with the salary they cost. This recipe ranks a slate by real points. It also shows the trap that catches everyone the first time: a rostered player who never took a snap still returns a row, with every stat null.
1. Page the player pool for names
player_stats identifies players by player_id only. The pool carries the display names, so fetch it once and index it.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/dfs/slate_players?slate_id=129036'2. Index the pool by player id
const names = new Map<number, DFSSlatePlayer>() for (const row of pool) names.set(row.player_id, row)3. Page the slate's scoring rows
One row per player in the pool, already scored under the slate's own format — classic and showdown award different points for the same play.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/dfs/player_stats?slate_id=129036'4. Drop the players who did not play
The view LEFT-joins the pool to the box score, so a healthy scratch, a backup, or a postponed game leaves fantasy_pts null. Null is not zero — a player who scored 0.0 played and produced nothing, which is a different fact. Dropping nulls before you rank is the honest move.
const scored = stats.filter((row) => row.fantasy_pts !== null && row.fantasy_pts !== undefined)5. Rank by fantasy points
const best = [...scored].sort((a, b) => (b.fantasy_pts ?? 0) - (a.fantasy_pts ?? 0))6. Take the top fifteen
const top = best.slice(0, 15)7. Print the scoring board
The first column resolves player_id through the index built above.
console.log("Top scorers on the slate") console.log(["display_name", "position", "salary", "fantasy_pts"].join('\t')) for (const row of top) { console.log([String(names.get(row.player_id)?.display_name ?? row.player_id), String(row.position ?? ''), String(row.salary ?? ''), String(row.fantasy_pts ?? '')].join('\t')) }