Leaderboards
Add global leaderboards to your game. The SDK buffers scores and sends them in batches to avoid spamming the server. Fetch rankings asynchronously with a callback.
Functions
Section titled “Functions”submit_score()
Section titled “submit_score()”QuestData.submit_score(board_name: String, score: float, metadata: Dictionary = {}, player_display_name: String = "")| Parameter | Type | Default | Description |
|---|---|---|---|
board_name | String | required | Leaderboard identifier (e.g. "weekly_highscore") |
score | float | required | The score to submit |
metadata | Dictionary | {} | Additional data stored with the entry (e.g. level, character) |
player_display_name | String | "" | Display name shown on the leaderboard |
Scores are buffered and sent every 5 seconds. If the player submits multiple scores to the same board within that window, only the highest score is sent.
get_leaderboard()
Section titled “get_leaderboard()”QuestData.get_leaderboard(board_name: String, limit: int = 10, callback: Callable = Callable())| Parameter | Type | Default | Description |
|---|---|---|---|
board_name | String | required | Leaderboard identifier |
limit | int | 10 | Number of entries to fetch (1-100) |
callback | Callable | Callable() | Called with Array of leaderboard entries |
Each entry in the callback Array is a Dictionary with: player_id, player_name, score, rank, metadata, updated_at.
Example
Section titled “Example”# Submit a score after level completionfunc _on_level_completed(score: int): QuestData.submit_score("campaign_highscore", score, { "level": current_level, "character": selected_character }, player_name)
# Display top 10func show_leaderboard(): QuestData.get_leaderboard("campaign_highscore", 10, func(entries: Array): for entry in entries: print("#%d %s - %d" % [entry["rank"], entry["player_name"], entry["score"]]) )
# Weekly leaderboard with different board namefunc submit_weekly_score(score: int): QuestData.submit_score("weekly_" + get_week_id(), score)Boss Speedrun Leaderboard
Section titled “Boss Speedrun Leaderboard”func _on_boss_defeated(boss_id: String, time_seconds: float): # Lower is better — use negative score for "fastest wins" QuestData.submit_score("speedrun_" + boss_id, -time_seconds, { "boss": boss_id, "build": get_player_build() }, player_name)How It Works
Section titled “How It Works”submit_score()buffers the score in memory- Every 5 seconds, the SDK sends all buffered scores in one request
- If multiple scores were submitted to the same board, only the highest is sent
- The server uses UPSERT logic — a player’s entry is updated if the new score is higher
get_leaderboard()fetches rankings asynchronously viaGET /v1/leaderboards/:board_name
Dashboard
Section titled “Dashboard”Manage leaderboards under Players > Leaderboards:
- Board list — All leaderboards with entry counts
- Rankings — View top players per board
- Moderation — Remove cheating entries
- Create boards — Boards are auto-created on first score submission, but you can also create them in the dashboard
Best Practices
Section titled “Best Practices”- Use descriptive board names —
"weekly_highscore"not"lb1" - Include metadata — Level, character, build info helps you analyze patterns
- Set player_display_name — Without it, the leaderboard shows player IDs
- Don’t submit on every frame — The SDK buffers for you, but call
submit_score()only at meaningful moments (level end, game over) - Rotating leaderboards — Include a time identifier in the board name (e.g.
"weekly_2026_w15")