DEV Community

Alex Spinov
Alex Spinov

Posted on

Ghost CMS Has a Free API: Build Headless Content Platforms with the Content and Admin APIs

What is Ghost?

Ghost is an open-source CMS for professional publishing. Unlike WordPress, Ghost is built specifically for content — blogs, newsletters, memberships, and paid subscriptions. It exposes two powerful APIs.

The Content API (Public)

Read-only access to published content — no authentication needed beyond an API key:

export GHOST_URL="https://your-ghost.com"
export CONTENT_KEY="your-content-api-key"
Enter fullscreen mode Exit fullscreen mode

Get Posts

curl -s "$GHOST_URL/ghost/api/content/posts/?key=$CONTENT_KEY&limit=5" | jq '.posts[] | {title, slug, published_at}'
Enter fullscreen mode Exit fullscreen mode

Filter and Search

# Posts by tag
curl -s "$GHOST_URL/ghost/api/content/posts/?key=$CONTENT_KEY&filter=tag:javascript"

# Posts by author
curl -s "$GHOST_URL/ghost/api/content/posts/?key=$CONTENT_KEY&filter=author:alice"

# Featured posts
curl -s "$GHOST_URL/ghost/api/content/posts/?key=$CONTENT_KEY&filter=featured:true"

# Include related data
curl -s "$GHOST_URL/ghost/api/content/posts/?key=$CONTENT_KEY&include=tags,authors"
Enter fullscreen mode Exit fullscreen mode

Pages, Tags, Authors

# Get pages
curl -s "$GHOST_URL/ghost/api/content/pages/?key=$CONTENT_KEY"

# Get tags
curl -s "$GHOST_URL/ghost/api/content/tags/?key=$CONTENT_KEY" | jq '.tags[] | {name, slug, count: .count.posts}'

# Get authors
curl -s "$GHOST_URL/ghost/api/content/authors/?key=$CONTENT_KEY" | jq '.authors[] | {name, bio}'
Enter fullscreen mode Exit fullscreen mode

The Admin API (Full CRUD)

const GhostAdminAPI = require("@tryghost/admin-api");

const api = new GhostAdminAPI({
  url: "https://your-ghost.com",
  key: "admin-api-key",
  version: "v5.0",
});

// Create post
const post = await api.posts.add({
  title: "My New Post",
  html: "<p>Hello from the API!</p>",
  status: "published",
  tags: [{ name: "API" }, { name: "Tutorial" }],
});

// Update post
await api.posts.edit({
  id: post.id,
  title: "Updated Title",
  updated_at: post.updated_at,
});

// Upload image
const image = await api.images.upload({ file: "./photo.jpg" });
console.log(image.url);

// Create member
await api.members.add({
  email: "reader@example.com",
  name: "New Reader",
  labels: ["Newsletter"],
});
Enter fullscreen mode Exit fullscreen mode

JavaScript Content SDK

const GhostContentAPI = require("@tryghost/content-api");

const api = new GhostContentAPI({
  url: "https://your-ghost.com",
  key: "content-api-key",
  version: "v5.0",
});

// Get all posts
const posts = await api.posts.browse({
  limit: "all",
  include: "tags,authors",
});

// Get single post by slug
const post = await api.posts.read({ slug: "my-post" });

// Search
const results = await api.posts.browse({
  filter: "tag:javascript+published_at:>2026-01-01",
  order: "published_at DESC",
});
Enter fullscreen mode Exit fullscreen mode

Headless Ghost + Next.js

// app/blog/page.tsx
import GhostContentAPI from "@tryghost/content-api";

const ghost = new GhostContentAPI({
  url: process.env.GHOST_URL,
  key: process.env.GHOST_CONTENT_KEY,
  version: "v5.0",
});

export default async function BlogPage() {
  const posts = await ghost.posts.browse({ limit: 10, include: "tags" });
  return (
    <div>
      {posts.map(post => (
        <article key={post.id}>
          <h2>{post.title}</h2>
          <p>{post.excerpt}</p>
        </article>
      ))}
    </div>
  );
}
Enter fullscreen mode Exit fullscreen mode

Ghost vs WordPress

Feature Ghost WordPress
Focus Content/publishing Everything
Speed Fast (Node.js) Slower (PHP)
API REST (built-in) REST (plugin)
Memberships Built-in Plugin
Newsletter Built-in Plugin
Security Minimal attack surface Frequent vulnerabilities

Need a headless CMS or content platform setup?

📧 spinov001@gmail.com
🔧 My tools on Apify Store

WordPress or Ghost? What CMS do you prefer?

Top comments (0)