Skip to content

Show the right cover

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.

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.

<img
src="https://api.thebgdb.org/v1/media/covers/…-w500.jpg"
srcset="
https://api.thebgdb.org/v1/media/covers/…-w250.jpg 250w,
https://api.thebgdb.org/v1/media/covers/…-w500.jpg 500w,
https://api.thebgdb.org/v1/media/covers/….jpg 1200w
"
sizes="(max-width: 600px) 45vw, 250px"
width="1200"
height="1200"
alt="Wingspan"
/>

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.

  • imageKind says what the picture shows: box_front is the whole front of the box; the 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:

Terminal window
curl "https://api.thebgdb.org/v1/games?cover=ok&order=ranked&limit=24"

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:

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;
}
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)

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:

Terminal window
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.