Skip to content

JavaScript

The public API works with the standard fetch that comes with Node.js 18 and later. This page has a small helper you can paste into a project and the calls you will use most. It runs on a server or in a script, not in a web page on another website (see Calling the API from a browser).

Save this as bazoodle.mjs:

const BASE = "https://bazoodle.com/api/v1";
export async function api(path, params = {}) {
const url = new URL(BASE + path);
for (const [key, value] of Object.entries(params)) {
if (value !== undefined && value !== null) url.searchParams.set(key, String(value));
}
const response = await fetch(url, {
headers: { "User-Agent": "MyGameList/1.0 (contact: you@example.com)" },
});
if (response.status === 429) {
const seconds = Number(response.headers.get("Retry-After")) || 60;
throw new Error(`Slow down: try again in ${seconds} seconds`);
}
if (!response.ok) {
const body = await response.json().catch(() => ({}));
throw new Error(`${response.status} ${body.error?.message || response.statusText}`);
}
return response.json();
}

Change the User-Agent to describe your own tool. The other guides use this api helper.

const { games, next_offset } = await api("/catalog/browse", { sort: "new", limit: 5 });
for (const game of games) {
console.log(`${game.title} (${game.players.min}-${game.players.max} players) https://bazoodle.com/game/${game.id}`);
}
console.log("next page starts at:", next_offset);
const found = await api("/catalog/search", { q: "coin" });
console.log(found.games.map((g) => g.title));
const game = await api("/catalog/games/coins");
console.log(game.title, "-", game.description);
console.log("similar:", game.similar.map((g) => g.title));
try {
await api("/catalog/browse", { sort: "best" });
} catch (error) {
console.log(error.message); // 400 sort must be popular, new or top
}
  • Run a file with node yourfile.mjs: top-level await works in .mjs files.
  • Cache results; see Limits and caching.
  • Escape titles and descriptions before putting them in a web page. They are text written by creators.
  • For worked examples see Build a game browser and Show a game page.