Enforce correlated QB stacks, bring-backs, and player groups
Use `lineup_stacks`, `player_groups`, and `lineup_allow_defense_vs_offense: false` to enforce tournament correlation and conditional player group bounds cleanly.
- What it is
- Builds 5 NFL lineups requiring a correlated QB+WR primary stack plus 1 opponent bring-back, blocking defense-vs-offense, and capping key studs with `player_groups`.
- When to use it
- Use this for tournament lineup construction where correlation rules and conditional group limits must hold across every built roster.
- What you get back
- Five rule-compliant lineups showing each lineup's detected stack archetype and projected score.
1.Optimize 5 stacked lineups with group constraints
Combine a QB+WR+bring-back rule (`bring_back_count: 1`), `lineup_allow_defense_vs_offense: false`, and a mutual-exclusion `player_groups` block on slate `1126128`.
POST request (requires your API key in STAT_API_KEY). Run the SDK program on the right or the curl snippet below.
{
"lineup_count": 5,
"lineup_allow_defense_vs_offense": false,
"lineup_stacks": [
{
"positions": [
"QB",
"WR"
],
"bring_back_count": 1
}
],
"player_groups": [
{
"slate_player_ids": [
44186556,
44186570
],
"max_players": 1
}
],
"max_player_exposure_pct": 60,
"response_format": "json"
}const stackedRes = await api.dfs.slates.optimizerLineups(1126128, { lineup_count: 5, lineup_allow_defense_vs_offense: false, lineup_stacks: [{ positions: ["QB", "WR"], bring_back_count: 1 }], player_groups: [{ slate_player_ids: [44186556, 44186570], max_players: 1 }], max_player_exposure_pct: 60 })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
// Optimize 5 stacked lineups with group constraints
const stackedRes = await api.dfs.slates.optimizerLineups(1126128, { lineup_count: 5, lineup_allow_defense_vs_offense: false, lineup_stacks: [{ positions: ["QB", "WR"], bring_back_count: 1 }], player_groups: [{ slate_player_ids: [44186556, 44186570], max_players: 1 }], max_player_exposure_pct: 60 })
// Print stacked lineup summary
console.log(`Slate ${stackedRes.slate.id} (${stackedRes.slate.league}/${stackedRes.slate.operator}) | lineups=${stackedRes.portfolio.lineup_count} unique=${stackedRes.portfolio.unique_players} mean_pts=${stackedRes.portfolio.mean_projected_points.toFixed(2)}`)
for (const l of stackedRes.lineups.slice(0, 5)) {
console.log(`Lineup #${l.rank} | salary=${l.salary} pts=${l.projected_points.toFixed(2)} stack=${l.stack.summary}`)
}Verified output across all 4 SDKs
TypeScript, Python, Go, and Java execute cleanly and print byte-identical output:
Slate 1126128 (nfl/draftkings) | lineups=5 unique=19 mean_pts=147.88
Lineup #1 | salary=50000 pts=154.90 stack=QB+1 (NO) + 1 Opp (CAR)
Lineup #2 | salary=50000 pts=153.57 stack=QB+1 (NO) + 1 Opp (CAR)
Lineup #3 | salary=50000 pts=153.55 stack=QB+1 (NO) + 1 Opp (CAR)
Lineup #4 | salary=50000 pts=139.31 stack=QB+1 (DAL) + 1 Opp (SF)
Lineup #5 | salary=49900 pts=138.07 stack=QB+1 (DAL) + 1 Opp (SF)