# ClientLeaderboard: top() method

> The top() method of the ClientLeaderboard interface resolves with a page of the best entries of a period.

The **`top()`** method of the [`ClientLeaderboard`](/docs/client/client-leaderboard) interface resolves with a page of the best entries of a period, best first.

## Syntax

```ts
top()
top(options)
```

### Parameters

`options` Optional
: An object with any of these properties:

  `period`
  : A string: the period, as the [Description](/docs/room/leaderboard#description) section of `Leaderboard` describes. Defaults to `"all"`.

  `limit`
  : A number: the most entries in the page, from 1 to 100. Defaults to 20.

  `after`
  : A string or `null`: the `next` of the page before, for the page after it.

  `signal`
  : An `AbortSignal` that aborts this call.

### Return value

A `Promise` that resolves with `{ entries, next }`. `next` is `null` on the last page. Each entry is an object with these properties:

`rank`
: Its rank, from 1.

`player`
: The player's ID.

`score`
: The score the period keeps for the player.

`meta`
: The `meta` the last submit gave.

`updated`
: When the entry was last written, in wall-clock milliseconds.

### Exceptions

[`DataError`](/docs/room/data-error)
: Rejects with this if the read fails, such as with `E_FORBIDDEN` when the board doesn't have `clientRead: true`, `E_INVALID` for a `limit` out of range or `E_UNKNOWN` when the board isn't declared. An aborted call rejects with `E_UNAVAILABLE`, named `AbortError`, or `TimeoutError` for an `AbortSignal.timeout()`, with the signal's reason as its `cause`.

## Description

`top()` goes without a token until the client has one. With the project's `players.readLeaderboardsWithoutToken` on, it needs no guest, so a start screen can show a board without making one; otherwise the router's 401 gets the client a guest first.

`top()` is never cached, so call it on an event or every few seconds rather than every frame.

## Examples

### Paging through the all-time board

A "more" button loads the next 20 entries of the all-time board, starting again from the top once it reaches the end.

```ts
// all-time.ts
import { dataClient } from "@irtio/client";

const board = dataClient().leaderboard("highscores");
let after: string | null = null;

export async function nextPage() {
  const page = await board.top({ limit: 20, after });
  after = page.next;
  return page.entries.map((e) => `${e.rank}. ${e.player} ${e.score}`);
}
```

## See also

- [`ClientLeaderboard.around()`](/docs/client/client-leaderboard/around)
- [`Leaderboard.top()`](/docs/room/leaderboard/top), the same from room code
- [Player data, collections and leaderboards](/docs/room/guides/player-data#from-a-client)
