Reference
JavaScript SDK
pnpm add @pagekit/sdk
import { Pagekit } from "@pagekit/sdk";
const blog = new Pagekit({
apiKey: process.env.PAGEKIT_API_KEY!,
// baseUrl: "https://api.pagekit.app/v1" — override when self-hosting
});
Resources
await blog.posts.list({ status: "published", sort: "-published_at" });
await blog.posts.get("post_123");
await blog.posts.getBySlug("building-ai-agents");
await blog.posts.create({ title: "Hello", content: "# Hi" });
await blog.posts.update("post_123", { status: "published" });
await blog.posts.delete("post_123");
await blog.authors.list();
await blog.categories.list();
await blog.categories.getBySlug("engineering");
await blog.tags.list();
await blog.media.list();
Errors
import { PagekitError } from "@pagekit/sdk";
try {
await blog.posts.get("missing");
} catch (error) {
if (error instanceof PagekitError) {
error.status; // 404
error.code; // "not_found"
error.isAuthError; // false
error.isRateLimited; // false
}
}
The client uses the global fetch — Node 18+, Bun, Deno, and browsers all work.
Pass timeout (default 30s) or a custom fetch implementation if needed.