STAT-API
DFS Cookbook

Rank a DFS slate by salary and value

Value is points per dollar, and it is the screen that decides most lineups. A 9,800-salary running back who scores 20 points returns less than a 3,600 receiver who scores 15. dfs.player_stats reports the salary and the points on the same row, so this needs one endpoint and no join. Salaries below the floor are excluded, because a minimum-priced player who scores once distorts any ratio.

What it is
Ranks a slate by points scored per $1,000 of salary — the value screen that decides most lineups.
When to use it
Use it to find which prices the operator got wrong, to measure whether a pricing model beats the market, or to score a completed slate for value.
What you get back
The ten best values on the slate, each with the salary paid, the points scored, and the ratio between them.

1.Page the slate's scoring rows

Salary, position, and points all arrive together.

const stats: DFSPlayerStat[] = []
for await (const row of api.dfs.player_stats.iter({ slate_id: 129036 })) stats.push(row)

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, type DFSPlayerStat } from '@stat-api/client'

const api = new StatApi() // reads STAT_API_KEY from the environment

// Page the slate's scoring rows
const stats: DFSPlayerStat[] = []
for await (const row of api.dfs.player_stats.iter({ slate_id: 129036 })) stats.push(row)

// Drop the players who did not play
const scored = stats.filter((row) => row.fantasy_pts !== null && row.fantasy_pts !== undefined)

// Drop minimum-salary players
const playable = scored.filter((row) => row.salary >= 4000)

// Compute points per $1,000 of salary
const board = playable
  .map((row) => ({
    player_id: row.player_id,
    position: row.position,
    salary: row.salary,
    points: row.fantasy_pts ?? 0,
    value: ((row.fantasy_pts ?? 0) / row.salary) * 1000,
  }))
  .sort((a, b) => b.value - a.value)
  .slice(0, 10)
console.log(['player_id', 'position', 'salary', 'points', 'per $1k'].join('\t'))
for (const r of board) {
  console.log([r.player_id, r.position, r.salary, r.points, r.value.toFixed(2)].join('\t'))
}