# Quickstart

Source: https://developers.newjune.co/quickstart

> Create a key, confirm it works, list your rounds, and fetch the next page. About two minutes.

You need a New June account with at least one round, and a terminal. The TypeScript samples run on Node 20 or later with the built-in `fetch`. Save them as `.mts` files and run them with `npx tsx file.mts`, so top-level `await` works. The Python samples need `requests` (`pip install requests`).

### Create a key

Open the [Developer page](https://newjune.co/golf/developer) in the New June web portal, sign in, and create a key. Give it a name you will recognize later, and pick the scopes it needs. For this quickstart, `rounds:read` is enough.

The key starts with `nj_live_` and is shown once. Copy it now and keep it in an environment variable, not in your code:

```bash
export NEW_JUNE_API_KEY="nj_live_..."
```

### Check the key

`GET /v1/me` works with any valid key and returns no golf data. A `200` means the key is good.

curl:

```bash
curl https://data.newjune.co/v1/me \
  -H "Authorization: Bearer $NEW_JUNE_API_KEY"
```

TypeScript:

```ts
const response = await fetch('https://data.newjune.co/v1/me', {
  headers: { Authorization: `Bearer ${process.env.NEW_JUNE_API_KEY}` },
});
console.log(response.status, await response.json());
```

Python:

```python
import os
import requests

response = requests.get(
    "https://data.newjune.co/v1/me",
    headers={"Authorization": f"Bearer {os.environ['NEW_JUNE_API_KEY']}"},
    timeout=30,
)
print(response.status_code, response.json())
```

```json title="200 OK"
{
  "object": "api_key_context",
  "key": {
    "object": "api_key",
    "id": "6f1c2b8e-3d4a-4f5b-9c6d-7e8f9a0b1c2d",
    "name": "Spreadsheet sync",
    "prefix": "nj_live_3f9a",
    "scopes": ["rounds:read"],
    "expires_at": null
  },
  "limits": { "requests_per_minute": 60, "requests_per_day": 1000 }
}
```

A `401` means the key is missing, mistyped, revoked, or expired. The response's `error.code` says which. See [Authentication](https://developers.newjune.co/authentication).

### List your rounds

`GET /v1/rounds` returns your rounds, newest first. `limit` sets the page size (1 to 100, default 25).

curl:

```bash
curl "https://data.newjune.co/v1/rounds?limit=2" \
  -H "Authorization: Bearer $NEW_JUNE_API_KEY"
```

TypeScript:

```ts
const response = await fetch('https://data.newjune.co/v1/rounds?limit=2', {
  headers: { Authorization: `Bearer ${process.env.NEW_JUNE_API_KEY}` },
});
const page = await response.json();
for (const round of page.data) {
  console.log(round.started_at, round.course?.name, round.total_strokes, round.score_to_par);
}
console.log('next_cursor:', page.next_cursor);
```

Python:

```python
import os
import requests

response = requests.get(
    "https://data.newjune.co/v1/rounds",
    params={"limit": 2},
    headers={"Authorization": f"Bearer {os.environ['NEW_JUNE_API_KEY']}"},
    timeout=30,
)
page = response.json()
for round_ in page["data"]:
    course = round_["course"]["name"] if round_["course"] else None
    print(round_["started_at"], course, round_["total_strokes"], round_["score_to_par"])
print("next_cursor:", page["next_cursor"])
```

Every list has the same envelope:

```json title="200 OK (shortened)"
{
  "object": "list",
  "data": [
    { "object": "round", "id": "6f1c2b8e-3d4a-4f5b-9c6d-7e8f9a0b1c2d", "status": "completed", "started_at": "2026-06-14T15:02:11.000Z", "total_strokes": 87, "score_to_par": 15 },
    { "object": "round", "id": "0b5d7c1e-2f3a-4b6c-8d9e-1a2b3c4d5e6f", "status": "completed", "started_at": "2026-06-07T16:40:03.000Z", "total_strokes": 91, "score_to_par": 19 }
  ],
  "has_more": true,
  "next_cursor": "eyJ2IjoxLCJrIjpbIjIwMjYtMDYtMDdUMTY6NDA6MDMuMDAwMDAwWiIsIjBiNWQ3YzFlLTJmM2EtNGI2Yy04ZDllLTFhMmIzYzRkNWU2ZiJdfQ"
}
```

### Get the next page

When `has_more` is true, send `next_cursor` back as `cursor`. Keep every other parameter the same.

curl:

```bash
curl "https://data.newjune.co/v1/rounds?limit=2&cursor=PASTE_NEXT_CURSOR_HERE" \
  -H "Authorization: Bearer $NEW_JUNE_API_KEY"
```

TypeScript:

```ts
const url = new URL('https://data.newjune.co/v1/rounds');
url.searchParams.set('limit', '2');
url.searchParams.set('cursor', process.argv[2] ?? '');
const response = await fetch(url, {
  headers: { Authorization: `Bearer ${process.env.NEW_JUNE_API_KEY}` },
});
console.log(await response.json());
```

Python:

```python
import os
import sys
import requests

response = requests.get(
    "https://data.newjune.co/v1/rounds",
    params={"limit": 2, "cursor": sys.argv[1]},
    headers={"Authorization": f"Bearer {os.environ['NEW_JUNE_API_KEY']}"},
    timeout=30,
)
print(response.json())
```

On the last page, `has_more` is false and `next_cursor` is null. [Pagination](https://developers.newjune.co/pagination) has a complete loop in each language.

## Next

- Learn how the objects connect in the [Data model](https://developers.newjune.co/data-model).
- Pull every round into a file with [Export every round to CSV](https://developers.newjune.co/guides/export-rounds-to-csv).
- Browse every endpoint in the [API reference](https://developers.newjune.co/api-reference).
