Configuration
ComicVineOptions
Section titled “ComicVineOptions”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: { /* ... */ },});Required Options
Section titled “Required Options”apiKey
Section titled “apiKey”Your Comic Vine API key. Get one for free at comicvine.gamespot.com/api.
const client = new ComicVine({ apiKey: 'your-api-key',});Optional Options
Section titled “Optional Options”baseUrl
Section titled “baseUrl”Override the default API base URL. Useful for proxy servers, API gateways, or testing:
// Route through a CORS proxy for browser usageconst client = new ComicVine({ apiKey: 'your-api-key', baseUrl: 'https://your-proxy-server.com/api/',});
// Point to a mock server for testingconst client = new ComicVine({ apiKey: 'test-key', baseUrl: 'http://localhost:3000/api/',});stores
Section titled “stores”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 cachingconst client = new ComicVine({ apiKey: 'your-api-key', stores: { cache: new InMemoryCacheStore({ maxItems: 1000 }), }, client: { defaultCacheTTL: 300, // 5 minutes },});client
Section titled “client”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 },});| Option | Type | Default | Description |
|---|---|---|---|
defaultCacheTTL | number | — | Default cache TTL in seconds |
throwOnRateLimit | boolean | true | Throw errors when rate limited |
maxWaitTime | number | — | Maximum time to wait when rate limited (ms) |
SQLite Store Configuration
Section titled “SQLite Store Configuration”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' }), },});See Also
Section titled “See Also”- Caching Guide — Caching and deduplication details
- Rate Limiting Guide — Rate limiting strategies