SDK
TypeScript SDK
A type-safe TypeScript client for the Wrytze Blog API with automatic error handling and zero runtime dependencies.
The @wrytze/sdk package provides a lightweight, fully typed TypeScript client for the Wrytze Blog API. It wraps the REST API with a clean, intuitive interface so you can fetch blogs, categories, and tags with minimal boilerplate.
The companion @wrytze/react package provides 20 pre-built React components, 4 hooks, and 2 page-level components for rendering complete blog pages with a single import. See the React Components guide.
Key features
- Full TypeScript types -- every request and response is strongly typed, with exported interfaces for all API objects.
- Automatic error handling -- API errors are parsed into structured
WrytzeErrorobjects with HTTP status codes. - Rate limit handling --
RateLimitErrorexposes aretryAfterproperty so you can back off automatically when you hit the 100 req/min limit. - Zero runtime dependencies -- built on the native
fetchAPI. Works in Node.js 18+, Bun, Deno, Cloudflare Workers, and any environment with a globalfetch. - React components --
@wrytze/reactprovides page-level components, composable building blocks, hooks, and metadata utilities for React and Next.js applications.
Quick example
import { WrytzeClient } from "@wrytze/sdk";
const wrytze = new WrytzeClient({
apiKey: process.env.WRYTZE_API_KEY!,
});
// Fetch the 10 most recent blogs
const { data: blogs, pagination } = await wrytze.blogs.list({ limit: 10 });
for (const blog of blogs) {
console.log(`${blog.title} (${blog.readingTimeMinutes} min read)`);
}
console.log(`Page ${pagination.page} of ${pagination.pages}`);Resources
The client exposes three resource namespaces:
| Resource | Methods | Description |
|---|---|---|
wrytze.blogs | list, get, getBySlug | Published blog posts with full HTML content |
wrytze.categories | list | Hierarchical content categories per website |
wrytze.tags | list | Flat content tags per website |