# The BGDB API
> An open database of board games, read over a JSON API with no key needed. Find a game despite typos, show its cover, respect the limits.
Search by name in any language, with misspellings corrected and a
light endpoint for search boxes. [Read the guide](https://docs.thebgdb.org/guides/find-a-game/).
Scan the box: the exact edition, its language and publisher, and its
game. [Read the guide](https://docs.thebgdb.org/guides/identify-an-edition/).
Three sizes of every cover, all served by us, with their dimensions
and what they show. [Read the guide](https://docs.thebgdb.org/guides/covers-and-credits/).
The limits as numbers, the headers on every answer, and what to keep
and for how long. [Read the guide](https://docs.thebgdb.org/guides/limits-and-caching/).
An MCP server for assistants, and these docs as plain text:
[llms.txt](https://docs.thebgdb.org/llms.txt) and [llms-full.txt](https://docs.thebgdb.org/llms-full.txt).
[Read the guide](https://docs.thebgdb.org/guides/mcp/).
## The API in one call
```sh
curl "https://api.thebgdb.org/v1/search?q=wingspn"
```
Every answer is JSON. A successful answer puts its payload under `data`; a
refusal sends `{ "error": "…", "code": "…" }`, where `code` is a stable name
a program can act on ([every code](https://docs.thebgdb.org/errors/)).
The full description of the API is an OpenAPI 3.1 file:
[openapi.json](https://docs.thebgdb.org/openapi.json), also served by the API itself at
`https://api.thebgdb.org/v1/openapi.json`.
## Plans
Reading needs no key. A free personal API token raises the limits. For
commercial use, the Starter plan is €49.99 a month; larger volumes, data
dumps and service levels are on request at contact@thebgdb.org. The numbers
are in [Limits and caching](https://docs.thebgdb.org/guides/limits-and-caching/).
---
# Make your first call
> Search the catalog, read one game and show its cover, in three requests and no key.
The API is at `https://api.thebgdb.org/v1`. Reading needs no key and no
account. Three calls take you from a name typed with a mistake to a game's
cover on screen.
## 1. Search, with a typo
```sh
curl "https://api.thebgdb.org/v1/search?q=wingspn&limit=2"
```
```json
{
"query": "wingspn",
"total": 2,
"page": 1,
"pages": 1,
"nextCursor": "2",
"data": [
{
"id": "2e8eb86c-73f6-4343-a04a-c546debfd484",
"slug": "wingspan",
"name": "Wingspan",
"yearPublished": 2019,
"players": { "min": 1, "max": 5 },
"thumbnail": "/v1/media/covers/1520…-w250.jpg",
"approximate": true
}
]
}
```
`approximate: true` says the game was found by correcting the query, not
as written. The answer is shortened here: every game in a list carries the
same fields (`GameSummary` in the [reference](https://docs.thebgdb.org/reference/)).
## 2. Read one game
Use the `id` or the `slug`:
```sh
curl "https://api.thebgdb.org/v1/games/wingspan"
```
The answer holds everything the catalog knows about the game: its names in
every language, credits, players, playing time, age, members' ratings and
polls, its covers. A fact nobody knows is `null`, never a guess.
## 3. Show its cover
`image`, `medium` and `thumbnail` are paths on the API. Put the API's
address in front:
```html
```
Every file is ours: the API never sends another site's address for an
image. See [Show the right cover](https://docs.thebgdb.org/guides/covers-and-credits/).
## In TypeScript and Python
```ts
const base = "https://api.thebgdb.org/v1";
const found = await fetch(`${base}/search?q=${encodeURIComponent("wingspn")}`);
const { data } = await found.json();
const game = await (await fetch(`${base}/games/${data[0].slug}`)).json();
console.log(game.data.name, game.data.yearPublished);
```
```python
base = "https://api.thebgdb.org/v1"
found = requests.get(f"{base}/search", params={"q": "wingspn"}, timeout=10).json()
game = requests.get(f"{base}/games/{found['data'][0]['slug']}", timeout=10).json()
print(game["data"]["name"], game["data"]["yearPublished"])
```
## Next
- [Find a game despite typos](https://docs.thebgdb.org/guides/find-a-game/): search boxes, languages, paging.
- [Limits and caching](https://docs.thebgdb.org/guides/limits-and-caching/): before you go to production.
---
# Find a game despite typos
> Search games by name in any language, with misspellings corrected, and offer suggestions while someone types.
People type game names badly, in their own language, and with the
punctuation left out. Two endpoints cover it:
| | `GET /search` | `GET /suggest` |
| ------- | -------------------------------------------------------------- | ---------------------------------------- |
| For | a results page | a search box, at every key press |
| Returns | games (and, with `type=all`, people and publishers in `terms`) | games and up to 3 people or publishers |
| Paging | `page` or `cursor` | none: one short list |
| Answer | full `GameSummary` objects | a slimmer `Suggestion`, with `thumbnail` |
## Search
```sh
curl "https://api.thebgdb.org/v1/search?q=brass%20birmigham"
```
- **Every word, any order, any name.** A game matches when one of its names
(the main one or an alternate one, in any language) contains every word of
`q`. Case, accents and punctuation are ignored: `flugelschlag` finds
Flügelschlag, `catan!` finds Catan.
- **Misspellings.** When fewer than `limit` games match as written, games
with a close name are added after them, each marked `approximate: true`.
`cattan` finds Catan, `wingspn` finds Wingspan. Show these as "Did you
mean…" if your interface tells them apart.
- **Which name matched.** `matchedName` says which alternate name was found
when it was not the main one, so you can show "Die Siedler von Catan (Catan)".
- **Order.** A name equal to the query first, then names starting with it,
then a word starting with it, then names containing it; within each, the
better-known games first.
### Names in the reader's language
Send `lang` (a BCP 47 code such as `fr`, `ja` or `pt-BR`):
```sh
curl "https://api.thebgdb.org/v1/search?q=aventuriers&lang=fr"
```
A game with a name in that language comes back with it as `name`, and its
main name as `originalName`. A regional code falls back on its language
(`fr-CA` on `fr`).
### Pages
`limit` sets the page size. Go on with the `nextCursor` of the previous
answer as `cursor`, or ask for a numbered `page`:
```sh
curl "https://api.thebgdb.org/v1/search?q=catan&limit=24&page=2"
```
Send one of `page` or `cursor`, not both (`invalid_page`). A page past the
last is refused with `page_out_of_range`.
### People and publishers
`type=people` finds designers and artists, `type=publishers` publishers,
and `type=all` games plus up to 10 people and publishers in `terms` on the
first page:
```sh
curl "https://api.thebgdb.org/v1/search?q=feld&type=people"
```
## Suggestions for a search box
`GET /suggest` answers in a few milliseconds from the search index, with the
same matching and order:
```sh
curl "https://api.thebgdb.org/v1/suggest?q=wings&lang=en"
```
Each game carries its `thumbnail` (our small copy of the cover), so the list
can show covers at once. Designers, artists and publishers come back with
their `kind`. Call it as the person types, after a short pause (150 to 250
ms) so a fast typist does not send a request per letter.
## In code
```ts
async function findGames(query: string, lang = "en") {
const url = new URL("https://api.thebgdb.org/v1/search");
url.searchParams.set("q", query);
url.searchParams.set("lang", lang);
const response = await fetch(url);
if (!response.ok) throw new Error((await response.json()).code);
const { data } = await response.json();
return data.map((game) => ({
slug: game.slug,
name: game.name,
guessed: game.approximate === true,
}));
}
```
```python
def find_games(query, lang="en"):
response = requests.get(
"https://api.thebgdb.org/v1/search",
params={"q": query, "lang": lang},
timeout=10,
)
body = response.json()
if not response.ok:
raise RuntimeError(body["code"])
return [(g["slug"], g["name"], g.get("approximate", False)) for g in body["data"]]
```
:::tip[What to cache, and for how long]
Search and suggestion answers are cached by us for everyone until the
catalog changes, and a cached answer does not count against your limits.
On your side, keep a query's results for a few minutes; keep the `id` of the game someone picked for good: `GET /games/{id}` also
accepts a slug the game had before, or the id of an entry merged into it,
and answers with the game under its current address.
:::
---
# Identify an edition by its barcode
> Turn the barcode on a box into the exact edition and its game, one at a time or a hundred at once, and handle a barcode we do not know yet.
The barcode on the back of a box names an edition: its language, its
publisher, its print run. Scan it, and the API tells you which game it is
and which edition of it.
## One barcode
```sh
curl "https://api.thebgdb.org/v1/editions?ean=4002051694104"
```
`ean` takes the 13 digits of an EAN-13, or the 12 of a UPC-A (boxes sold in
North America). Spaces and dashes are ignored; the check digit must be
right, so a misread scan is refused (`invalid_ean`, 400) instead of
matching another box.
The answer gives the barcode as EAN-13 and every edition it is printed on,
each with its game:
```json
{
"ean": "4002051694104",
"data": [
{
"edition": {
"id": "…",
"slug": "de-kosmos-2015-k3x9q2",
"name": null,
"original": false,
"language": "de",
"publisher": { "slug": "kosmos", "name": "Kosmos" },
"year": 2015,
"ean": "4002051694104",
"cover": { "image": "/v1/media/covers/….jpg", "thumbnail": "/v1/media/covers/…-w250.jpg" }
},
"game": { "id": "…", "slug": "catan", "name": "Catan" }
}
]
}
```
The answer is shortened here; `game` is a full game summary, the same as in
search results. There is usually one result. A publisher sometimes reuses
a barcode for a reprint, and then you get each edition it is printed on.
A barcode can match in three ways: an edition's own barcode, the game's
barcode (which is its original edition's), or a barcode a source gave the
game. Each call counts as one game read against the weekly
[limits](https://docs.thebgdb.org/guides/limits-and-caching/).
### A barcode we do not know yet
`barcode_not_found` (404) means no edition in the catalog carries it yet.
Offer the person a name search instead ([Find a game despite
typos](https://docs.thebgdb.org/guides/find-a-game/)), and keep the barcode: the catalog grows
every day.
```ts
async function fromBarcode(scanned: string) {
const url = new URL("https://api.thebgdb.org/v1/editions");
url.searchParams.set("ean", scanned);
const response = await fetch(url);
const body = await response.json();
if (response.ok) return body.data; // [{ edition, game }, …]
if (body.code === "barcode_not_found") return []; // Ask for the name instead.
if (body.code === "invalid_ean") throw new Error("Scan it again");
throw new Error(body.code);
}
```
```python
def from_barcode(scanned):
response = requests.get(
"https://api.thebgdb.org/v1/editions", params={"ean": scanned}, timeout=10
)
body = response.json()
if response.ok:
return body["data"] # [{"edition": ..., "game": ...}, ...]
if body["code"] == "barcode_not_found":
return [] # Ask for the name instead.
raise RuntimeError(body["code"])
```
## The edition's own page
Each edition has a `slug`, its address under its game. Read everything we
hold about it (the front and back of its box, the languages of its rules,
its rulebooks, what differs from the original edition):
```sh
curl "https://api.thebgdb.org/v1/games/catan/editions/de-kosmos-2015-k3x9q2"
```
The same edition is shown to people at
`https://thebgdb.org/games/catan/editions/de-kosmos-2015-k3x9q2`.
## A hundred at once
On a paid plan, `POST /lookup` takes up to 100 barcodes and ids in one
request, for a shop's catalog or a collection import:
```sh
curl -X POST "https://api.thebgdb.org/v1/lookup" \
-H "Authorization: Bearer bgdb_…" \
-H "Content-Type: application/json" \
-d '{ "eans": ["4002051694104", "0841333100667"], "ids": ["catan"] }'
```
Each result names what was sent (`ean` or `id`) and what it found
(`found`, a list of editions with their games); a barcode that cannot be
read has an `error`. Every item counts as a request and a game read. Without
a paid plan the answer is `paid_plan_required` (403): look barcodes up one
at a time with `GET /editions?ean=`.
:::tip[What to cache, and for how long]
A barcode keeps naming the same edition: keep a match for a month. Ask
again for a `barcode_not_found` after a week or so, when the person comes
back.
:::
---
# Show the right cover
> Pick the right size of a game's cover, lay it out before it loads, choose the box of the reader's language, and credit what needs credit.
Every game that has a cover comes with it in three sizes, its dimensions
and what the picture shows. Every file is stored and served by us: the API
never sends another site's address for an image.
## The three sizes
Each game object (in lists and on its own) carries:
| Field | What it is |
| --------------------------- | ----------------------------------------------------------------- |
| `image` | The main cover, the original edition's box front. |
| `medium` | The same, 500 pixels wide: cards and small screens. |
| `thumbnail` | The same, 250 pixels wide: lists and search results. |
| `imageWidth`, `imageHeight` | The size of `image` in pixels, to keep its place before it loads. |
All three are paths on the API (they start with `/v1/media/`): put
`https://api.thebgdb.org` in front. `medium` and `thumbnail` are the same
path as `image` when the cover is no wider than that size, and for
members' photos. A game with no cover we hold has `null` in all three.
```html
```
Set `width` and `height` from `imageWidth` and `imageHeight` (they can be
`null`: then reserve a square), so the page does not jump when the image
arrives. Covers are not all square: show them whole (`object-fit:
contain`), never cropped.
## Is it a good cover?
- `imageKind` says what the picture shows: `box_front` is the whole front of
the box; the [reference](https://docs.thebgdb.org/reference/) lists the others.
- `imageAcceptable` is `true` for a good cover: the whole front of the box,
no person in it, a sharp enough picture, at least 300 pixels on its short
side. `false` means a better one is wanted; you may prefer your own
placeholder then.
- `imageLanguage` is the language of the edition on the box, when a source
states it. It is usually `null`.
To list only games with a good cover, filter the list:
```sh
curl "https://api.thebgdb.org/v1/games?cover=ok&order=ranked&limit=24"
```
## The box in the reader's language
`GET /games/{id}` also returns `covers`: the main cover first (`primary:
true`), then the box of each other edition or name the game is sold under,
and members' photos of a box that say which edition they show. Each carries
its `language`, its `edition` and the `name` printed on it:
```ts
function coverFor(game, lang: string) {
const local = game.covers.find(
(c) => c.language === lang && c.kind === "box_front",
);
return local ?? game.covers.find((c) => c.primary) ?? null;
}
```
```python
def cover_for(game, lang):
local = next((c for c in game["covers"] if c["language"] == lang and c["kind"] == "box_front"), None)
return local or next((c for c in game["covers"] if c["primary"]), None)
```
## Credits
Some covers come from Wikimedia Commons, and some descriptions from
Wikipedia, under licences that ask for credit. `GET /credits` lists exactly
those, with the source, the licence and the author:
```sh
curl "https://api.thebgdb.org/v1/credits?kind=image&limit=50"
```
Show the credit wherever you show such an image. Nothing else needs a
credit line. Using the images and data is subject to the
[terms](https://thebgdb.org/terms#images).
:::tip[What to cache, and for how long]
A file's address never changes its content: cache images for as long as you
like (we send `immutable`). When a game's cover is replaced, the game
points to a new address. Re-read a game's fields at least daily if you show
them.
:::
---
# Limits, caching and terms
> The request limits as numbers, the headers on every answer, what to do on a 429, and what to cache for how long.
Reading needs no key. Limits keep the catalog fast for everyone; they are
counted per address without a token, and per member with one.
## The limits
| | Without a token | Free API token | Starter plan |
| ----------------- | ------------------------------------ | --------------------------------- | ----------------------- |
| Requests a minute | 60 | 90 | 1,200 |
| Requests a day | 2,000 | 3,000 | no daily limit |
| Requests a week | 5,000 | 7,500 | 200,000 |
| Games read a week | 500 | 750 | 40,000 |
| Counted per | address (an IPv6 address by its /64) | member, all their tokens together | member |
"Games read" counts `GET /games/{id}` and the routes under it. Days are UTC
days; weeks start on Monday at 00:00 UTC.
- **Free API token**: a member whose email address is confirmed creates up
to 2 on their account page at thebgdb.org, and sends
one as `Authorization: Bearer bgdb_…`.
- **Starter plan**: for commercial use, €49.99 a month, from
[thebgdb.org/developers](https://thebgdb.org/developers).
- **More**: larger volumes, data dumps and service levels on request at
contact@thebgdb.org.
The same numbers, as JSON, with your own limits when you send a token:
```sh
curl "https://api.thebgdb.org/v1/limits"
```
## The headers
Every counted answer carries:
| Header | Meaning |
| -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| `X-RateLimit-Limit` | Your daily limit (the weekly one on a paid plan, which has no daily limit). |
| `X-RateLimit-Remaining` | What is left of it. |
| `X-RateLimit-Reset` | When it starts again, in seconds since 1970. |
| `x-ratelimit-weekly-limit`, `x-ratelimit-weekly-remaining`, `x-ratelimit-weekly-reset` | The same for the week. |
| `x-ratelimit-weekly-detail-*` | The same for the games read this week, on `GET /games/{id}`. |
## When you are refused
Beyond a limit the API answers `429` with a `retry-after` header (seconds to
wait) and the code `rate_limited` (a minute's or a day's limit) or
`weekly_limit` (a week's):
```ts
async function get(url: string): Promise {
for (let attempt = 0; attempt < 3; attempt++) {
const response = await fetch(url);
if (response.status !== 429) return response;
const wait = Number(response.headers.get("retry-after") ?? 60);
const { code } = await response.json();
if (code === "weekly_limit" || wait > 120) return response; // Not worth waiting for.
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
}
return fetch(url);
}
```
```python
def get(url, **params):
for _ in range(3):
response = requests.get(url, params=params, timeout=10)
if response.status_code != 429:
return response
wait = int(response.headers.get("retry-after", "60"))
if response.json()["code"] == "weekly_limit" or wait > 120:
return response
time.sleep(wait)
return requests.get(url, params=params, timeout=10)
```
## Caching
- **Catalog answers** are cached by us for up to five minutes, so a change
can take that long to show. Search and suggestion answers are cached for
everyone until the catalog changes, and a cached answer is not counted
against your limits.
- **Images** never change at a given address: keep them as long as you like.
- **On your side**, keep a game you show for a day before reading it again;
keep search results for a few minutes; keep the `id` of a game for good.
- **Do not** walk the whole catalog game by game: `GET /games` lists games
a page at a time with their summaries, and `GET /index/games` gives names
and slugs by the hundred.
## Terms
Using the API and what it returns is subject to the
[terms](https://thebgdb.org/terms#api): the licence of the data and texts
is CC BY-NC 4.0 ([details](https://thebgdb.org/terms#license)): credit us as
**Data from thebgdb.org** with a link to https://thebgdb.org (or to the
game's page). Commercial use (a product, a service, an app or a site that
earns money) needs the Starter plan, or for larger volumes an agreement on
request.
---
# Use the MCP server
> Connect an AI assistant to the catalog with the Model Context Protocol, openly or as a member with OAuth.
The Board Game DB runs a [Model Context Protocol](https://modelcontextprotocol.io)
server, so an assistant (Claude, ChatGPT, an IDE agent) can search the
catalog and read games itself. It speaks streamable HTTP and has two
endpoints:
| Endpoint | Who | Authentication |
| -------------------------------- | --------------------------------- | ---------------------------------------------------------------------- |
| `https://mcp.thebgdb.org/mcp` | anyone | none; optionally `Authorization: Bearer bgdb_…` (a personal API token) |
| `https://mcp.thebgdb.org/member` | a member, through their assistant | OAuth 2.1 with PKCE, dynamic client registration |
## The open endpoint
Add it to your assistant as a remote MCP server:
```json
{
"mcpServers": {
"thebgdb": { "url": "https://mcp.thebgdb.org/mcp" }
}
}
```
It offers the catalog tools: searching games, reading one game, listing
games with filters, credits, anniversaries, and the generic `search` and
`fetch` tools that research assistants expect. Calls count against the same
[limits](https://docs.thebgdb.org/guides/limits-and-caching/) as the API: per address, or per member
when you send a personal API token, which also unlocks the member tools.
## The member endpoint
For an assistant acting for a member (their lists, ratings, corrections),
connect to `/member`. The assistant registers itself, sends the member to
thebgdb.org to sign in, and the member chooses what it may do on the consent
page:
| Scope | Allows |
| ------------------- | -------------------------------------------------------------------------- |
| `catalog:read` | Read the public catalog: games, credits, rules, tutorials (always granted) |
| `lists:read` | See the member's lists, private ones included |
| `lists:write` | Create, change and delete lists, add or remove games |
| `ratings:read` | See the games the member rated |
| `ratings:write` | Rate games and take ratings back |
| `corrections:read` | See the corrections the member proposed and what moderators decided |
| `corrections:write` | Propose corrections to games in the member's name |
| `offline_access` | Stay connected without asking again for 30 days |
Each tool needs one scope; an assistant only sees the tools its scopes
allow. A write scope includes the matching read scope.
## What the server says about itself
```sh
curl "https://mcp.thebgdb.org/"
```
returns its endpoints, how to authenticate and every scope with its meaning.
:::tip[For agents reading these docs]
These pages are also plain Markdown: add `.md` to any guide's address, or
read [llms.txt](https://docs.thebgdb.org/llms.txt) (an index) and [llms-full.txt](https://docs.thebgdb.org/llms-full.txt)
(every guide in one file). The API itself is described by
[openapi.json](https://docs.thebgdb.org/openapi.json).
:::