Skip to main content

Function: latestSeason()

latestSeason(leagueId?, endpoint?, today?, seasonType?): string

Defined in: src/core/transforms.ts:145

sdv-py nba_stats_runtime._latest_season: the latest season that has rows on today (local date, as py's date.today()), labelled for leagueId: "2025-26" for the NBA, G League ("20") and Summer League ("15"), a year for the WNBA ("10") and for drafthistory. endpoint picks the draft rules, commonplayoffseries or a seasonType of Playoffs / PlayIn the playoff rule, and All Star the All-Star rule.

Parameters​

leagueId?​

string = "00"

stats.nba.com LeagueID: "00" NBA (default), "20" G League, "15" Summer League, "10" WNBA. An unknown id falls back to the NBA calendar.

endpoint?​

string = ""

The endpoint slug (the request path's last segment), default "". Any draftcombine* slug uses the combine rule, drafthistory the draft rule and commonplayoffseries the playoff rule; other slugs use the league's rule.

today?​

Date = ...

The date to evaluate on; defaults to new Date() (local time).

seasonType?​

unknown

The request's SeasonType: "Playoffs" / "PlayIn" select the playoff rule, "All Star" the All-Star rule; anything else is ignored.

Returns​

string

"YYYY-YY" for the NBA, G League and Summer League; "YYYY" for the WNBA and for drafthistory in any league.

Remarks​

The first-rows month and year lag per (league, endpoint) were measured on stats.nba.com 2026-10-05; the lookup order is endpoint alone, then "<league> <endpoint>", then the league. A lockout or pandemic calendar needs an explicit season.

Example​

import { latestSeason } from "./transforms.js";
latestSeason("00", "", new Date(2026, 9, 5)); // "2025-26" (October: not yet 2026-27)
latestSeason("10", "", new Date(2026, 9, 5)); // "2026"
latestSeason("00", "leaguegamelog", new Date(2026, 9, 5), "Playoffs"); // "2025-26"