Getting Started

Your first API call

Обновлено Просмотров: 260

This takes about five minutes. You need an API key and at least one published entry.

With curl

Every request authenticates with a single header:

Bash
curl -H "Kookee-API-Key: YOUR_API_KEY" \
  https://api.kookee.dev/v1/blog/posts

You get back a paginated envelope:

JSON
{
  "data": [
    {
      "id": "...",
      "slug": "hello-world",
      "title": "Hello world",
      "locale": "en"
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 10,
  "totalPages": 1
}

With the SDK

Bash
npm install @kookee/sdk
TypeScript
import { Kookee } from '@kookee/sdk';

const kookee = new Kookee({ apiKey: process.env.KOOKEE_API_KEY! });

const response = await kookee.blog.list({ limit: 5 });

response.data.forEach((post) => {
  console.log(post.title, post.slug);
});

The response format

List methods always return the same envelope:

  • data — the array of items

  • total — total matching items across all pages

  • page — the current page, 1-based

  • limit — items per page (default 10, maximum 100)

  • totalPages — how many pages exist

Single-item methods return the item directly, with no envelope:

TypeScript
const post = await kookee.blog.getBySlug('hello-world');
console.log(post.title);
console.log(post.contentHtml);

List items are summaries

This is the detail that surprises people most often. List responses omit the body to keep them small. contentHtml is only returned when you fetch a single entry:

TypeScript
const { data } = await kookee.blog.list();
data[0].contentHtml; // undefined — not included in list items

const post = await kookee.blog.getBySlug(data[0].slug);
post.contentHtml;    // the full HTML body

So an index page uses list(), and a detail page uses getBySlug().

Try another module

The same client reaches every module:

TypeScript
const articles = await kookee.help.list({ limit: 5 });
const releases = await kookee.changelog.list({ limit: 5 });
const pages = await kookee.pages.list();
const config = await kookee.config.list();

If you get an empty list

Almost always one of three things:

  1. The content is still a draft — only published entries are returned

  2. You are filtering by a locale that has no translations, with fallback: false

  3. You are querying a different project than the one you created content in

If you get an error

JSON
{ "code": "API_KEY_INVALID" }

A 401 means the key is invalid or missing. A 404 means the slug or ID does not exist. A 429 means you have hit a rate limit — see Rate limits, plans and error handling.

Была ли эта статья полезной?