Errors and retries
- Failed requests throw
errors.APIError, withstatusCodeand the response body. - A
401is retried once with a fresh token. - A
429 Too Many Requestsis retried up to three times, honouringRetry-After. - A server error (
500,502,503,504) is retried once.
import { errors } from "@pinta365/blizzard-api";
try {
await client.wow.characterProfile("silvermoon", "nosuchcharacter");
} catch (error) {
if (error instanceof errors.APIError && error.statusCode === 404) {
// Not found
}
}
A 404 doesn't always mean the thing doesn't exist. WoW: Forever characters, for example, only appear from level 10, after a logout: see Characters and guilds.