Add a photo to a game
const url = 'https://api.thebgdb.org/v1/games/5c9b0f43-7a39-4f0c-8a4e-2f2d2b1d9a77/images';const form = new FormData();form.append('file', 'file');form.append('kind', 'box_front');form.append('official', 'true');form.append('language', 'example');form.append('editionId', 'example');form.append('nameId', 'example');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.thebgdb.org/v1/games/5c9b0f43-7a39-4f0c-8a4e-2f2d2b1d9a77/images \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form file=@file \ --form kind=box_front \ --form official=true \ --form language=example \ --form editionId=example \ --form nameId=exampleUpload one JPEG, PNG or WebP file of at most 5 MB, say what it shows (kind), and optionally say which language the edition it shows is in. A vision model also looks at the photo; its opinion is kept apart and shown to moderators, who may correct kind. The member’s email address must be confirmed. The type is checked from the file’s content, not its name. A photo of the box front or back (box_front, box_back) is the box alone, straight on, with no border, background or shadow: at least 500 × 500 pixels, and roughly square (longest side at most 1.4 times the shortest). Faces of people are not shown in any photo: hands and the table only. A member can add 20 photos a day. A photo is shown to others once a moderator has approved it; the game’s oldest approved photo is used as its cover. A member verified as representing one of the game’s publishers may send official = true: once approved, that photo is the cover ahead of the others.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The game’s id, as returned in every game object. The game’s slug is accepted too, and so is an address it had before: a slug changed when the game was renamed by the addressing rule, or the id or slug of an entry merged into it because both were the same game. The answer is the game under its current id and slug; compare them with what you sent to update a stored link.
Example
5c9b0f43-7a39-4f0c-8a4e-2f2d2b1d9a77Request Bodyrequired
Section titled “Request Bodyrequired”object
What the photo shows. 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.
The game’s official cover. Only from a verified representative of one of its publishers.
The language of the edition the photo shows, as a code such as “en” or “pt-BR”. Optional; taken from nameId when that is sent alone.
The edition the photo shows, an id from GET /v1/games/{id}/editions. Optional.
Which of the game’s names is on the box, a name’s id from the game’s names. Optional.
Responses
Section titled “Responses”The photo was stored.
object
object
Path of the file on this API.
What the photo shows, as sent.
The language of the edition shown, when it was said.
An edition of the game, as GET /v1/games/{id}/editions lists it.
object
Null for the original edition.
This edition’s own barcode (EAN-13), when a source states it. Null for the original edition: its barcode is the game’s ean.
The titles this edition is sold under, such as “Dominion (Second Edition)”. They are this edition’s, so they are not among the game’s names. Empty when it has none of its own.
Example
{ "data": { "kind": "box_front", "edition": { "titles": [ "Dominion (Second Edition)" ] }, "name": { "id": "3f9c0b1e2d4a5b6c7d8e9f0a1b2c3d4e", "name": "Les Colons de Catane", "language": "fr" } }}No file was sent (photo_missing), kind is missing (photo_kind_missing) or not one of the words listed (invalid_photo_kind), the language is not a language code (invalid_language), or editionId or nameId is not the game’s (edition_not_found, name_not_found).
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"}The request has no valid session token.
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"}The member has not confirmed their email address, or sent official without being a verified representative of one of the game’s publishers.
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"}No game has this id.
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"}The file is larger than 5 MB.
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"}The file is not a JPEG, PNG or WebP image.
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"}A box front or back photo is smaller than 500 × 500 pixels (photo_too_small) or far from square (photo_not_square); params holds its width, height and the min side.
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"}Rate limited, or the member already added 20 photos today.
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"}