# ClientLeaderboard

> The ClientLeaderboard interface of the Client API is a leaderboard as a client sees it, which submits and finds its own player's score.

The **`ClientLeaderboard`** interface of the [Client API](/docs/client) is a leaderboard as a client sees it: the Room API's [`Leaderboard`](/docs/room/leaderboard), with `submit()` and `around()` for the player the client is. [`DataClient.leaderboard()`](/docs/client/data-client/leaderboard) and [`RoomClient.leaderboard()`](/docs/client/room-client/leaderboard) return one.

## Instance properties

`ClientLeaderboard.name`
: The board's name, as `irt.config.ts` declares it. Read only.

## Instance methods

[`ClientLeaderboard.submit()`](/docs/client/client-leaderboard/submit)
: Applies this player's score to every period the board keeps.

[`ClientLeaderboard.top()`](/docs/client/client-leaderboard/top)
: Resolves with a page of the best entries of a period.

[`ClientLeaderboard.around()`](/docs/client/client-leaderboard/around)
: Resolves with a player's rank and the entries either side, this player's by default.

## Description

Reading a board needs its `clientRead: true`, and submitting needs its `clientWrite: "own"`. Periods, ranks and the `keep` rule are as the [Description](/docs/room/leaderboard#description) section of `Leaderboard` describes. Nothing is cached: every `top()` and `around()` is a call to the router.

A score a client submits can be faked: any player can send any number. Submit from room code, which decides the score, for any board that matters.

## Examples

### Submitting a run and showing the standings

After a run, the client submits the player's points and shows the day's top five.

```ts
// arcade-run.ts
import { dataClient } from "@irtio/client";

const board = dataClient().leaderboard("arcade");

export async function finishRun(points: number) {
  await board.submit(points);
  const { entries } = await board.top({ period: "day", limit: 5 });
  for (const e of entries) console.log(`${e.rank}. ${e.player} ${e.score}`);
}
```

## See also

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