STAT-API

Read a PGA golfer's leaderboard finishes

The leaderboards table has one row per player per tournament: rank, total score, earnings, and strokes-gained splits. Pick a golfer and read their finishes.

  1. 1. Pick a golfer

    A one-row page gives us a valid player id to filter finishes by.

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/pga/players?limit=1'
  2. 2. Read that golfer's finishes

    Filter leaderboards by player_id to get every tournament that golfer played.

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/pga/leaderboards?player_id=1&limit=25'
  3. 3. Best finishes first

    Sort by rank ascending; rank is nullable (WD/DQ), coerced to sort last.

    const ranked = [...board].sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0))
  4. 4. Show the finishes

    console.log(["rank", "sg_total"].join('\t'))
    for (const row of ranked) {
      console.log([String(row.rank ?? ''), String(row.sg_total ?? '')].join('\t'))
    }