Rank MLB 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. Resolve the current season
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/mlb/seasons?limit=200'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/mlb/season_player_stats?season_id=2026'3. Rank by home runs
Sort the accumulated rows by any numeric column — here, home runs.
const ranked = [...rows].sort((a, b) => b.home_runs - a.home_runs)4. Take the top ten
const leaders = ranked.slice(0, 10)5. Print the leaderboard
console.log("MLB home runs leaders") console.log(["player_id", "home_runs"].join('\t')) for (const row of leaders) { console.log([String(row.player_id ?? ''), String(row.home_runs ?? '')].join('\t')) }