Build a PGA golfer's scorecard
A scorecard is a round broken into holes. Pick a golfer, index them by id for name lookups, then pull the holes and render score-to-par per hole.
1. Pick a golfer
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/pga/players?limit=1'2. Index the golfer by id for name lookups
index_by builds a map from id to row so a later join can show the name.
const player_by_id = new Map<number, PGAPlayer>() for (const row of players) player_by_id.set(row.id, row)3. Pull the hole-by-hole cards
player_holes breaks each round into holes — hole_number, score, to_par.
curl -sS --compressed \ -H 'Authorization: Bearer YOUR_API_KEY' \ 'https://api.stat-api.com/api/v1/pga/player_holes?player_id=1'4. Render the scorecard
Each row shows the golfer's name (joined via the index), the round, hole, and to-par.
console.log(["full_name", "round_number", "hole_number", "to_par"].join('\t')) for (const row of holes) { console.log([String(player_by_id.get(row.player_id)?.full_name ?? row.player_id), String(row.round_number ?? ''), String(row.hole_number ?? ''), String(row.to_par ?? '')].join('\t')) }