Game leaderboards
Publisher studio · Your player profile · OpenAPI · Plain text guide
Two steps for a hosted build. No SDK, API key, or game ID in your code.
1. Create a board in Publisher studio > your game > Leaderboards, or POST {key:"high",title:"High score"} to /api/v1/games/GAME_ID/leaderboards with a games:write key. 2. When a run ends, call window.GBG?.submitScore('high', score). That is all.
Good Browser Games injects window.GBG into the entry HTML of every hosted build before your scripts run. Every player who opens your game on the site gets a player ID, signed in or not. Signed-out players play as guests: their scores are saved, and they move to the player's account when the player signs in. A score ranks on the public board once its player has an account with a username. The game page shows your boards beside the player, refreshes after each submitted score, and asks guests to sign up to keep their scores.
Keep your best score in your own save too. The player ID can change when a guest signs in, and the client reads a fresh one on each play. Never put a player ID in a public response, log, analytics event, or link.
JavaScript
// Hosted builds: window.GBG is already set. It is undefined when your game runs elsewhere.
const result = await window.GBG?.submitScore('high', 420, { level: 3 }); // null without a player
// result: { accepted: true, guest: true|false }. Errors reject with the API message.
// Optional reads for an in-game board:
const top = await window.GBG?.getLeaderboard('high', { range: 'week', limit: 10 }); // {entries, nextCursor}
const mine = await window.GBG?.getMyScore('high'); // {handle, score, rank, date} or null while unranked
// Optional daily challenge: a board created with daily:true files each score
// under the UTC day it was played for. Seed today's puzzle from the same day:
const day = window.GBG?.challengeDay(); // "2026-10-19", rolls over at midnight UTC
await window.GBG?.submitDailyScore('daily', 420, { moves: 31 }, day);
const today = await window.GBG?.getLeaderboard('daily'); // today's challenge by default
const past = await window.GBG?.getLeaderboard('daily', { day: '2026-10-18' });
// A build with its own Content-Security-Policy gets no injection. Load the same
// client yourself, then pass your game ID first:
// <script src="https://goodbrowsergames.com/developers/gbg.js"></script>
// GBG.submitScore('GAME_ID', 'high', 420)Unity WebGL (C#)
// Assets/Plugins/WebGL/GBG.jslib — forwards to the injected window.GBG client.
mergeInto(LibraryManager.library, {
GBGSubmitScore: function (board, score) {
if (window.GBG) window.GBG.submitScore(UTF8ToString(board), score).catch(console.warn);
}
});
// C# (any MonoBehaviour). Add using System.Runtime.InteropServices.
#if UNITY_WEBGL && !UNITY_EDITOR
[DllImport("__Internal")] private static extern void GBGSubmitScore(string board, double score);
#else
private static void GBGSubmitScore(string board, double score) {}
#endif
void OnRunEnded(int score) => GBGSubmitScore("high", score);Godot 4 (GDScript)
# Call when a run ends. Does nothing outside a web export or off Good Browser Games.
func submit_score(score: float) -> void:
if OS.has_feature("web"):
JavaScriptBridge.eval("window.GBG && window.GBG.submitScore('high', %s).catch(console.warn)" % score)External URL games
Load https://goodbrowsergames.com/developers/gbg.js and call GBG.submitScore('GAME_ID', 'high', score), or read new URLSearchParams(location.hash.slice(1)).get('gbg_player') in the client and POST {playerId, score, meta?} to https://goodbrowsergames.com/api/v1/games/GAME_ID/leaderboards/BOARD_KEY/scores yourself. The fragment is not sent to your server or in Referer headers. In the dashboard, opt into query delivery only if your server needs the ID; then read the gbg_player query parameter. Query values can enter server and proxy logs. The registered origin is the origin of the game's iframe URL. The API permits CORS only for that origin and GBG's play origin. Serve external games over HTTPS. Never request credentials with a score submission.
Boards and public reads
GET /api/v1/games/GAME_ID/leaderboards/KEY?range=day|week|all&limit=10&cursor=0 returns entries {handle,score,rank,date} and nextCursor (null on the last page). Day starts at midnight UTC; week is the past seven days. Follow nextCursor unchanged. GET the same path plus /players/PLAYER_ID returns {player: {handle,score,rank,date} | null}. Treat that URL as private. Public entries never include email, playerId, or metadata.
Daily challenges
Daily boards are optional. Create a board with daily:true (Mode: Daily challenge in the dashboard) for a game that gives every player the same puzzle, course, or seed each day. Each score files under a challengeDay (YYYY-MM-DD, UTC). Send challengeDay with the score, or call GBG.submitDailyScore with the day your run was seeded from. Without it, the server files the score under today. The server accepts today and yesterday, so a run that started before midnight UTC still counts for its challenge. Other days return 400.
On a daily board, range defaults to day and means today's challenge; week means the last seven challenges; all ranks every challenge together. Add day=YYYY-MM-DD to read one past challenge. Responses include challengeDay. Best-per-player applies within each read. Changing a populated board to or from daily mode needs a reset first. Creating a daily board, or switching one to daily, tags your game Daily Challenge so players can find it. You can also set the tag yourself on the Leaderboards page or with PATCH /api/v1/games/GAME_ID {dailyChallenge:true}.
Highest scores come first for desc; lowest for asc. Earlier scores win ties, then entry ID breaks exact timestamp ties. Best-per-player is calculated within the selected range. integer accepts whole numbers, time_ms accepts nonnegative whole milliseconds, decimal accepts finite numbers. Values must be within the safe integer magnitude. Metadata is limited to 2048 UTF-8 bytes. Score bodies are limited to 8192 bytes. Limits are 20 submissions per player per game per minute and 100 per IP per minute. Rate errors return 429; retry after 60 seconds. All errors use {error,message}.
Publisher API and moderation
Use Authorization: Bearer YOUR_PUBLISHER_KEY without Cookie or Origin headers. games:read can list boards and entries. games:write can create, edit, reset, delete, hide, and submit verified scores from your backend. Do not ship your API key in a game build.
GET/POST /api/v1/games/GAME_ID/leaderboards GET/PATCH/DELETE /api/v1/games/GAME_ID/leaderboards/KEY POST /api/v1/games/GAME_ID/leaderboards/KEY/reset GET /api/v1/games/GAME_ID/leaderboards/KEY/entries?cursor=0 PATCH /api/v1/games/GAME_ID/leaderboards/KEY/entries/ENTRY_ID with {hidden:true} POST /api/v1/games/GAME_ID/leaderboards/KEY/scores with {playerId,score,meta?,challengeDay?} PATCH /api/v1/games/GAME_ID/leaderboard-settings with {delivery:"fragment"} or {delivery:"query"}
Create body: {key:"high",title:"High score",sort:"desc",format:"integer",minScore:0,maxScore:1000000,onePerPlayer:true,daily:false,status:"active"}. PATCH accepts these fields individually. Max five boards, including archived boards. Archive with {status:"archived"}; archived boards reject scores and public reads. Reset deletes all scores. Delete removes the board. Reset before changing sort, format, best-per-player, or daily mode on a populated board. Bounds apply to new submissions. Hidden entries can be restored. Flagged entries stay hidden regardless of the hidden toggle. Publishers moderate in their dashboard; admins can open the same controls from a game's admin page. Admin moderation is audited.
Anyone holding a playerId can submit as that player for that game. Client scores cannot prove integrity. Validate scores on your backend and submit with a publisher key when needed. Bot and publisher self-play flags keep client submissions off public boards. Your backend validates trusted server submissions; publisher self-play still stays off public boards. A successful submission means accepted, not necessarily publicly ranked.