Create an API token
const url = 'https://api.thebgdb.org/v1/account/keys';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"My app"}'};
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/account/keys \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "My app" }'Returns the token once. Send it as Authorization: Bearer <token> to get the member request limit. Only for a member whose email address is confirmed; up to 2 tokens per account, which share the member’s limits.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
games:write only for a member given access to the Publisher API. admin only for an admin (the admin API, described apart), 2 such tokens at most, apart from the others.
When the token stops working, in the future. Without it, the token works until deleted.
Example
{ "name": "My app"}Responses
Section titled “Responses”The new token. key is not retrievable later.
object
object
First characters of the token.
What the token may do beyond reading and acting as you: games:write adds and updates your publisher’s games (Publisher API); admin opens the admin API (admins only).
When the token stops working; null for never.
The token. Starts with bgdb_.
Example
{ "data": { "scopes": [ "games:write" ] }}The name is missing or too long, a scope is unknown, expiresAt is not a future date (invalid_token_expiry), or the account already has 2 tokens (too_many_tokens).
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’s email address is not confirmed (email_not_confirmed), games:write was asked by a member without access to the Publisher API (publisher_access_required), or admin by someone who is not an admin (admins_only).
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"}Over a request limit. rate_limited: without a token, 60 a minute and 2,000 a UTC day per address (more with a token; see Limits above). weekly_limit: the week’s requests or game details are used up (params.max is the cap). The retry-after header says how many seconds to wait: 60 for a minute’s limit, until midnight UTC for a day’s, until Monday 00:00 UTC for a week’s.
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"}