> The index of these docs, for agents: https://traktor.fun/llms.txt

# Leaderboard

Traktor's own accounts, ranked by what their trades through Traktor realized.

`GET /v1/leaderboard` answers with the board Traktor's Traders page draws as its Traktor leaderboard view: its accounts ranked by what their trades through Traktor realized in a window.

### `GET /v1/leaderboard`

The leaderboard of Traktor's own accounts, ranked by what their trades through Traktor realized in a window, with the standing of the key's account.

- URL: `https://api.traktor.fun/v1/leaderboard`
- Credential: API key
- REST units: 1 unit

| Parameter | In | Type | Required | Default | Bounds | Description |
| --- | --- | --- | --- | --- | --- | --- |
| `window` | query | enum | no | 7d | 24h, 7d, 30d, all | The range, as the Portfolio tab's chart reads it. |

Limits:

- Invalid keys: 30 a minute, per IP
- Accounts listed: 1,000 rows, per request

```bash cURL
curl -s "https://api.traktor.fun/v1/leaderboard" \
  -H "Authorization: Bearer $TRAKTOR_API_KEY"
```

```ts TypeScript
const response = await fetch("https://api.traktor.fun/v1/leaderboard", {
  headers: { Authorization: `Bearer ${process.env.TRAKTOR_API_KEY}` },
});
const body = await response.json();
```

```python Python
import os
import requests

response = requests.get(
    "https://api.traktor.fun/v1/leaderboard",
    headers={"Authorization": f"Bearer {os.environ['TRAKTOR_API_KEY']}"},
)
print(response.json())
```

Errors: `invalid_parameter`, `unknown_parameter`, `duplicate_query_parameter`, `data_unavailable`, `missing_credentials`, `invalid_key`, `key_revoked`, `subscription_inactive`, `key_in_query`, `method_not_allowed`, `rate_limited`, `quota_exhausted`, `rate_limit_unavailable`, `internal_error`. Every code: https://traktor.fun/docs/errors.md

Each sale in the window is booked against the average cost of the account's buys before it, the way its Portfolio tab books it, and `window` picks the range as that tab's chart does. The board lists the first 1,000 accounts, the most realized first, and `summary` counts every account ranked, past the list too.

- `pnlUsd` is `null` when none of the window's sales was of a token whose cost the ledger names, such as one that came from outside, since what those tokens cost is unknown; such a row comes after every row with a figure, and `summary.pnlUsd` adds up the rows that have one.
- `roi` is what the sales realized over what the tokens sold cost, and `null` while nothing sold had a cost the ledger names.
- `wins` and `losses` count the tokens whose sales realized more, or lost more, than half a cent; `winRate` is wins over the tokens decided either way, `null` while none is.
- `you` is the standing of the account that owns the key, with its place on the whole board, and `null` while that account has no buy or sale in the window or is not ranked at all: closed, suspended, or kept off the board at its owner's request.

A row names an account by its X or Traktor name and an `id` that stays the same for the account, never a wallet. The board is read from the ledger once a minute, and `meta.asOf` dates that read. While a new read fails, the last board stays up to five minutes old, its `meta.asOf` saying so; past that, a board that cannot be read is `503 data_unavailable`, and its unit comes back ([Limit headers](https://traktor.fun/docs/plans.md#limit-headers)).
