Make your first call
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
Section titled “1. Search, with a typo”curl "https://api.thebgdb.org/v1/search?q=wingspn&limit=2"{ "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).
2. Read one game
Section titled “2. Read one game”Use the id or the slug:
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
Section titled “3. Show its cover”image, medium and thumbnail are paths on the API. Put the API’s
address in front:
<img src="https://api.thebgdb.org/v1/media/covers/1520…-w250.jpg" width="250" alt="Wingspan"/>Every file is ours: the API never sends another site’s address for an image. See Show the right cover.
In TypeScript and Python
Section titled “In TypeScript and Python”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);import requests
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"])- Find a game despite typos: search boxes, languages, paging.
- Limits and caching: before you go to production.