Read an NBA player's game log
A game log is one player's per-game stat lines with the game context joined back in. Resolve the season, index its games by id, borrow a player from one game's box score, then page that player's stats and join each row to its game.
1. Resolve the current season
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/nba/seasons?limit=200'2. Page the season's games
Collect every game so each stat line can be joined back to its game.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/nba/games?season_id=2025'3. Index games by id
index_by builds an id-to-game map for the join.
const game_by_id = new Map<number, NBAGame>() for (const row of games) game_by_id.set(row.id, row)4. Borrow a player from one game's box score
One stat line gives a valid player_id to build the log from.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/nba/game_player_stats?game_id=1&limit=1'5. Page that player's game log
game_player_stats accepts player_id as a standalone filter — page every appearance.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/nba/game_player_stats?player_id=1'6. Print the game log
Each row joins game_id back to its game_time through the index; the stat column is the sport's headline number.
console.log("NBA game log (points)") console.log(["game_time", "pts"].join('\t')) for (const row of gamelog) { console.log([String(game_by_id.get(row.game_id)?.game_time ?? row.game_id), String(row.pts ?? '')].join('\t')) }