# RoomClient: leaderboard() method

> The leaderboard() method of the RoomClient interface returns one of the project's leaderboards, declared in irt.config.ts, for this player.

The **`leaderboard()`** method of the [`RoomClient`](/docs/client/room-client) interface returns a [`ClientLeaderboard`](/docs/client/client-leaderboard): a collection declared with leaderboard settings in `irt.config.ts`, which keeps players' scores per period, read and submitted to as this player.

## Syntax

```ts
leaderboard(name)
```

### Parameters

`name`
: A string: the collection's name, as `irt.config.ts` declares it.

### Return value

A [`ClientLeaderboard`](/docs/client/client-leaderboard), whose [`submit()`](/docs/client/client-leaderboard/submit), [`top()`](/docs/client/client-leaderboard/top) and [`around()`](/docs/client/client-leaderboard/around) methods return promises. Getting it makes no request, and doesn't check `name`: a collection that isn't declared, or has no leaderboard settings, fails each call with `E_UNKNOWN`.

### Exceptions

None.

## Description

The board's calls go to the router over HTTP, with the connection's token or guest, so they need no open connection to the room. They're the same calls [`dataClient()`](/docs/client/dataclient) makes. Nothing is cached on the client: every call goes to the router.

A client submits only its own score, and only to a board with `clientWrite: "own"`. A score a client submits can be faked, so for a score that matters, submit it from room code with [`room.leaderboard()`](/docs/room/room/leaderboard) instead.

Calls reject with [`DataError`](/docs/room/data-error), which `@irtio/client` also exports: `E_UNAVAILABLE` when the router or the data service can't be reached, `E_LIMIT` over the router's 10 calls a second per address and per player and `E_FORBIDDEN` for what the board's settings don't allow.

## Examples

### Showing the player's rank after a run

A casual puzzle game, whose board takes scores from clients, submits the player's score and shows their rank with the scores either side.

```ts
// rank.ts
import { DataError, type ReadyRoomClient } from "@irtio/client";

export async function showRank(room: ReadyRoomClient, score: number) {
  const board = room.leaderboard("daily-puzzle");
  try {
    await board.submit(score);
    const around = await board.around({ period: "day", count: 2 });
    if (around) console.log(`You're number ${around.rank} today`);
  } catch (e) {
    if (e instanceof DataError && e.code === "E_UNAVAILABLE") console.warn("The leaderboard can't be reached.");
    else throw e;
  }
}
```

## See also

- [`ClientLeaderboard`](/docs/client/client-leaderboard)
- [`RoomClient.collection()`](/docs/client/room-client/collection)
- [`Room.leaderboard()`](/docs/room/room/leaderboard), for scores that can't be faked
- [Player data, collections and leaderboards](/docs/room/guides/player-data)
