STAT-API

Rank NHL season leaders

season_player_stats holds one row per player per season. Resolve the current season, page through all of it with the auto-pager, then sort client-side to build any leaderboard.

  1. 1. Resolve the current season

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/nhl/seasons?limit=200'
  2. 2. Page through the whole season

    The auto-paging iterator follows the keyset cursor across every page, so you accumulate the full season of rows without a manual loop.

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/nhl/season_player_stats?season_id=2025'
  3. 3. Rank by goals

    Sort the accumulated rows by any numeric column — here, goals.

    const ranked = [...rows].sort((a, b) => b.goals - a.goals)
  4. 4. Take the top ten

    const leaders = ranked.slice(0, 10)
  5. 5. Print the leaderboard

    console.log("NHL goals leaders")
    console.log(["player_id", "goals"].join('\t'))
    for (const row of leaders) {
      console.log([String(row.player_id ?? ''), String(row.goals ?? '')].join('\t'))
    }