Late-swap unlocked slots on active contest entries
Pass `entries` (or `entries_csv`) together with `as_of`, `locked_game_ids`, and `min_projection_gain` to freeze locked games and re-optimize only unlocked slots across your submitted contest entries.
- What it is
- Submits an entered NFL Classic roster on slate `1126128`, locks game `43545` (`QB`, `WR`, `FLEX`), and swaps the remaining unlocked slots for positive projection gain.
- When to use it
- Use this when news breaks between early kickoffs and late windows and you want fast deterministic late swaps before contest lock.
- What you get back
- Per-entry swap action (`swapped` vs `held`), salary, hold projection vs swapped projection, net projection gain, and locked slot count.
1.Run fast late swap with locked game 43545
Keep players from game `43545` pinned in `locked_game_ids` while upgrading unlocked slots for any non-negative `min_projection_gain`.
POST request (requires your API key in STAT_API_KEY). Run the SDK program on the right or the curl snippet below.
{
"entries": [
{
"entry_id": "entry-1",
"slate_player_ids": [
44186595,
44186556,
44186645,
44186641,
44186568,
44186860,
44186666,
44186564,
44187045
]
}
],
"as_of": "2025-01-01T00:00:00Z",
"locked_game_ids": [
43545
],
"min_projection_gain": 0,
"response_format": "json"
}const swapRes = await api.dfs.slates.optimizerLineups(1126128, { entries: [{ entry_id: "entry-1", slate_player_ids: [44186595, 44186556, 44186645, 44186641, 44186568, 44186860, 44186666, 44186564, 44187045] }], as_of: "2025-01-01T00:00:00Z", locked_game_ids: [43545], min_projection_gain: 0 })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
// Run fast late swap with locked game 43545
const swapRes = await api.dfs.slates.optimizerLineups(1126128, { entries: [{ entry_id: "entry-1", slate_player_ids: [44186595, 44186556, 44186645, 44186641, 44186568, 44186860, 44186666, 44186564, 44187045] }], as_of: "2025-01-01T00:00:00Z", locked_game_ids: [43545], min_projection_gain: 0 })
// Print per-entry swap decision and gain
console.log(`Slate ${swapRes.slate.id} | entries=${swapRes.lineups.length} swapped=${swapRes.portfolio.swapped_count ?? 0} held=${swapRes.portfolio.held_count ?? 0}`)
const _nz = (v: number) => (Math.abs(v) < 0.005 ? 0 : v)
for (const l of swapRes.lineups) {
const holdPts = l.hold_projected_points ?? l.projected_points
const gainPts = _nz(l.projection_gain ?? 0)
console.log(`Entry ${l.entry_id ?? 'entry'} | action=${l.action ?? ''} salary=${l.salary} hold=${holdPts.toFixed(2)} proj=${l.projected_points.toFixed(2)} gain=${gainPts.toFixed(2)} locked_slots=${(l.locked_slots ?? []).length}`)
}Verified output across all 4 SDKs
TypeScript, Python, Go, and Java execute cleanly and print byte-identical output:
Slate 1126128 | entries=1 swapped=1 held=0
Entry entry-1 | action=swapped salary=49900 hold=144.42 proj=155.40 gain=10.98 locked_slots=3