Skip to content

API Client

import { createKenresoftClient } from '@kenresoft-cms/astro';
export const cms = createKenresoftClient({
url: import.meta.env.PUBLIC_KENRESOFT_CMS_URL,
});
const posts = await cms.entries.list({ contentType: 'blog-post' });
const post = await cms.entries.get({
contentType: 'blog-post',
slug: 'hello-world',
});

Only published entries are returned. A draft resolves like a missing slug: a KenresoftApiError with status 404. Non-2xx responses throw KenresoftApiError.

The client also wraps forms (cms.forms.submit), media (cms.media.url, cms.media.get), global variables (cms.globalVariables.list()), structured settings (cms.settings.general(), .contact(), .social(), .navigation(), .footer(), .seo()), pages and route patterns. Commerce methods exist for stores using the Commerce plugin.

Everything maps onto the public API, so any HTTP client can do the same. The package is a thin fetch wrapper, so it works in any JavaScript runtime.