IGDBClient accepts an IGDBClientConfig object. Only clientId and
clientSecret are required. HTTP execution is powered by
@api-wrappers/api-core.
The default configuration is intended to be production-safe for normal IGDB usage. Reach for these options when you need stricter timeouts, custom fetch behavior, additional api-core plugins, or different retry/rate-limit behavior.
interface IGDBClientConfig {
clientId: string;
clientSecret: string;
retry?: Partial<RetryConfig>;
rateLimit?: RateLimitPluginOptions;
timeoutMs?: number;
fetch?: typeof globalThis.fetch;
transport?: Transport;
plugins?: ApiPlugin[];
logger?: LoggerInterface;
}The client retries transient failures with api-core's retry loop. Defaults are
maxAttempts: 3 and delayMs: 300. Backoff is exponential, and api-core uses
jitter unless you set jitter: false.
interface RetryConfig {
maxAttempts: number;
delayMs?: number;
jitter?: boolean;
retriableStatusCodes?: number[];
}Example - more aggressive retries:
const client = new IGDBClient({
clientId: "...",
clientSecret: "...",
retry: {
maxAttempts: 5,
delayMs: 500,
},
});Example - disable retries:
retry: { maxAttempts: 1 }The built-in rate limiter uses api-core's rate limit plugin. Defaults are
maxConcurrent: 8, maxRequestsPerInterval: 4, intervalMs: 1000, and
minTimeMs: 250, matching IGDB's documented 4 requests-per-second rate limit
and 8 open-request concurrency limit.
interface RateLimitPluginOptions {
maxConcurrent?: number;
minTimeMs?: number;
maxRequestsPerInterval?: number;
intervalMs?: number;
}Example - more conservative limits:
const client = new IGDBClient({
clientId: "...",
clientSecret: "...",
rateLimit: {
maxConcurrent: 2,
minTimeMs: 500,
},
});Example - higher throughput:
rateLimit: {
maxConcurrent: 8,
maxRequestsPerInterval: 4,
intervalMs: 1000,
}The wrapper forwards these api-core options to the IGDB HTTP client:
timeoutMssets a request timeout.fetchswaps the fetch implementation and is also used for Twitch token requests.transportreplaces the IGDB request transport.pluginsappends additional api-core plugins after the built-in rate limit and auth plugins.loggercontrols api-core diagnostic logging.
Pass fetch when you need to run through a custom HTTP stack, add test doubles, or use a runtime-specific implementation. The same function is used for Twitch token requests and IGDB API requests.
const client = new IGDBClient({
clientId: "...",
clientSecret: "...",
fetch: async (input, init) => {
console.log("IGDB request:", input);
return fetch(input, init);
},
});const client = new IGDBClient({
clientId: "...",
clientSecret: "...",
timeoutMs: 10_000,
});import { IGDBClient } from "@api-wrappers/igdb-wrapper";
const client = new IGDBClient({
clientId: process.env.TWITCH_CLIENT_ID!,
clientSecret: process.env.TWITCH_CLIENT_SECRET!,
retry: {
maxAttempts: 4,
delayMs: 400,
},
rateLimit: {
maxConcurrent: 3,
minTimeMs: 350,
},
timeoutMs: 10_000,
});