# Scoring trends over time

Source: https://developers.newjune.co/guides/scoring-trends

> Average score to par by month from your completed rounds.

`score_to_par` on each round is `total_strokes - par_total` for the holes you scored. This script fetches your completed rounds, keeps the 18-hole ones so months compare fairly, and prints the average score to par for each month.

**Needs:** a key with `rounds:read`, exported as `NEW_JUNE_API_KEY`.

curl:

```bash
#!/usr/bin/env bash
# scoring-trends.sh: needs curl and jq.
set -euo pipefail

all="[]"
cursor=""
while :; do
  url="https://data.newjune.co/v1/rounds?status=completed&limit=100"
  if [ -n "$cursor" ]; then url="$url&cursor=$cursor"; fi
  page=$(curl -sf "$url" -H "Authorization: Bearer $NEW_JUNE_API_KEY")
  all=$(jq -s '.[0] + .[1].data' <(echo "$all") <(echo "$page"))
  if [ "$(echo "$page" | jq -r '.has_more')" != "true" ]; then break; fi
  cursor=$(echo "$page" | jq -r '.next_cursor')
done

echo "$all" | jq -r '
  map(select(.holes_scored == 18 and .score_to_par != null))
  | group_by(.started_at[0:7])
  | .[]
  | "\(.[0].started_at[0:7])  rounds: \(length)  avg to par: \((map(.score_to_par) | add / length * 10 | round / 10))"'
```

TypeScript:

```ts
// scoring-trends.mts: Node 20+, no dependencies. Run with: npx tsx scoring-trends.mts
interface Round {
  started_at: string;
  holes_scored: number;
  score_to_par: number | null;
}

async function* listAll<T>(path: string, params: Record<string, string> = {}) {
  let cursor: string | null = null;
  do {
    const url = new URL(`https://data.newjune.co/v1/${path}`);
    url.searchParams.set('limit', '100');
    for (const [name, value] of Object.entries(params)) url.searchParams.set(name, value);
    if (cursor) url.searchParams.set('cursor', cursor);
    const response = await fetch(url, {
      headers: { Authorization: `Bearer ${process.env.NEW_JUNE_API_KEY}` },
    });
    if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
    const page = (await response.json()) as { data: T[]; has_more: boolean; next_cursor: string | null };
    yield* page.data;
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
}

const byMonth = new Map<string, number[]>();
for await (const round of listAll<Round>('rounds', { status: 'completed' })) {
  if (round.holes_scored !== 18 || round.score_to_par === null) continue;
  const month = round.started_at.slice(0, 7); // UTC month, e.g. "2026-06"
  byMonth.set(month, [...(byMonth.get(month) ?? []), round.score_to_par]);
}

for (const month of [...byMonth.keys()].sort()) {
  const scores = byMonth.get(month)!;
  const average = scores.reduce((sum, score) => sum + score, 0) / scores.length;
  const sign = average > 0 ? '+' : '';
  console.log(`${month}  rounds: ${scores.length}  avg to par: ${sign}${average.toFixed(1)}`);
}
```

Python:

```python
# scoring_trends.py: needs requests (pip install requests).
import os
from collections import defaultdict
import requests

API = "https://data.newjune.co/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['NEW_JUNE_API_KEY']}"

def list_all(path, **params):
    params = {"limit": 100, **params}
    while True:
        response = session.get(f"{API}/{path}", params=params, timeout=30)
        response.raise_for_status()
        page = response.json()
        yield from page["data"]
        if not page["has_more"]:
            return
        params["cursor"] = page["next_cursor"]

by_month = defaultdict(list)
for round_ in list_all("rounds", status="completed"):
    if round_["holes_scored"] != 18 or round_["score_to_par"] is None:
        continue
    by_month[round_["started_at"][:7]].append(round_["score_to_par"])  # UTC month

for month in sorted(by_month):
    scores = by_month[month]
    average = sum(scores) / len(scores)
    print(f"{month}  rounds: {len(scores)}  avg to par: {average:+.1f}")
```

```text title="Example output"
2026-04  rounds: 3  avg to par: +18.3
2026-05  rounds: 5  avg to par: +16.0
2026-06  rounds: 4  avg to par: +14.5
```

## Notes

- **Months are UTC.** A round that starts late in the evening can fall into the next UTC day or month. To group by local date, convert `started_at` with the round's `timezone` (an IANA name such as `America/Los_Angeles`) first.
- **Nine-hole rounds** are left out so a month with short rounds does not look better than it was. To include them, compare `score_to_par` per hole (`score_to_par / holes_scored`) instead.
- **`score_to_par` is null** when par is unknown for any scored hole, for example on a course without par data. Those rounds are skipped.
- **One year only:** add `started_after`, for example `{ status: 'completed', started_after: '2026-01-01T00:00:00Z' }`.
