
Type-safe client library for accessing Suske en Wiske (Spike and Suzy) comic data
A fully type-safe tRPC client package that provides auto-generated hooks and utilities for querying Suske en Wiske albums, characters, artists, and collections. Built on top of @trpc/client with full TypeScript support and Zod schema validation.
npm install @sstraatemans/sw_trpcclient
yarn add @sstraatemans/sw_trpcclient
pnpm add @sstraatemans/sw_trpcclient
This package requires the following peer dependencies:
npm install superjson zod
Or with pnpm:
pnpm add superjson zod
Get started in just a few lines of code:
import { createClient } from '@sstraatemans/sw_trpcclient';
// 1. Create the client
const trpc = createClient({
url: 'https://playground-trpcserver.vercel.app/trpc/v1',
});
// 2. Make type-safe queries
const albums = await trpc.albums.all.query({ offset: 0, limit: 10 });
console.log(`Found ${albums.totalCount} albums`);
// 3. Get a specific album by ID
const album = await trpc.albums.getAlbumById.query(1);
console.log(`Album: ${album.title}`);
The simplest way to set up the client:
import { createClient } from '@sstraatemans/sw_trpcclient';
export const trpcClient = createClient({
url: 'https://playground-trpcserver.vercel.app/trpc/v1',
});
Add authentication or custom headers:
import { createClient } from '@sstraatemans/sw_trpcclient';
export const trpcClient = createClient({
url: 'https://playground-trpcserver.vercel.app/trpc/v1',
headers: {
'x-api-key': process.env.API_KEY,
'x-client-version': '1.0.0',
},
});
Or use a function for dynamic headers:
export const trpcClient = createClient({
url: 'https://playground-trpcserver.vercel.app/trpc/v1',
headers: async () => {
const token = await getAuthToken();
return {
authorization: `Bearer ${token}`,
};
},
});
interface CreateClientOptions {
// Server URL (required)
url: string;
// Custom transformer (default: superjson)
transformer?: typeof superjson;
// HTTP headers for requests
headers?:
| Record<string, string>
| (() => Record<string, string> | Promise<Record<string, string>>);
// Maximum URL length for batching (default: 4000)
maxURLLength?: number;
// Maximum batch items (default: 3)
maxItems?: number;
}
Example with all options:
import { createClient } from '@sstraatemans/sw_trpcclient';
import superjson from 'superjson';
export const trpcClient = createClient({
url: 'https://playground-trpcserver.vercel.app/trpc/v1',
transformer: superjson,
headers: {
'x-client-name': 'my-app',
},
maxURLLength: 5000,
maxItems: 5,
});
Don't want to use tRPC? No problem! The Suske en Wiske data is also available through other APIs:
Access the data using GraphQL for flexible queries and precise data fetching.
query {
albums(limit: 10) {
id
title
year
}
}
GraphQL Endpoint: https://graphql.suskeenwiske.dev/v1
Use traditional REST endpoints for simple HTTP requests.
curl https://suskeenwiske.dev/api/v1/albums
REST Base URL: https://suskeenwiske.dev/api/v1
For more information about the GraphQL and REST APIs, visit the online documentation.
⨠Fully Type-Safe - Auto-generated TypeScript types from the tRPC server
š Zod Validation - Runtime type checking with Zod schemas
š¦ Tree-Shakeable - Only import what you need
š HTTP Batching - Automatic request batching for better performance
šÆ IntelliSense - Full autocomplete support in your IDE
š SuperJSON - Native support for Date, Map, Set, BigInt, and more
This project is licensed under the ISC License - see the LICENSE file for details.
The data exposed by this package is not owned by the package author or maintainer. All such data is freely available on the internet from public sources.
The copyright to Suske en Wiske and all related characters, stories, and intellectual property yada yada yada is owned by Standaard Uitgeverij. This package does not claim any ownership or endorsement rights.
Having an issue, question, or want to contribute?
Happy coding! š