Skip to main content

Variable: BASKETBALL_PBP_PRODUCERS

const BASKETBALL_PBP_PRODUCERS: object

Defined in: src/producers/espn_basketball_pbp.ts:1267

{ league: { helper_<lg>_pbp, helper_<lg>_pickcenter, helper_<lg>_game_data, helper_<lg>_pbp_features } }: the PBP producers keyed by league, which src/index.ts merges onto sdv.nba / sdv.wnba / sdv.mbb / sdv.wbb under both the snake_case name and a camelCase alias (and mounts espn_<lg>_pbp beside them via _espnPbp).

Type Declaration​

mbb​

mbb: object

mbb.helper_mbb_game_data​

helper_mbb_game_data: (pbp_txt, init) => [Record<string, any>, Init]

MBB home / away identification (sdv-py helper_mbb_game_data(pbp_txt, init)): [pbp_txt, init]. homeTeamSpread follows homeFavorite (a one-element array in init stays one, as numpy).

Parameters​
pbp_txt​

any

The trimmed game dict; reads header.competitions[0] and header.season.

init​

Init

The pickcenter dict (all four keys required).

Returns​

[Record<string, any>, Init]

[pbp_txt, init] with the team keys added (see the NBA helper).

Example​
const [txt, init2] = sdv.mbb.helper_mbb_game_data(summary, init);
See​

helper_nba_game_data for the keys read / written and the errors.

mbb.helper_mbb_pbp​

helper_mbb_pbp: (game_id, pbp_txt) => PbpResult

MBB cleaned game dict (sdv-py helper_mbb_pbp(game_id, pbp_txt)): plays, timeouts, ...

Parameters​
game_id​

unknown

The ESPN event id; coerced with int() for gameId (a decimal string).

pbp_txt​

any

The TRIMMED summary (espn_mbb_pbp(id, { raw: true })); no seasonseries.

Returns​

PbpResult

The PbpResult.

Example​
const trimmed = await sdv.mbb.espn_mbb_pbp(401638645, { raw: true });
const game = sdv.mbb.helper_mbb_pbp(401638645, trimmed);
game.gameId; // "401638645"
See​

helper_nba_pbp for the required keys, the no-play-by-play case and the errors.

mbb.helper_mbb_pbp_features​

helper_mbb_pbp_features: (game_id, pbp_txt, init) => Record<string, any>

MBB play features + timeouts (sdv-py helper_mbb_pbp_features(game_id, pbp_txt, init)): halves, Int32 clock.

Parameters​
game_id​

unknown

The ESPN event id.

pbp_txt​

any

The game dict after helper_mbb_game_data.

init​

Init

The init dict helper_mbb_game_data returned.

Returns​

Record<string, any>

{ ...pbp_txt, plays, timeouts }.

Example​
const done = sdv.mbb.helper_mbb_pbp_features(401638645, txt, init2);
done.plays[0]["start.period_seconds_remaining"];
Remarks​

MBB's own column set: half = period, lag_period / lead_period (and lag_half / lead_half), start.period_seconds_remaining / end.period_seconds_remaining -- no qtr, game_half, period or quarter columns. clock.displayValue / time keep the display as is; only the split gets the "0:" prefix ("23.4" -> 0:23), then Float64 -> Int32 (truncating). Ladders 1200 / 2400, OT 300 (both end.* columns reset to 300 at every OT); timeouts split at period <= 1; season / team ids not cast.

See​

helper_nba_pbp_features for the shared timeout and per-game rules.

mbb.helper_mbb_pickcenter​

helper_mbb_pickcenter: (pbp_txt) => Init

MBB pickcenter metadata (sdv-py helper_mbb_pickcenter(pbp_txt)): spread / over-under (default 142.0) / home favorite / availability as plain scalars.

Parameters​
pbp_txt​

any

The trimmed game dict (or any ESPN summary payload); reads pickcenter.

Returns​

Init

{ gameSpread, overUnder, homeFavorite, gameSpreadAvailable }.

Example​
const summary = await sdv.mbb.espnMbbSummary({ event_id: 401638645 });
const init = sdv.mbb.helper_mbb_pickcenter(summary);
See​

helper_nba_pickcenter for the provider order, favorite and default rules.

nba​

nba: object

nba.helper_nba_game_data​

helper_nba_game_data: (pbp_txt, init) => [Record<string, any>, Init]

NBA home / away identification (sdv-py helper_nba_game_data(pbp_txt, init)): [pbp_txt, init]. homeTeamSpread follows homeFavorite (a one-element array in init stays one, as numpy).

Parameters​
pbp_txt​

any

The trimmed game dict. Reads header.competitions[0] (competitors[].{homeAway, team.{id,location,name,abbreviation}}, playByPlaySource, boxscoreSource) and header.season. Never mutated: the touched header path is copied.

init​

Init

The pickcenter dict (gameSpread, overUnder, homeFavorite, gameSpreadAvailable), all four keys required.

Returns​

[Record<string, any>, Init]

[pbp_txt, init]: the game dict with timeouts: {}, teamInfo (= the copied header.competitions[0], now carrying home / away team objects), season, playByPlaySource, boxscoreSource, the four spread keys and homeTeamSpread (+|spread| when home is favored, else -|spread|); and init extended with homeTeamId, homeTeamMascot, homeTeamName, homeTeamAbbrev, homeTeamNameAlt and the five awayTeam* twins.

Throws​

Error prefixed KeyError: / IndexError: when a read key or competitor is absent; ValueError: when a team id is not an int; TypeError: when init.gameSpread is not a number (Python abs).

Example​
const init = sdv.nba.helper_nba_pickcenter(summary);
const [txt, init2] = sdv.nba.helper_nba_game_data(summary, init);
init2.homeTeamAbbrev;
Remarks​

Shared by all four leagues (the others @see this block): the team ids in init are py ints (JS numbers) here; they become decimal strings only in the plays rows. homeTeamNameAlt is the location with Stat... shortened to St. The first competitor's homeAway decides which side is home.

nba.helper_nba_pbp​

helper_nba_pbp: (game_id, pbp_txt) => PbpResult

NBA cleaned game dict (sdv-py helper_nba_pbp(game_id, pbp_txt)): pickcenter -> game data -> play features, then the result keys in py's order.

Parameters​
game_id​

unknown

The ESPN event id; the result's gameId (a decimal string) and the plays' game_id.

pbp_txt​

any

The TRIMMED summary (what espn_nba_pbp(id, { raw: true }) returns): every output key must be present (winprobability, boxscore, header, format, broadcasts, videos, standings, article, leaders, seasonseries, pickcenter, againstTheSpread, odds, predictor, espnWP, gameInfo, season), plus plays when the game has play-by-play.

Returns​

PbpResult

The PbpResult. Without a plays key, or when header.competitions[0].playByPlaySource is "none", plays is [] and timeouts holds the two empty { "1": [], "2": [] } entries.

Throws​

Error prefixed KeyError: when an output key is absent from pbp_txt; plus everything helper_nba_pickcenter, helper_nba_game_data and helper_nba_pbp_features throw.

Throws​

TypeError when a play / team id is a JS number beyond Number.MAX_SAFE_INTEGER.

Example​
const trimmed = await sdv.nba.espn_nba_pbp(401360428, { raw: true });
const game = sdv.nba.helper_nba_pbp(401360428, trimmed);
game.timeouts[game.plays[0].homeTeamId]["2"]; // second-half home timeout play ids
Remarks​

Shared by all four leagues (the others @see this block): espn_<lg>_pbp fetches the summary, trims it and calls this; use that unless you already hold a trimmed payload. NBA / WNBA keep seasonseries; MBB / WBB do not and coerce gameId with int() first (a non-integer id raises ValueError:).

nba.helper_nba_pbp_features​

helper_nba_pbp_features: (game_id, pbp_txt, init) => Record<string, any>

NBA play features + timeouts (sdv-py helper_nba_pbp_features(game_id, pbp_txt, init)): quarters, 720-second ladder.

Parameters​
game_id​

unknown

The ESPN event id; becomes the Int32 game_id column.

pbp_txt​

any

The game dict after helper_nba_game_data. Reads header.season and plays.

init​

Init

The init dict helper_nba_game_data returned.

Returns​

Record<string, any>

{ ...pbp_txt, plays, timeouts }: plays as Row[] (py's columns, in order; ids as decimal strings) and timeouts as { [homeTeamId]: { "1": ids, "2": ids }, [awayTeamId]: {...} } of timeout play ids split by half.

Throws​

Error prefixed KeyError: when init.homeTeamId / awayTeamId is absent, plus everything _playsFrame and _features throw.

Throws​

TypeError when a play / team id is a JS number beyond Number.MAX_SAFE_INTEGER.

Example​
const [txt, init2] = sdv.nba.helper_nba_game_data(summary, sdv.nba.helper_nba_pickcenter(summary));
const done = sdv.nba.helper_nba_pbp_features(401360428, txt, init2);
done.plays[0]["start.game_seconds_remaining"]; // 2880 for a first-quarter play at 12:00
Remarks​

Shared by all four leagues (the others @see this block):

  • A team timeout (RegularTimeOut, ShortTimeOut, Full / Short / No / Reset Timeout; official / TV timeouts excluded) is credited to the play's own team.id; a play without one falls back to the side's abbreviation / location / mascot / alt name as a whole word in the play text (case-insensitive).
  • Every lag / lead / game_play_number op is per game_id.
  • NBA: period.number / qtr / period Int32; clock.displayValue and time get a "0:" prefix when the clock has no colon; clock.minutes / clock.seconds Float32; ladders 720 / 1440 / 2160 / 2880, OT 300; timeouts split at period <= 2.
  • Season and the team-id columns are cast Int32 for NBA / WNBA and left as is for MBB / WBB.
  • timeouts keys are strings here (py: ints); JS orders integer keys ascending.

nba.helper_nba_pickcenter​

helper_nba_pickcenter: (pbp_txt) => Init

NBA pickcenter metadata (sdv-py helper_nba_pickcenter(pbp_txt) -> _espn_basketball_pbp.pickcenter_odds): spread / over-under (default 215.5) / home favorite / availability as plain scalars, e.g. gameSpread: -8.5; the spread and the favorite come from one provider row.

Parameters​
pbp_txt​

any

The trimmed game dict (or any ESPN summary payload). Reads pickcenter: a list of provider records (a single dict counts as one record), each flattened to dotted keys (spread, overUnder, provider.id, homeTeamOdds.favorite).

Returns​

Init

{ gameSpread, overUnder, homeFavorite, gameSpreadAvailable } -- the init dict the next stage (helper_nba_game_data) takes.

Throws​

Error prefixed AttributeError: when pbp_txt is not a dict; TypeError: when pickcenter is not a list of dicts; ValueError: when a spread / overUnder is not float-able.

Example​
const summary = await sdv.nba.espnNbaSummary({ event_id: 401360428 });
const init = sdv.nba.helper_nba_pickcenter(summary);
init.gameSpreadAvailable; // true when some provider carries a spread
Remarks​

Shared by all four leagues (the others @see this block):

  • No provider carries a spread: { gameSpread: 2.5, overUnder: <league default>, homeFavorite: true, gameSpreadAvailable: false }. Over/under defaults: NBA 215.5, WNBA 165.5, MBB 142.0, WBB 130.5.
  • Providers are sorted by str(provider.id) (stable), so teamrankings "1002" sorts ahead of consensus "1004" and Caesars "45"; an absent id sorts as "nan", a null one as "None". Without any provider.id the payload order stands.
  • The spread is ESPN's home line: homeFavorite = spread < 0; a pick'em (0) takes that row's own homeTeamOdds.favorite (home when unset). overUnder is the first non-null one in sorted order, else the league default.

wbb​

wbb: object

wbb.helper_wbb_game_data​

helper_wbb_game_data: (pbp_txt, init) => [Record<string, any>, Init]

WBB home / away identification (sdv-py helper_wbb_game_data(pbp_txt, init)): [pbp_txt, init]. homeTeamSpread follows homeFavorite (a one-element array in init stays one, as numpy).

Parameters​
pbp_txt​

any

The trimmed game dict; reads header.competitions[0] and header.season.

init​

Init

The pickcenter dict (all four keys required).

Returns​

[Record<string, any>, Init]

[pbp_txt, init] with the team keys added (see the NBA helper).

Example​
const [txt, init2] = sdv.wbb.helper_wbb_game_data(summary, init);
See​

helper_nba_game_data for the keys read / written and the errors.

wbb.helper_wbb_pbp​

helper_wbb_pbp: (game_id, pbp_txt) => PbpResult

WBB cleaned game dict (sdv-py helper_wbb_pbp(game_id, pbp_txt)): plays, timeouts, ...

Parameters​
game_id​

unknown

The ESPN event id; coerced with int() for gameId (a decimal string).

pbp_txt​

any

The TRIMMED summary (espn_wbb_pbp(id, { raw: true })); no seasonseries.

Returns​

PbpResult

The PbpResult.

Example​
const trimmed = await sdv.wbb.espn_wbb_pbp(401587390, { raw: true });
const game = sdv.wbb.helper_wbb_pbp(401587390, trimmed);
See​

helper_nba_pbp for the required keys, the no-play-by-play case and the errors.

wbb.helper_wbb_pbp_features​

helper_wbb_pbp_features: (game_id, pbp_txt, init) => Record<string, any>

WBB play features + timeouts (sdv-py helper_wbb_pbp_features(game_id, pbp_txt, init)): halves before 2016, else quarters.

Parameters​
game_id​

unknown

The ESPN event id.

pbp_txt​

any

The game dict after helper_wbb_game_data; also reads format.regulation.periods for the era.

init​

Init

The init dict helper_wbb_game_data returned.

Returns​

Record<string, any>

{ ...pbp_txt, plays, timeouts }.

Example​
const done = sdv.wbb.helper_wbb_pbp_features(401587390, txt, init2);
Remarks​

WNBA's chain with a 2016 season-year cutoff (the format still wins when present) and the season / team-id columns NOT cast.

See​

helper_wnba_pbp_features for the era ladders; helper_nba_pbp_features for the shared timeout, clock and per-game rules.

wbb.helper_wbb_pickcenter​

helper_wbb_pickcenter: (pbp_txt) => Init

WBB pickcenter metadata (sdv-py helper_wbb_pickcenter(pbp_txt)): spread / over-under (default 130.5) / home favorite / availability as plain scalars.

Parameters​
pbp_txt​

any

The trimmed game dict (or any ESPN summary payload); reads pickcenter.

Returns​

Init

{ gameSpread, overUnder, homeFavorite, gameSpreadAvailable }.

Example​
const summary = await sdv.wbb.espnWbbSummary({ event_id: 401587390 });
const init = sdv.wbb.helper_wbb_pickcenter(summary);
See​

helper_nba_pickcenter for the provider order, favorite and default rules.

wnba​

wnba: object

wnba.helper_wnba_game_data​

helper_wnba_game_data: (pbp_txt, init) => [Record<string, any>, Init]

WNBA home / away identification (sdv-py helper_wnba_game_data(pbp_txt, init)): [pbp_txt, init]. homeTeamSpread follows homeFavorite (a one-element array in init stays one, as numpy).

Parameters​
pbp_txt​

any

The trimmed game dict; reads header.competitions[0] and header.season.

init​

Init

The pickcenter dict (all four keys required).

Returns​

[Record<string, any>, Init]

[pbp_txt, init] with the team keys added (see the NBA helper).

Example​
const [txt, init2] = sdv.wnba.helper_wnba_game_data(summary, init);
See​

helper_nba_game_data for the keys read / written and the errors.

wnba.helper_wnba_pbp​

helper_wnba_pbp: (game_id, pbp_txt) => PbpResult

WNBA cleaned game dict (sdv-py helper_wnba_pbp(game_id, pbp_txt)): plays, timeouts, ...

Parameters​
game_id​

unknown

The ESPN event id.

pbp_txt​

any

The TRIMMED summary (espn_wnba_pbp(id, { raw: true })); keeps seasonseries.

Returns​

PbpResult

The PbpResult.

Example​
const trimmed = await sdv.wnba.espn_wnba_pbp(401320565, { raw: true });
const game = sdv.wnba.helper_wnba_pbp(401320565, trimmed);
See​

helper_nba_pbp for the required keys, the no-play-by-play case and the errors.

wnba.helper_wnba_pbp_features​

helper_wnba_pbp_features: (game_id, pbp_txt, init) => Record<string, any>

WNBA play features + timeouts (sdv-py helper_wnba_pbp_features(game_id, pbp_txt, init)): halves before 2006, else quarters.

Parameters​
game_id​

unknown

The ESPN event id.

pbp_txt​

any

The game dict after helper_wnba_game_data; also reads format.regulation.periods for the era.

init​

Init

The init dict helper_wnba_game_data returned.

Returns​

Record<string, any>

{ ...pbp_txt, plays, timeouts }.

Example​
const done = sdv.wnba.helper_wnba_pbp_features(401320565, txt, init2);
Remarks​

Era-aware: format.regulation.periods (2 = halves, 4 = quarters) is authoritative, else season year < 2006 = halves. Quarters: ladders 600 / 1200 / 1800 / 2400, OT 300, arithmetic K + (60m + s). Halves: ladders 1200 / 2400, OT 300 from period 3, half = period. Timeouts split at the first-half period count (1 or 2). Ids cast Int32.

See​

helper_nba_pbp_features for the shared timeout, clock and per-game rules.

wnba.helper_wnba_pickcenter​

helper_wnba_pickcenter: (pbp_txt) => Init

WNBA pickcenter metadata (sdv-py helper_wnba_pickcenter(pbp_txt)): spread / over-under (default 165.5) / home favorite / availability as plain scalars.

Parameters​
pbp_txt​

any

The trimmed game dict (or any ESPN summary payload); reads pickcenter.

Returns​

Init

{ gameSpread, overUnder, homeFavorite, gameSpreadAvailable }.

Example​
const summary = await sdv.wnba.espnWnbaSummary({ event_id: 401320565 });
const init = sdv.wnba.helper_wnba_pickcenter(summary);
See​

helper_nba_pickcenter for the provider order, favorite and default rules.

Remarks​

Every member is pure (no network); the map is the single registration point.

Example​

BASKETBALL_PBP_PRODUCERS.wbb.helper_wbb_pickcenter(summary);