Control player exposures, locks, excludes, and diversity weight
Pair `diversity_weight` and global `max_player_exposure_pct` with per-player overrides in `players[]`: `lock`, `exclude`, `min_exposure_pct`, and `max_exposure_pct` (which can either tighten below or override above the global ceiling).
- What it is
- Builds 8 NFL Classic lineups on slate `1126128` locking Justin Jefferson, excluding Bijan Robinson, enforcing 50–75% exposure on James Cook III, capping Chuba Hubbard at 50%, and relaxing Emmett Johnson to 100%.
- When to use it
- Use this when scaling multi-entry tournament builds with per-player conviction bounds that selectively tighten or override your global exposure ceiling.
- What you get back
- Portfolio diversity metrics, exclusion/shortfall counts, realized player exposure table sorted by lineup appearances, and the top ranked lineups.
1.Optimize 8 lineups with exposure bounds and locks
Call `optimizerLineups` with `diversity_weight: 0.35`, `max_player_exposure_pct: 75.0`, one lock, one exclude, and per-player exposure floors/ceilings.
POST request (requires your API key in STAT_API_KEY). Run the SDK program on the right or the curl snippet below.
{
"lineup_count": 8,
"diversity_weight": 0.35,
"min_unique_players": 2,
"max_player_exposure_pct": 75,
"players": [
{
"slate_player_id": 44186570,
"lock": true
},
{
"slate_player_id": 44186556,
"exclude": true
},
{
"slate_player_id": 44186562,
"min_exposure_pct": 50,
"max_exposure_pct": 75
},
{
"slate_player_id": 44186564,
"max_exposure_pct": 50
},
{
"slate_player_id": 44186645,
"max_exposure_pct": 100
}
],
"response_format": "json"
}const expRes = await api.dfs.slates.optimizerLineups(1126128, { lineup_count: 8, diversity_weight: 0.35, min_unique_players: 2, max_player_exposure_pct: 75, players: [{ slate_player_id: 44186570, lock: true }, { slate_player_id: 44186556, exclude: true }, { slate_player_id: 44186562, min_exposure_pct: 50, max_exposure_pct: 75 }, { slate_player_id: 44186564, max_exposure_pct: 50 }, { slate_player_id: 44186645, max_exposure_pct: 100 }] })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 8 lineups with exposure bounds and locks
const expRes = await api.dfs.slates.optimizerLineups(1126128, { lineup_count: 8, diversity_weight: 0.35, min_unique_players: 2, max_player_exposure_pct: 75, players: [{ slate_player_id: 44186570, lock: true }, { slate_player_id: 44186556, exclude: true }, { slate_player_id: 44186562, min_exposure_pct: 50, max_exposure_pct: 75 }, { slate_player_id: 44186564, max_exposure_pct: 50 }, { slate_player_id: 44186645, max_exposure_pct: 100 }] })
// Print portfolio diversity metrics and realized player exposures
const p = expRes.portfolio
const excl = expRes.diagnostics.excluded?.by_caller ?? 0
const shortfalls = (p.min_exposure_shortfalls ?? []).length
console.log(`Slate ${expRes.slate.id} (${expRes.slate.league}/${expRes.slate.operator}) | source=${expRes.source.name} lineups=${p.lineup_count} unique=${p.unique_players} mean_pts=${p.mean_projected_points.toFixed(2)}`)
console.log(`Diversity pds=${p.diversity.composite_diversity_score.toFixed(2)} overlap=${p.mean_pairwise_overlap.toFixed(2)} max_overlap=${p.diversity.max_pair_overlap} eff_shannon=${p.diversity.effective_players_shannon.toFixed(2)} excluded=${excl} shortfalls=${shortfalls}`)
const sortedExps = [...p.exposures].sort((a, b) => b.lineups - a.lineups || a.slate_player_id - b.slate_player_id)
for (const e of sortedExps.slice(0, 8)) {
console.log(`Exposure ${e.name ?? ''} (${e.team ?? ''}) | lineups=${e.lineups}/${p.lineup_count} pct=${e.exposure_pct.toFixed(2)}%`)
}
for (const l of expRes.lineups.slice(0, 3)) {
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) | source=STAT_API_LATEST lineups=8 unique=22 mean_pts=152.58
Diversity pds=0.60 overlap=4.68 max_overlap=6 eff_shannon=17.96 excluded=1 shortfalls=0
Exposure Justin Jefferson (MIN) | lineups=8/8 pct=100.00%
Exposure Emmett Johnson (KC) | lineups=8/8 pct=100.00%
Exposure Tyler Shough (NO) | lineups=6/8 pct=75.00%
Exposure CeeDee Lamb (DAL) | lineups=5/8 pct=62.50%
Exposure Colts (IND) | lineups=5/8 pct=62.50%
Exposure James Cook III (BUF) | lineups=4/8 pct=50.00%
Exposure Chuba Hubbard (CAR) | lineups=4/8 pct=50.00%
Exposure Drake London (ATL) | lineups=4/8 pct=50.00%
Lineup #1 | salary=50000 pts=154.90 stack=QB+1 (NO) + 1 Opp (CAR)
Lineup #2 | salary=50000 pts=152.86 stack=QB (NO) + 1 Opp (CAR)
Lineup #3 | salary=50000 pts=152.57 stack=Naked QB (SF)