Read a leaderboard
GET https://api.opengame.gg/v1/scores
Authentication: Optional: a game session token.
top needs no session, is cached 30 seconds, and is readable in a browser only from a live game host. me returns the player’s entry and around returns 10 entries either side of it; both need the game’s session from that game’s host and are not cached. limit and offset apply to top only. sort ranks by the score or by a sortable column, each in the order the board sets for it, and filter limits the board to runs with those tags. With no filter, the page ranks all the board’s runs. On a keep: "best" board, each player appears once, by their best run for the sorted column; on a keep: "runs" board, each stored run is a row. Only runs with state ok appear, so a player whose best was clamped gets an empty me. From a private preview, each view needs the preview session, host may be left out, and only that preview’s scores are returned.
Parameters
Query
The game’s host label, for example
derkoloss. Optional on a private preview. Example: derkoloss.A board key the game declares in
opengame.json. At most 48 characters. Matches ^[a-z0-9][a-z0-9_-]*$. Example: rounds.Never rejected: a value that is not a whole number of 1 or more uses the default, and a larger one is clamped. From 1 to 100.
Rows to skip before the page, for
top only. Anything else is rejected with invalid_score_query. From 0 to 10,000.score, or the key of a column the board declares sortable. Each sorts in the declared order. Example: kills.Tags to narrow the board to, written
key:value and joined with commas, such as mode:coop. Each key and value must be declared by the board. Example: mode:solo.Request
cURL
Response 200
Board entries, labeled as the game’s claim.Errors
Submit a score
POST https://api.opengame.gg/v1/scores
Authentication: A game session token.
Call it from a live game frame with the session token. Who, which game and which version all come from the token. The body includes the board, the value, and optionally meta, the run’s stats and the tags; any other top-level key, and any stat the board does not declare, is dropped and named in ignored. A tag the board does not declare is rejected. A keep: "best" board stores one run per player for each combination of tags; a keep: "runs" board stores each run, up to runsPerPlayer per player for each combination, and after that replaces that player’s lowest-ranked run. Each stat is checked with the column’s bounds as the value is with the board’s, and the run gets the lower state. A value above the board’s plausible_max is stored as plausible_max, with state clamped when it is within 10 times the bound and rejected beyond that. Values below plausible_min are handled the same way. Only scores with state ok appear on the board. From a private preview, the score goes to that preview’s boards and the response includes preview: true.
Body
Sent asapplication/json.
A board key declared in opengame.json. At most 48 characters. Matches
^[a-z0-9][a-z0-9_-]*$. Example: rounds.The run’s number for any of the board’s columns, keyed by column. Each value is a finite number from -1e15 to 1e15, and 0 or at least 1e-6 from it; at most 512 bytes as JSON.
Request
cURL
Response 200
Stored, clamped or rejected as implausible.Errors
Read the player’s entry on each board
GET https://api.opengame.gg/v1/player/stats
Authentication: A game session token.
The session player’s best accepted entry on each active board the game declares, in key order, and on a career board their row for all runs. og.player.stats() in the SDK. The request takes no parameters: the game and the player come from the session, so it cannot read another player or another game, and any query string is a 400. Never cached. Rate limited as me() is, per session, player and address. A private preview reads the boards.
Request
cURL