Leaderboards

Leaderboards rank the signed-in players of your game every week. Players see them on your game's page and in a sheet your game can open over itself; the best of each week win trophies that stay on their profile. You set up the boards in the dashboard (Dashboard → your game → Leaderboards), then send scores from the game with the SDK or from your own server.

Boards and seasons

A game has up to 5 boards. Each board has:

SettingWhat it does
Id1 to 32 lowercase letters, numbers and dashes (main, best-time). Your code uses it; it can't change later.
TitleEnglish and Spanish required; other languages fall back to English.
What it measuresscore, time (milliseconds) or count.
Best isHigher or lower (times default to lower).
Each submitKeeps the player's best, or adds to their total (coins collected, levels cleared).
Lowest / highest allowed valueValues outside the range are refused with range. Leave empty for no limit.
Seconds between submitsPer player and board (default 2). Too soon answers cooldown.
Shown asA whole number, 1 to 3 decimals, or a time (1:02.345). Values are rounded to it.
Server onlyOnly your server can submit (SDK submits answer server-only).

Once a board has scores, what it measures, its order and its mode are fixed: create another board to change them.

Seasons are weekly: from Monday 00:00 UTC to the next Monday. Each board shows this week and all time. When a week ends it is closed: the next one starts empty, and past weeks are kept for 12 weeks.

Ranks

Every board ranks players three ways:

  • Everyone (global): all players of the board.
  • Your country (country): players from the same country as the player (taken, coarse, from the network when they submit; never shown to anyone).
  • Friends (friends): the player and their accepted Gamealia friends. Guests need to sign in.

Equal values share a rank; whoever got there first is listed first.

Trophies

When a week ends, its top 3 win gold, silver and bronze. On boards with at least 100 players that week, the top 1%, 5% and 10% win a trophy too. Trophies show on the player's profile and next to the board (last week's podium).

In the game (SDK)

Only signed-in players get on a board. A guest's submit answers { ok: false, reason: "signin" }: show a sign-in button (Gamealia.user.requestLogin() only runs from a button the player pressed) and submit again.

const r = await Gamealia.leaderboard.submit("main", score);
if (r.ok) {
  showToast(`Your best this week: ${r.best} (#${r.rank})`);
} else if (r.reason === "signin") {
  showButton("Sign in to save your score", async () => {
    if (await Gamealia.user.requestLogin()) await Gamealia.leaderboard.submit("main", score);
  });
}

submit(boardId, value) resolves { ok, best?, rank?, reason? }. best is the player's kept value this week (the best, or the total), rank their rank among everyone. Reasons: signin, cooldown, range, unknown-board, server-only, unavailable (offline, preview, or the player was banned from the board).

Read a board to draw it inside your game:

const top = await Gamealia.leaderboard.get("main", { scope: "global", season: "current", limit: 10 });
for (const e of top.entries) drawRow(e.rank, e.username, e.value, e.isMe);
if (top.me && !top.entries.some((e) => e.isMe)) drawRow(top.me.rank, top.me.username, top.me.value, true);

const near = await Gamealia.leaderboard.get("main", { scope: "friends", around: true, limit: 5 });

get(boardId, options) options: scope ("global", "country", "friends"; default global), season ("current" or "all"; default current), limit (1 to 50, default 10), around (true: the entries around the player instead of the top). It resolves { ok, entries, me, total }: each entry has rank, id (the player's id for your game, the same as the id of Gamealia.user.get()), username, avatarUrl, value and isMe; me is the player's own entry (also when outside entries) and total the number of players in that scope.

Or let the portal show it:

Gamealia.leaderboard.show("main"); // no id: the game's first board

show opens the portal's leaderboard sheet over the game. Your game gets pause while it is open and resume when the player closes it, like with an ad.

In the mock (local development) a board in memory with fake players answers, so you can build the screens before the board exists. Unity and Godot have the same calls: see Unity and Godot.

From your server

For competitive games, send scores from your own backend, which knows the real result. Create a server key in the dashboard (it is shown once: keep it on your server, never in the game), and turn on Server only on the board so nobody can submit from the browser.

curl -X POST https://api.gamealia.app/v1/leaderboards/<game id>/scores \
  -H "Authorization: Bearer glb_..." \
  -H "Content-Type: application/json" \
  -d '{"scores":[{"boardId":"main","playerId":"<token sub>","value":1200}]}'

playerId is the player's id for your game: the sub of the player token your server already verifies (see Player accounts). Up to 100 scores per request and 1000 requests per minute per game. The answer has one result per score, in order:

{ "ok": true, "results": [{ "ok": true, "boardId": "main", "playerId": "…", "best": 1200, "rank": 4, "improved": true }] }

A refused score has ok: false and a reason: range, unknown-board, unknown-player (that player never played your game signed in) or invalid. Server submits skip the cooldown and the server-only switch; ranges, best/total and bans still apply. A wrong or revoked key answers 401. Rotate the key in the dashboard if it leaks: the old one stops working at once.

Keep it fair

  • Prefer server submits (and Server only) for competitive games: anything a browser sends can be faked.
  • Set a realistic range: the highest score a person can reach, the fastest possible time.
  • Keep a cooldown that fits how often a run can end.
  • Send one value at the end of a run, not every frame (the portal also allows at most 30 submits per minute per player).
  • Check the Scores list in the dashboard: delete a score that looks wrong, or ban a player from a board (their scores go and later submits are refused). Gamealia can moderate too.