sdk reference
@chilicms/sdk is a small typed fetch client over the public REST delivery API.
It is generic today: you pass the URL plural (posts, pages, releases) and
optionally provide your own TypeScript shape for the returned entries. Generated
per-model clients are follow-up work.
install
bun add @chilicms/sdkcreate a client
import { createClient } from "@chilicms/sdk"
export const chili = createClient({
baseUrl: process.env.CHILICMS_API_URL ?? "http://localhost:4000",
})The public delivery surface is read-only and only returns published content. In
self-hosted deployments that require a delivery token, pass it at your edge or
fetch wrapper; the v0 SDK accepts a custom fetch implementation for that.
list entries
type PostPreview = { id: string; title: string; slug: string }
const posts = await chili.list<PostPreview>("posts")
const germanPosts = await chili.list<PostPreview>("posts", { locale: "de" })get one entry
const byId = await chili.getById<PostPreview>("posts", "8a0f...")
const bySlug = await chili.getBySlug<PostPreview>("posts", "hello-world")method reference
| method | returns | notes |
|---|---|---|
.list<T>(typeSlug, opts?) | T[] | opts.locale filters to one locale |
.getById<T>(typeSlug, id) | T | null | fetches /api/v1/<typeSlug>/<id> |
.getBySlug<T>(typeSlug, slug, opts?) | T | null | lists, then finds a matching slug; pass locale to disambiguate |
Every method returns the generic type you provide. That keeps app code typed without pretending the generated per-model client has shipped.
Next: self-host ChiliCMS, or read the concepts behind the delivery model.