Upload a rulebook or another file for a game
const url = 'https://api.thebgdb.org/v1/games/5c9b0f43-7a39-4f0c-8a4e-2f2d2b1d9a77/rulebooks';const form = new FormData();form.append('type', 'rulebook');form.append('language', 'en');form.append('edition', '5th edition, 2015');
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/rulebooks \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form type=rulebook \ --form language=en \ --form 'edition=5th edition, 2015'type says what the file is (a rulebook when left out; see the Rulebook schema for the words). Send one PDF, or up to 20 JPEG, PNG or WebP images of the pages in reading order, as repeated file fields. All files together may weigh 25 MB at most, and each image 5 MB; a PDF of up to 200 MB is sent in parts instead, starting with POST /games/{id}/rulebooks/uploads. The type is checked from each file’s content, not its name. language says which language the rules are written in. The member’s email address must be confirmed. A member can upload 10 rulebooks a day. A rulebook is shown to others once a moderator has approved it; until then only its uploader can list it (GET /account/games/{id}) and download its files.
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
One PDF, or 1 to 20 images.
What the file is. rulebook: the game’s rules (the only type structured rules are drafted from); player_aid: player aids, reference sheets, rules summaries; score_sheet: score sheets and printable trackers; faq: FAQ and errata; campaign: campaign logs, scenario books; print_and_play: print-and-play files; variant: solo, automa and fan variants; other: anything else.
A language code such as “en”, “fr” or “pt-BR”.
Which edition or printing these rules belong to. Optional.
Example
{ "type": "rulebook", "language": "en", "edition": "5th edition, 2015"}Responses
Section titled “Responses”The rulebook was stored and waits for review.
object
object
What the file is. rulebook: the game’s rules (the only type structured rules are drafted from); player_aid: player aids, reference sheets, rules summaries; score_sheet: score sheets and printable trackers; faq: FAQ and errata; campaign: campaign logs, scenario books; print_and_play: print-and-play files; variant: solo, automa and fan variants; other: anything else.
A language code such as “en”, “fr” or “pt-BR”.
Which edition or printing the rules belong to, when the uploader said.
One PDF file, or one image per page.
Number of pages. Null for a PDF whose pages could not be counted.
Bytes, all files together.
The files, in reading order. A PDF has one.
object
Path of the file on this API.
Bytes.
What the file shows: rulebook for a page sent as an image; null for a PDF, which is not an image. 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.
Example
{ "data": { "id": "c2b7e5a4-3f1d-4b7c-8f0a-9e6d5c4b3a21", "type": "rulebook", "language": "en", "edition": "5th edition, 2015", "kind": "pdf", "pages": null, "size": 4812330, "files": [ { "path": "/v1/media/rulebooks/5c9b0f43-7a39-4f0c-8a4e-2f2d2b1d9a77/c2b7e5a4-3f1d-4b7c-8f0a-9e6d5c4b3a21/1.pdf", "contentType": "application/pdf", "size": 4812330, "kind": null } ], "status": "pending" }}No file was sent, a PDF was sent with other files, there are more than 20 images, or the type, language or edition is not valid.
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.
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 files weigh more than 25 MB together, or an image more 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"}A file is not a PDF, JPEG, PNG or WebP.
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 uploaded 10 rulebooks 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"}