From 51f7df2d40ff431b915a1d6a9cf923a394841816 Mon Sep 17 00:00:00 2001 From: ltctceplrm <14954927+ltctceplrm@users.noreply.github.com> Date: Mon, 17 Nov 2025 13:38:39 +0100 Subject: [PATCH 1/2] Added API authorization for Boardgame Geek --- README.md | 4 +++- src/api/apis/BoardGameGeekAPI.ts | 12 +++++++++++- src/settings/Settings.ts | 13 +++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 08131e6..32e4252 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,8 @@ Now you select the result you want and the plugin will cast it's magic and creat - movies (including specials) - series (including OVAs) -- games +- videogames +- boardgames - music releases - wiki articles - books @@ -121,6 +122,7 @@ Now you select the result you want and the plugin will cast it's magic and creat | [Open Library](https://openlibrary.org) | The OpenLibrary API offers metadata for books | books | No | Cover access is rate-limited when not using CoverID or OLID by max 100 requests/IP every 5 minutes. This plugin uses OLID so there shouldn't be a rate limit. | No | | [Moby Games](https://www.mobygames.com) | The Moby Games API offers metadata for games for all platforms | games | Yes, by making an account [here](https://www.mobygames.com/user/register/). NOTE: As of September 2024 the API key is no longer free so consider using Giant Bomb or steam instead | API requests are limited to 360 per hour (one every ten seconds). In addition, requests should be made no more frequently than one per second. | No | | [Giant Bomb](https://www.giantbomb.com) | The Giant Bomb API offers metadata for games for all platforms | games | Yes, by making an account [here](https://www.giantbomb.com/login-signup/) | API requests are limited to 200 requests per resource, per hour. In addition, they implement velocity detection to prevent malicious use. If too many requests are made per second, you may receive temporary blocks to resources. | No | +| [Boardgame Geek](https://boardgamegeek.com) | The Boardgame Geek API offers metadata for boardgames | boardgames | Yes, by making an account [here](https://boardgamegeek.com/join/) and then [requesting an application token](https://boardgamegeek.com/applications) | Exact usage limits are still undetermined | No | | Comic Vine | The Comic Vine API offers metadata for comic books | comicbooks | Yes, by making an account [here](https://comicvine.gamespot.com/login-signup/) and going to the [api section](https://comicvine.gamespot.com/api/) of the site | 200 requests per resource, per hour. There is also a velocity detection to prevent malicious use. If too many requests are made per second, you may receive temporary blocks to resources. | No | #### Notes diff --git a/src/api/apis/BoardGameGeekAPI.ts b/src/api/apis/BoardGameGeekAPI.ts index 7321883..e8c6500 100644 --- a/src/api/apis/BoardGameGeekAPI.ts +++ b/src/api/apis/BoardGameGeekAPI.ts @@ -16,7 +16,7 @@ export class BoardGameGeekAPI extends APIModel { this.plugin = plugin; this.apiName = 'BoardGameGeekAPI'; this.apiDescription = 'A free API for BoardGameGeek things.'; - this.apiUrl = 'https://api.geekdo.com/xmlapi'; + this.apiUrl = 'https://boardgamegeek.com/xmlapi/'; this.types = [MediaType.BoardGame]; } @@ -26,6 +26,9 @@ export class BoardGameGeekAPI extends APIModel { const searchUrl = `${this.apiUrl}/search?search=${encodeURIComponent(title)}`; const fetchData = await requestUrl({ url: searchUrl, + headers: { + Authorization: `Bearer ${this.plugin.settings.BoardgameGeekKey}`, + }, }); if (fetchData.status !== 200) { @@ -64,8 +67,15 @@ export class BoardGameGeekAPI extends APIModel { const searchUrl = `${this.apiUrl}/boardgame/${encodeURIComponent(id)}?stats=1`; const fetchData = await requestUrl({ url: searchUrl, + headers: { + Authorization: `Bearer ${this.plugin.settings.BoardgameGeekKey}`, + }, }); + if (fetchData.status === 401) { + throw Error(`MDB | Authentication for ${this.apiName} failed. Check the API key.`); + } + if (fetchData.status !== 200) { throw Error(`MDB | Received status code ${fetchData.status} from ${this.apiName}.`); } diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index c7e5ac7..000335a 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -16,6 +16,7 @@ export interface MediaDbPluginSettings { MobyGamesKey: string; GiantBombKey: string; ComicVineKey: string; + BoardgameGeekKey: string; sfwFilter: boolean; templates: boolean; customDateFormat: string; @@ -79,6 +80,7 @@ const DEFAULT_SETTINGS: MediaDbPluginSettings = { MobyGamesKey: '', GiantBombKey: '', ComicVineKey: '', + BoardgameGeekKey: '', sfwFilter: true, templates: true, customDateFormat: 'L', @@ -222,6 +224,17 @@ export class MediaDbSettingTab extends PluginSettingTab { void this.plugin.saveSettings(); }); }); + new Setting(containerEl) + .setName('Boardgame Geek Key') + .setDesc('API key for "www.boardgamegeek.com".') + .addText(cb => { + cb.setPlaceholder('API key') + .setValue(this.plugin.settings.BoardgameGeekKey) + .onChange(data => { + this.plugin.settings.BoardgameGeekKey = data; + void this.plugin.saveSettings(); + }); + }); new Setting(containerEl) .setName('SFW filter') From 0de5ba008b290710da5cebe641944d992b254e6d Mon Sep 17 00:00:00 2001 From: ltctceplrm <14954927+ltctceplrm@users.noreply.github.com> Date: Mon, 17 Nov 2025 13:44:40 +0100 Subject: [PATCH 2/2] Added 401 error status --- src/api/apis/BoardGameGeekAPI.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/apis/BoardGameGeekAPI.ts b/src/api/apis/BoardGameGeekAPI.ts index e8c6500..07c2098 100644 --- a/src/api/apis/BoardGameGeekAPI.ts +++ b/src/api/apis/BoardGameGeekAPI.ts @@ -31,6 +31,10 @@ export class BoardGameGeekAPI extends APIModel { }, }); + if (fetchData.status === 401) { + throw Error(`MDB | Authentication for ${this.apiName} failed. Check the API key.`); + } + if (fetchData.status !== 200) { throw Error(`MDB | Received status code ${fetchData.status} from ${this.apiName}.`); }