Ghost CMS
Manage Ghost CMS content via its REST API. Works with self-hosted and Ghost Pro sites.
Configuration
CODEBLOCK0
Get Posts
CODEBLOCK1
Options:
- -
--limit — Number of posts to return (default: 10) - INLINECODE1 — Page number (default: 1)
- INLINECODE2 — Filter by status:
published, draft, scheduled, all (default: published) - INLINECODE7 — Output format:
json or table (default: json)
Create a New Post
CODEBLOCK2
Options:
- -
--title — Post title (required) - INLINECODE11 — Post content in Markdown (required)
- INLINECODE12 — Short excerpt/summary (optional)
- INLINECODE13 — Comma-separated tag names (optional, auto-creates)
- INLINECODE14 — Publish immediately (omit to save as draft)
- INLINECODE15 — Mark as featured (optional)
Manage Tags
CODEBLOCK3
Get Site Stats
CODEBLOCK4
Returns: total posts, total published posts, total draft posts, total members, total paid members, total pageviews (if stats addon is enabled)
Notes
- - Admin API key format:
[id]:[apiKey] — split on the colon, use the second part as the bearer token - Tags are created automatically if they don't exist when creating posts
- Ghost uses a
Content-Type: application/json header for all API calls - All scripts output JSON by default; use
--format table for human-readable output where supported
Ghost CMS
通过其REST API管理Ghost CMS内容。适用于自托管和Ghost Pro站点。
配置
bash
你的Ghost站点URL
export GHOST_URL=https://example.com
管理API密钥(来自Ghost管理后台 > 设置 > 集成)
export GHOST
ADMINAPI_KEY=your-admin-api-key
可选:内容API密钥(用于公开数据)
export GHOST
CONTENTAPI_KEY=your-content-api-key
获取文章
bash
bash skills/ghost-cms/scripts/posts.sh [--limit 10] [--page 1] [--status published]
选项:
- - --limit — 返回文章数量(默认:10)
- --page — 页码(默认:1)
- --status — 按状态筛选:published、draft、scheduled、all(默认:published)
- --format — 输出格式:json 或 table(默认:json)
创建新文章
bash
bash skills/ghost-cms/scripts/new-post.sh \
--title 我的新文章 \
--content ## 你好,世界
这是Markdown格式的文章内容。 \
--tags 新闻,更新 \
--publish
选项:
- - --title — 文章标题(必填)
- --content — Markdown格式的文章内容(必填)
- --excerpt — 简短摘要/概述(可选)
- --tags — 逗号分隔的标签名称(可选,自动创建)
- --publish — 立即发布(省略则保存为草稿)
- --featured — 标记为精选(可选)
管理标签
bash
列出所有标签
bash skills/ghost-cms/scripts/tags.sh --list
创建标签
bash skills/ghost-cms/scripts/tags.sh --create --name 教程 --description 操作指南 --slug tutorials
通过slug获取标签
bash skills/ghost-cms/scripts/tags.sh --slug tutorials
获取站点统计
bash
bash skills/ghost-cms/scripts/stats.sh
返回:总文章数、已发布文章总数、草稿文章总数、总会员数、付费会员总数、总页面浏览量(如果启用了统计插件)
注意事项
- - 管理API密钥格式:[id]:[apiKey] — 以冒号分割,使用第二部分作为Bearer令牌
- 创建文章时,如果标签不存在,会自动创建
- Ghost对所有API调用使用Content-Type: application/json头
- 所有脚本默认输出JSON格式;在支持的情况下使用--format table获取人类可读的输出