@ikko-dev/ghost-api
v0.1.2
Published
Ghost CMS API client — HTTP wrapper, JWT signing, types
Readme
@ikko-dev/ghost-api
Low-level HTTP client for the Ghost CMS APIs (Admin + Content).
Used internally by @ikko-dev/ghost-sdk, @ikko-dev/ghost-core,
and @ikko-dev/ghost-mcp. You can also use it directly if you want a
thin layer that handles JWT signing, error normalization, and URL building.
Install
npm install @ikko-dev/ghost-apiUsage
Admin API (staff access token)
import { GhostHttpClient } from "@ikko-dev/ghost-api";
const client = new GhostHttpClient({
admin: {
url: "https://my-blog.ghost.io",
staffAccessToken: "xxxxxxxxxxxxxxxxxxxxxxxx:abcdef...",
},
});
const { posts } = await client.admin_<{ posts: Post[] }>("GET", "/posts");Content API (content API key)
const client = new GhostHttpClient({
content: {
url: "https://my-blog.ghost.io",
contentApiKey: "abcdef0123456789abcdef0123",
},
});
const { posts } = await client.content_<{ posts: Post[] }>("GET", "/posts");What this package does for you
- JWT signing: turns a
id:secretstaff access token into a short-lived HS256 JWT and attaches it asAuthorization: Ghost <jwt>on every Admin call. - URL building: enforces Ghost's trailing-slash convention.
- Error normalization: non-2xx responses throw
GhostApiErrorwith the fullerrors[]array Ghost returns. - Versioning: sends
Accept-Version: v5.0by default (override viaacceptVersionoption).
