Search games, people and publishers by name
const url = 'https://api.thebgdb.org/v1/search?q=catan&type=games&limit=20&lang=fr';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.thebgdb.org/v1/search?q=catan&type=games&limit=20&lang=fr'With type=people or type=publishers, returns the designers and artists, or the publishers, one of whose names (their own, or a spelling merged into them) starts at a word with q: feld finds Stefan Feld, ouset media finds Ouset, case and accents ignored. A name typed whole comes first, then a word of it typed to its end, then the start of the name, then the start of a word; within that, the ones with more games first. With type=all, the games as below, and up to 10 people and publishers in terms on the first page.
By default (type=games), returns games one of whose names contains every word of q, in any order: the main name or any alternate name, in any language. A game is returned once, with matchedName saying which alternate name was found when it was not the main one. Case, accents and punctuation are ignored (catan! finds Catan, flugelschlag finds Flügelschlag). Words shorter than three characters are looked for only at the start of a name (go finds Go).
Order: a name equal to the query first, then names starting with it, then names with a word starting with it, then names containing it; within that, better-known games first (how often the game is looked at and rated, its rank, how many languages name it), and a game’s main name or its name in lang before its other names. The best-known names are read first and the reading stops at a few hundred names, so a query matching thousands of names (the) lists the best known of them.
Misspellings: when fewer than limit games match the query as written, games with a name close to it are added after them, marked approximate: true (cattan finds Catan, wingspn finds Wingspan, brass birmigham finds Brass: Birmingham). Close means one slip (a character added, dropped or replaced, or two neighbours swapped) for a query of 4 to 8 characters, two up to 16, three beyond; the query may be close to a whole name or to consecutive words of one. A query of up to three characters is never corrected, and one of four or five only when nothing matches it as written. A single word of four or five characters that shares no run of three characters with any name (kahn for Khan, uzno for UNO) is compared with the names of about its length (one character shorter or longer at most) that start with the same letter; a slip in the first letter of such a word is not corrected.
Answers are cached for everyone alike until the catalog changes, and a cached answer does not count against the rate limits. For a search box, GET /suggest is lighter.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”What to look for.
Example
catanWhat to look for: games (the default), people (designers and artists), publishers, or all (games, and people and publishers in terms).
Which page to return, from 1, of limit games each: it starts at game (page − 1) × limit + 1, so page=3&limit=24 is the same page as cursor=48&limit=24. Send page or cursor, not both (400 invalid_page). A page past the last is refused with 404 page_out_of_range, whose params.pages says how many there are; page 1 of an empty list is an empty page. A random order keeps the same shuffle for the same seed on every page.
The nextCursor of the previous page.
A language code (BCP 47) such as “fr”, “ja” or “pt-BR”. A game that has a name in that language is returned with it as name, and its main name as originalName; a regional code falls back on its language (“fr-CA” on “fr”), a language with no name of its own takes a regional one (“pt” shows a name the game only has in “pt-BR”), and a game with no name in the language keeps its main name. A game that has a cover of its own in that language (the box of its French edition) is returned with it as image; otherwise image is its main cover. Only names and covers are localised: descriptions and summaries stay in English.
Example
frResponses
Section titled “Responses”Matching games, best match first (see the order above); then the approximate matches, closest first. Approximate matches are added only to the first page, when every match as written fits on it.
object
How many games match as written, across all pages (up to the few hundred names read), plus the approximate matches when there are any.
The page shown, from 1. Null when a cursor started it between two pages.
How many pages of limit games there are: total divided by limit, rounded up. 0 for an empty list.
Pass as cursor to get the next page. Null on the last page.
Games (SearchResult); people or publishers (TermResult) with type=people or type=publishers.
object
Never changes. When two entries turn out to be the same game, one is merged into the other: its id then leads to the game it was merged into.
Used in URLs. The name, then the name and year when the name is taken, then a number after it (catan, catan-1995, catan-1995-2). It may change once, by that rule or by a merge; the slug it had keeps leading to the game.
The game’s main name, or its name in the language asked for with lang when it has one.
The game’s main name when name is the one of the language asked for with lang. Null otherwise.
Fewest and most players.
object
The game’s cover: always a path on this API (starts with /v1/media/): a member’s photo or our own copy of the cover. Null when the game has none we hold yet: the API never sends another site’s address for a file. It is the main cover, the original edition’s, unless lang asks for a language the game has a cover of its own in: then it is that one (on a game, every cover is in covers). Texts from Wikipedia and images from Wikimedia Commons are credited, as their licences ask, at https://thebgdb.org/credits and listed by GET /v1/credits.
A middle-sized version of image, for cards and small screens: a path on this API to our copy 500 pixels wide. The same path as image when the cover is no wider than that, when no narrower copy could be made, and for members’ uploads. Null when the game has no cover we hold.
A small version of image, for lists: a path on this API to our copy 250 pixels wide. There is no resizing for members’ uploads, so for those it is the same path as image. Null when the game has no cover we hold.
What the entry is: game a stand-alone game; expansion when it needs another game to be played (see relations.expansionOf on the game); accessory when it is not played at all (sleeves, an insert, a playmat). Everything is a game until a source states otherwise.
What the cover shows: as a vision model judged it, box_front for a cover a moderator chose, or what the member said for a member’s photo shown as the cover. Null when it has not been looked at or when the game has no cover. box_front the whole front of the box; box_back its back; box_partial the box at an angle, cropped, or an overall shot of it; board_traditional the board of a traditional game that never had a box (chess, go); setup the game laid out ready to play; in_play a game in progress, nobody visible; components the pieces, boards and tokens; cards cards; people people playing, or any person, face or hand in the picture; rulebook a page of the rules; logo a title or logo alone; other anything else. New words may be added; treat an unknown one as other.
Whether the cover is a good one: the whole front of the box (or the board of a traditional game), with no person in it, of quality 3 or more (imageQuality), at least 300 pixels on its short side. False means a better cover is wanted. A moderator’s decision overrules what the cover was found to show. Null when nothing has looked at the cover or when the game has none. A member’s approved photo is shown as the cover unless it was found not good while the source’s cover is good.
How good a picture the cover is, as a vision model judged it: 5 a clean, sharp, straight scan or packshot; 3 an honest photo with small faults (some glare, some angle); 1 and 2 blurred, tiny, dark, glaring, skewed, watermarked or cluttered. Below 3 the cover is not a good one (imageAcceptable false). Null when it has not been judged for quality or when the game has no cover.
Width of the cover in pixels, to lay it out before it loads. Null when not measured.
Height of the cover in pixels. Null when not measured.
The language of the edition the cover shows, as a language code (de for a German box). Null unless a source states it reliably, which is rare: most covers say nothing about it.
Members’ ratings. Null when nobody has rated it.
object
Mean of members’ ratings, from 1 to 10.
How many members rated the game.
The average pulled towards the mean of all ratings in the catalog, as if the game had also received 30 ratings at that mean: (30 × catalog mean + sum of the game’s ratings) ÷ (30 + count). It keeps a game with a handful of high ratings from outranking a widely rated one. Ranks and order=rating use it. Brought up to date every hour.
True when the game was found by correcting the spelling of the query: its name is close to the query but does not contain it. Such games always come after the ones that match as written.
The alternate name the query was found in. Null when it was found in the game’s main name.
object
A designer, artist or publisher found by name. Its page on this API is /designers/{slug}, /artists/{slug} or /publishers/{slug}.
object
Its own name.
The spelling found when it is one merged into this term (“Ouset Media” for Ouset); null when its own name was found.
With type=all, on the first page: the people and publishers found, best first.
A designer, artist or publisher found by name. Its page on this API is /designers/{slug}, /artists/{slug} or /publishers/{slug}.
object
Its own name.
The spelling found when it is one merged into this term (“Ouset Media” for Ouset); null when its own name was found.
Example
{ "query": "colons de catane", "total": 1, "page": 1, "pages": 1, "nextCursor": null, "data": [ { "id": "5c9b0f43-7a39-4f0c-8a4e-2f2d2b1d9a77", "slug": "catan", "name": "Catan", "originalName": null, "kind": "game", "yearPublished": 1995, "players": { "min": 3, "max": 4 }, "image": "/v1/media/covers/4f1c2b9e.jpg", "medium": "/v1/media/covers/4f1c2b9e-w500.jpg", "thumbnail": "/v1/media/covers/4f1c2b9e-w250.jpg", "rating": { "average": 7.42, "count": 318, "weighted": 7.31 }, "complexity": { "average": 2.29, "votes": 121 }, "matchedName": { "name": "Les Colons de Catane", "language": "fr" }, "approximate": false } ]}q is shorter than 2 or longer than 100 characters, lang is not a language code, or page or cursor is not an accepted value.
object
What went wrong, in plain English words. The wording may change: act on code.
A stable name for this refusal, for programs and for showing the message in another language. A code is never renamed; new ones may be added.
The numbers the sentence names, when it names any: for example { "max": 20 } with daily_photo_limit.
object
Example
{ "error": "Game not found", "code": "game_not_found"}page is past the last page (page_out_of_range); params.pages says how many there are.
object
What went wrong, in plain English words. The wording may change: act on code.
A stable name for this refusal, for programs and for showing the message in another language. A code is never renamed; new ones may be added.
The numbers the sentence names, when it names any: for example { "max": 20 } with daily_photo_limit.
object
Example
{ "error": "Game not found", "code": "game_not_found"}Over a request limit. rate_limited: without a token, 60 a minute and 2,000 a UTC day per address (more with a token; see Limits above). weekly_limit: the week’s requests or game details are used up (params.max is the cap). The retry-after header says how many seconds to wait: 60 for a minute’s limit, until midnight UTC for a day’s, until Monday 00:00 UTC for a week’s.
object
What went wrong, in plain English words. The wording may change: act on code.
A stable name for this refusal, for programs and for showing the message in another language. A code is never renamed; new ones may be added.
The numbers the sentence names, when it names any: for example { "max": 20 } with daily_photo_limit.
object
Example
{ "error": "Game not found", "code": "game_not_found"}