Quick Start
Get an API Key
Section titled “Get an API Key”You’ll need a Comic Vine API key. Register for free at comicvine.gamespot.com/api.
Create a Client
Section titled “Create a Client”import ComicVine from 'comic-vine-sdk';
const client = new ComicVine({ apiKey: 'your-api-key' });Retrieve a Resource
Section titled “Retrieve a Resource”Every resource has a retrieve() method that fetches a single item by ID:
// Get a specific issueconst issue = await client.issue.retrieve(1);console.log(issue.name);
// Get a specific characterconst character = await client.character.retrieve(1443);console.log(character.name); // "Spider-Man"List Resources
Section titled “List Resources”Every resource has a list() method that returns paginated results:
const characters = await client.character.list({ filter: { name: 'Spider-Man' }, limit: 10,});
console.log(characters.totalCount); // Total matching resultsconsole.log(characters.results); // Array of charactersSelect Specific Fields
Section titled “Select Specific Fields”Reduce response size and get type-safe narrowing with fieldList:
const issue = await client.issue.retrieve(12345, { fieldList: ['id', 'name', 'issueNumber', 'coverDate'],});
console.log(issue.name); // string - availableconsole.log(issue.issueNumber); // number - available// issue.description // TypeScript error - not selectedConfigure with Stores
Section titled “Configure with Stores”Add caching, deduplication, and rate limiting by installing store packages:
import ComicVine from 'comic-vine-sdk';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(), rateLimit: new InMemoryRateLimitStore({ defaultConfig: { limit: 100, windowMs: 60000 }, }), },});Next Steps
Section titled “Next Steps”- Field Selection — Type-safe field narrowing
- Filtering — Filter results by name, date, and more
- Pagination — Manual and automatic pagination
- All Resources — Complete resource reference