Skip to content

Configuration

The ComicVine constructor accepts a configuration object with the following options:

import ComicVine from 'comic-vine-sdk';
const client = new ComicVine({
apiKey: 'your-api-key',
baseUrl: 'https://comicvine.gamespot.com/api',
stores: {
/* ... */
},
client: {
/* ... */
},
});

Your Comic Vine API key. Get one for free at comicvine.gamespot.com/api.

const client = new ComicVine({
apiKey: 'your-api-key',
});

Override the default API base URL. Useful for proxy servers, API gateways, or testing:

// Route through a CORS proxy for browser usage
const client = new ComicVine({
apiKey: 'your-api-key',
baseUrl: 'https://your-proxy-server.com/api/',
});
// Point to a mock server for testing
const client = new ComicVine({
apiKey: 'test-key',
baseUrl: 'http://localhost:3000/api/',
});

Configure cache, deduplication, and rate limit stores. Store implementations are provided by @http-client-toolkit packages:

import {
InMemoryCacheStore,
InMemoryDedupeStore,
InMemoryRateLimitStore,
} from '@http-client-toolkit/store-memory';
const client = new ComicVine({
apiKey: 'your-api-key',
stores: {
cache: new InMemoryCacheStore({ maxItems: 1000 }),
dedupe: new InMemoryDedupeStore({ jobTimeoutMs: 300000 }),
rateLimit: new InMemoryRateLimitStore({
defaultConfig: { limit: 100, windowMs: 60000 },
}),
},
});

All stores are optional. You can use any combination:

// Only caching
const client = new ComicVine({
apiKey: 'your-api-key',
stores: {
cache: new InMemoryCacheStore({ maxItems: 1000 }),
},
client: {
defaultCacheTTL: 300, // 5 minutes
},
});

Configure HTTP client behavior:

const client = new ComicVine({
apiKey: 'your-api-key',
client: {
defaultCacheTTL: 3600, // Default cache TTL in seconds
throwOnRateLimit: true, // Throw errors on rate limit (default: true)
maxWaitTime: 60000, // Max wait time for rate limits in ms
},
});
OptionTypeDefaultDescription
defaultCacheTTLnumberDefault cache TTL in seconds
throwOnRateLimitbooleantrueThrow errors when rate limited
maxWaitTimenumberMaximum time to wait when rate limited (ms)

For persistent stores that survive application restarts:

import {
SQLiteCacheStore,
SQLiteDedupeStore,
SQLiteRateLimitStore,
} from '@http-client-toolkit/store-sqlite';
const client = new ComicVine({
apiKey: 'your-api-key',
stores: {
cache: new SQLiteCacheStore({ database: './comic-vine.db' }),
dedupe: new SQLiteDedupeStore({ database: './comic-vine.db' }),
rateLimit: new SQLiteRateLimitStore({ database: './comic-vine.db' }),
},
});