> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Scores

> Leaderboards a game reports scores to through the OpenGame SDK, ranked by OpenGame, with each score stored as the game's own claim.

A leaderboard holds the scores a game reports for the players. A score is the game's claim: OpenGame stores and ranks it and does not verify it. Games call these routes through the SDK.

[Authentication](https://docs.opengame.io/api-reference/authentication.md) covers each credential, and [errors](https://docs.opengame.io/api-reference/errors.md) covers the JSON error body.

## 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

**host** `string` *required*

The game's host label, for example `derkoloss`. Optional on a private preview. Example: `derkoloss`.

**board** `string` *required*

A board key the game declares in `opengame.json`. At most 48 characters. Matches `^[a-z0-9][a-z0-9_-]*$`. Example: `rounds`.

**view** `string` (default: top)

One of `top`, `me` or `around`.

**limit** `integer` (default: 50)

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.

**offset** `integer` (default: 0)

Rows to skip before the page, for `top` only. Anything else is rejected with `invalid_score_query`. From 0 to 10,000.

**sort** `string` (default: score)

`score`, or the key of a column the board declares sortable. Each sorts in the declared order. Example: `kills`.

**filter** `string`

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

```bash cURL theme={"system"}
curl --request GET \
  --url 'https://api.opengame.gg/v1/scores?host=derkoloss&board=rounds'
```

### Response 200

Board entries, labeled as the game's claim.

```json theme={"system"}
{
  "board": "rounds",
  "direction": "desc",
  "source": "game_reported",
  "disclaimer": "Reported by the game. Not verified by OpenGame.",
  "entries": [
    {
      "player_name": "marlowe",
      "score": 14,
      "stats": {
        "kills": 212,
        "downs": 1,
        "revives": 0,
        "points": 18420,
        "time": 1284
      },
      "tags": {
        "mode": "solo"
      },
      "meta": {
        "character": "nikolai"
      },
      "created_at": "2026-10-20T21:14:03Z",
      "imported": false,
      "rank": 1
    },
    {
      "player_name": "Guest 7c3a",
      "score": 12,
      "stats": {
        "kills": 167,
        "downs": 3,
        "revives": 0,
        "points": 13905,
        "time": 1047
      },
      "tags": {
        "mode": "solo"
      },
      "meta": {
        "character": "nikolai"
      },
      "created_at": "2026-10-21T08:47:55Z",
      "imported": false,
      "rank": 2
    }
  ],
  "total": 2,
  "offset": 0,
  "sort": "score",
  "sortDirection": "desc",
  "filter": {
    "mode": "solo"
  },
  "shape": {
    "label": "Rounds survived",
    "scoreLabel": "Round",
    "format": "integer",
    "keep": "runs",
    "columns": [
      {
        "key": "kills",
        "label": "Kills",
        "format": "integer",
        "order": "desc",
        "sortable": true
      },
      {
        "key": "downs",
        "label": "Downs",
        "format": "integer",
        "order": "asc",
        "sortable": true
      },
      {
        "key": "revives",
        "label": "Revives",
        "format": "integer",
        "order": "desc",
        "sortable": true
      },
      {
        "key": "points",
        "label": "Points",
        "format": "integer",
        "order": "desc",
        "sortable": true
      },
      {
        "key": "time",
        "label": "Time",
        "format": "duration_s",
        "order": "asc",
        "sortable": true
      }
    ],
    "variants": [
      {
        "key": "mode",
        "label": "Mode",
        "values": [
          {
            "key": "solo",
            "label": "Solo"
          },
          {
            "key": "coop",
            "label": "Co-op"
          }
        ]
      }
    ]
  }
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `host and board are required`, `board is required` on a preview, or `invalid_score_query` for a bad view, board, offset, sort or filter. |
| 401 | `token_rejected`: `reason` names why. `session_rejected`: the player changed identity. Ask the page for a new session either way. |
| 403 | `origin_not_allowed`, `origin_mismatch` or `host_not_live`; on a preview, `preview_session_mismatch` or `preview_unavailable`. |
| 404 | `not_found`: the host is not live, is a preview label, or has no such board. |
| 405 | `method_not_allowed`. `Allow` lists the methods this path takes, except on a private preview, which sends no `Allow`. |
| 429 | `rate_limited`: `scope` is `public-read` for `top`, and `token`, `identity` or `address` otherwise. Wait for `Retry-After`, which is 60 seconds. |
| 500 | `internal_error`, only when OpenGame's own storage fails. Sent without CORS headers. |
| 502 | `upstream_error`: OpenGame could not read the scores. Retry later. |
| 503 | `not_configured` or `rate_limit_unavailable`, or `unavailable` with `reason` `board_query_unavailable` for a read with a filter, a sort or an offset that storage cannot answer yet. Not caused by the request. Retry later. |

## 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 as `application/json`.

**board** `string` *required*

A board key declared in opengame.json. At most 48 characters. Matches `^[a-z0-9][a-z0-9_-]*$`. Example: `rounds`.

**value** `number` *required*

Example: `12`.

**meta** `object`

At most 384 bytes. Strings up to 24 characters, so an email address does not fit.

**fields**

**label** `string`

At most 24 characters.

**mode** `string`

At most 24 characters.

**level** `string`

At most 24 characters.

**character** `string`

At most 24 characters.

**duration\_ms** `number`

**accuracy** `number`

**combo** `number`

**stats** `object`

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.

**tags** `object`

The run's value for any of the board's variants, such as `{"mode":"solo"}`.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://api.opengame.gg/v1/scores' \
  --header "Authorization: Bearer $OPENGAME_SESSION" \
  --header 'Content-Type: application/json' \
  --data '{
  "board": "rounds",
  "value": 12,
  "stats": {
    "kills": 167,
    "downs": 3,
    "time": 1047
  },
  "tags": {
    "mode": "solo"
  }
}'
```

### Response 200

Stored, clamped or rejected as implausible.

```json theme={"system"}
{
  "ok": true,
  "state": "ok",
  "stored": 12,
  "best": true,
  "ignored": []
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_body`: not a JSON object, or over 2 KB. `rejected`: `reason` names the bad field (`board`, `value`, a `meta` key, a stat that is not a finite number, or a tag the board does not declare). |
| 401 | `token_rejected`: `reason` names why, and `mint` names where a new session comes from on a public game. `session_rejected`: the player changed identity. Ask the page for a new session either way. |
| 403 | `origin_not_allowed`, `origin_mismatch`, `host_not_live`, `preview_session_mismatch` or `embed_not_allowed`; on a preview, `preview_unavailable`, including a preview that has ended. |
| 404 | `rejected`: no active board with that key for this game, and `reason` names so. |
| 405 | `method_not_allowed`. `Allow` lists the methods this path takes, except on a private preview, which sends no `Allow`. |
| 429 | `rate_limited`: `scope` names the budget that ran out. Wait for `Retry-After`, which is 60 seconds. |
| 500 | `internal_error`: OpenGame could not save the score at all. Sent without CORS headers, so a frame sees a failed request. Retry later. |
| 502 | `upstream_error`: OpenGame rejected the score or did not answer, including for a board that was turned off or a version that is gone. Retry later. |
| 503 | `not_configured`, `rate_limit_unavailable` or `embed_unavailable`, or `unavailable` with `reason` `runs_unavailable` for a run with stats or tags that storage cannot take yet. Not caused by the request. Retry later. |

## 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

```bash cURL theme={"system"}
curl --request GET \
  --url 'https://api.opengame.gg/v1/player/stats' \
  --header "Authorization: Bearer $OPENGAME_SESSION"
```

### Response 200

One line per board, with the player's entry or null.

```json theme={"system"}
{
  "source": "game_reported",
  "disclaimer": "Reported by the game. Not verified by OpenGame.",
  "boards": [
    {
      "board": "career",
      "label": "Career",
      "keep": "career",
      "entry": {
        "score": 12450,
        "stats": {
          "kills": 318,
          "played": 41
        },
        "tags": {},
        "meta": {},
        "created_at": "2026-11-11T19:04:12Z",
        "imported": false
      }
    },
    {
      "board": "matches",
      "label": "Matches",
      "keep": "runs",
      "entry": {
        "score": 610,
        "stats": {
          "kills": 14
        },
        "tags": {},
        "meta": {},
        "created_at": "2026-11-11T19:04:12Z",
        "imported": false
      }
    },
    {
      "board": "time_trial",
      "label": "Time trial",
      "keep": "best",
      "entry": null
    }
  ]
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_query`: the request included a query string. The route takes none. |
| 401 | `token_rejected`: `reason` names why and `mint` names where a new session comes from. `session_rejected`: the player changed identity. Ask the page for a new session either way. |
| 403 | `origin_not_allowed`, `origin_mismatch`, `host_not_live`, `preview_session_mismatch` or `embed_not_allowed`; on a preview, `preview_unavailable`, including a preview that has ended. |
| 404 | `not_found`: the game is gone. |
| 405 | `method_not_allowed`. `Allow` lists `GET` and `OPTIONS`. |
| 429 | `rate_limited`: `scope` names the budget that ran out. Wait for `Retry-After`, which is 60 seconds. |
| 500 | `internal_error`, sent without CORS headers, so a frame sees a failed request. Retry later. |
| 502 | `upstream_error`: OpenGame could not read the boards. Retry later. |
| 503 | `not_configured` or `rate_limit_unavailable`, or `unavailable` with `reason` `stats_unavailable` while storage cannot answer this read yet. Not caused by the request. Retry later. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.