Enforce targeted multi-team stacks with filtered bring-backs
`lineup_stacks` accepts multiple correlation blocks: restrict `lineup_stacks[0]` to specific game environments with `teams` and `bring_back_positions`, then layer secondary positional mini-stacks cleanly.
- What it is
- Solves 5 lineups on slate `1126128` requiring a primary `["QB", "WR"]` stack on `["NO", "SF", "DAL"]` with a `["WR", "RB"]` opponent bring-back plus a secondary `["WR", "TE"]` mini-stack.
- When to use it
- Use this when building game-environment portfolios that pair a primary QB game stack from target teams with a secondary mini-stack.
- What you get back
- Mean lineup salary and slot-by-slot rosters displaying both the primary game stack and secondary correlation structure.
1.Optimize 5 lineups with primary + secondary team stacks
Enforce a `QB+WR` primary stack from `["NO", "SF", "DAL"]` with a `WR`/`RB` opponent bring-back alongside a secondary `WR+TE` stack.
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,
"diversity_weight": 0.25,
"min_unique_players": 2,
"lineup_allow_defense_vs_offense": false,
"lineup_stacks": [
{
"teams": [
"NO",
"SF",
"DAL"
],
"positions": [
"QB",
"WR"
],
"bring_back_count": 1,
"bring_back_positions": [
"WR",
"RB"
]
},
{
"positions": [
"WR",
"TE"
]
}
],
"response_format": "json"
}const multiStackRes = await api.dfs.slates.optimizerLineups(1126128, { lineup_count: 5, diversity_weight: 0.25, min_unique_players: 2, lineup_allow_defense_vs_offense: false, lineup_stacks: [{ teams: ["NO", "SF", "DAL"], positions: ["QB", "WR"], bring_back_count: 1, bring_back_positions: ["WR", "RB"] }, { positions: ["WR", "TE"] }] })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 lineups with primary + secondary team stacks
const multiStackRes = await api.dfs.slates.optimizerLineups(1126128, { lineup_count: 5, diversity_weight: 0.25, min_unique_players: 2, lineup_allow_defense_vs_offense: false, lineup_stacks: [{ teams: ["NO", "SF", "DAL"], positions: ["QB", "WR"], bring_back_count: 1, bring_back_positions: ["WR", "RB"] }, { positions: ["WR", "TE"] }] })
// Print full slot assignments for multi-stacked lineups
const p = multiStackRes.portfolio
console.log(`Slate ${multiStackRes.slate.id} (${multiStackRes.slate.league}/${multiStackRes.slate.operator}) | lineups=${p.lineup_count} unique=${p.unique_players} mean_pts=${p.mean_projected_points.toFixed(2)} mean_sal=${p.mean_salary.toFixed(2)}`)
for (const l of multiStackRes.lineups.slice(0, 5)) {
console.log(`Lineup #${l.rank} | salary=${l.salary} pts=${l.projected_points.toFixed(2)} stack=${l.stack.summary}`)
const seatText = l.seats.map((s) => `${s.slot}:${s.name ?? ''}(${s.team ?? ''},${s.base_position})`).join(' ')
console.log(` Seats: ${seatText}`)
}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=18 mean_pts=151.36 mean_sal=49800.00
Lineup #1 | salary=49900 pts=152.65 stack=QB+1 (NO) + 1 Opp (CAR)
Seats: QB:Tyler Shough(NO,QB) RB:Chuba Hubbard(CAR,RB) RB:Emmett Johnson(KC,RB) WR:Chris Olave(NO,WR) WR:Drake London(ATL,WR) WR:Justin Jefferson(MIN,WR) TE:Kyle Pitts Sr.(ATL,TE) FLEX:Tyler Warren(IND,TE) DST:Rams(LAR,DST)
Lineup #2 | salary=49900 pts=152.38 stack=QB+1 (NO) + 1 Opp (CAR)
Seats: QB:Tyler Shough(NO,QB) RB:Emmett Johnson(KC,RB) RB:Chuba Hubbard(CAR,RB) WR:Justin Jefferson(MIN,WR) WR:Chris Olave(NO,WR) WR:Drake London(ATL,WR) TE:Kyle Pitts Sr.(ATL,TE) FLEX:Zach Charbonnet(SEA,RB) DST:Dolphins(MIA,DST)
Lineup #3 | salary=49800 pts=151.15 stack=QB+1 (NO) + 1 Opp (CAR)
Seats: QB:Tyler Shough(NO,QB) RB:Chuba Hubbard(CAR,RB) RB:Emmett Johnson(KC,RB) WR:Drake London(ATL,WR) WR:KC Concepcion Jr.(CLE,WR) WR:Justin Jefferson(MIN,WR) TE:Kyle Pitts Sr.(ATL,TE) FLEX:Chris Olave(NO,WR) DST:Seahawks(SEA,DST)
Lineup #4 | salary=49700 pts=150.32 stack=QB+1 (NO) + 1 Opp (CAR)
Seats: QB:Tyler Shough(NO,QB) RB:Chuba Hubbard(CAR,RB) RB:Emmett Johnson(KC,RB) WR:Jordyn Tyson(NO,WR) WR:Justin Jefferson(MIN,WR) WR:Drake London(ATL,WR) TE:Kyle Pitts Sr.(ATL,TE) FLEX:James Cook III(BUF,RB) DST:Dolphins(MIA,DST)
Lineup #5 | salary=49700 pts=150.28 stack=QB+1 (NO) + 1 Opp (CAR)
Seats: QB:Tyler Shough(NO,QB) RB:Chuba Hubbard(CAR,RB) RB:Emmett Johnson(KC,RB) WR:Chris Olave(NO,WR) WR:Justin Jefferson(MIN,WR) WR:Matthew Golden(GB,WR) TE:Gavin Bartholomew(MIN,TE) FLEX:Zach Charbonnet(SEA,RB) DST:Colts(IND,DST)