DEV Community

HoopVision Lab
HoopVision Lab

Posted on

Eighty seasons of NBA box scores: the data decisions behind a plain-English stats site

HoopVision Lab is the NBA sibling of a football stats site I build. You type "compare LeBron James and Stephen Curry career points per game" or "Bulls vs Magic 1995-96 playoffs" and it builds a dashboard. It covers every season from 1946-47, the BAA's first, to today.

Going back that far meant making a lot of small decisions that never show up on screen but decide whether the numbers are right. Here are the ones that mattered most.

One source, one file that knows it

Every number comes from the BALLDONTLIE API: every player's line for every game since 1946-47. Team games are the sum of their players' lines (plus the final score from the game), and seasons are the sum of their games.

Only one file in the codebase, etl/source.js, knows what the API's responses look like. Everything else reads my own tables. When the source changes shape, one file changes. A modern season is about 350 requests; a 1950s season is under 100. Finished days are cached, so a daily refresh only asks for the last two days.

Franchises, not abbreviations

Teams are keyed by the source's team id, not their abbreviation. So the Minneapolis Lakers' seasons belong to the Lakers and show "MNL", and the SuperSonics' seasons belong to Oklahoma City and show "SEA". Clubs that folded, like the Chicago Stags or the first Baltimore Bullets, get their own inactive keys instead of being merged into something that happens to share a name.

Conferences and divisions come from the source from 2004-05, when today's alignment began. Before that, they come from a hand-kept table of the league's alignment by season, so "western conference standings 1996" answers with the 1995-96 West, not today's.

Unrecorded is empty, not zero

This is the rule I care about most. The league didn't track everything from the start:

  • rebounds before 1950-51
  • minutes before 1951-52
  • steals, blocks and offensive/defensive rebounds before 1973-74
  • turnovers before 1977-78

Those are left empty, never counted as zero. A 1965 center doesn't have "0 blocks", he has no recorded blocks. The one exception is threes before the line existed in 1979-80; those really are zero.

It gets subtler. Into the 1960s, and for some stats until 1983-84, the box scores have a count for only some of a season's games. Assists exist for 1% of 1946-47's games. So a season keeps those totals over the games that have them, divides its averages by those games, and every board that touches such a season says how many games it's based on. Without that, an early-era player's assists per game would be quietly divided by games where nobody counted assists.

Words that mean something specific

A plain-English interface has to agree with how fans already talk:

  • A season includes its playoffs unless you say "regular season" or "playoffs only", and the board title always says which.
  • "30-point season" means 30 points a game, the way the NBA says it, not 30 total.
  • Playoff rounds below the Finals aren't in the source, so they're worked out from the playoff games: each pair of clubs is a series, the last one is the Finals, and each earlier round is the series each club played before that.
  • A traded player's season covers all his teams and is filed under the last one.

No language model reads the question

Requests are read by rules in the site's own code. Nothing typed into Ask goes to an AI service. The parsed plan becomes a set of query specs, and one query compiler looks up every stat key in a catalog and binds every value as a parameter. An unknown key is an error, not a guess.

Try it

It's free during the beta; asking needs a free account. If an old-era number looks wrong to you, I'd like to know: https://hoopvisionlab.com/?ref=devto

NBA data: BALLDONTLIE.

Drafted with AI assistance and checked against the project's code and docs.

Top comments (3)

Collapse
 
sportsapis profile image
SportsAPIs.dev •

Iirc the 1953-54 playoffs opened with a round robin in each division, so "each pair of clubs is a series" would turn that into a few 2-game series. Probably needs a one-off override for that year.

Curious how the partial-count seasons roll up on career boards too. Does a career assists per game skip the uncounted games the same way, or only the season view?

Collapse
 
hoopvisionlab profile image
HoopVision Lab •

Good catch on 1953-54. A round robin would break the "each pair of clubs is a series" rule, so that year probably does need a one-off. I'll check what the site shows for it. On career boards I haven't verified whether it divides by counted games the same way the season view does, so I won't claim it. I'll test a pre-1984 player and report back here.

Collapse
 
hoopvisionlab profile image
HoopVision Lab •

Following up on the career board question. I tested Oscar Robertson over 1960-73 in the site's data: 9,325 assists across 1,034 games played, and the board shows 9.52 a game. That works out to 9,325 divided by 980, so the career number skips the games where assists weren't counted, the same way the season view does. I haven't checked 1953-54 yet, so I won't say what it shows for that round robin year.