Ghost.io API
A strongly-typed, async Rust client for the Ghost CMS API.
v0.2.0 — Content API (stable) + Admin API Posts CRUD (new in v0.2.0)
Overview
ghost-io-api is an ergonomic Rust interface to both the Ghost Content API
and the Ghost Admin API. It is designed to be:
- Async-first — built on
tokioandreqwest - Strongly typed — every request and response is a Rust struct with serde derives
- Secure — Admin API requests carry freshly-minted HS256 JWTs; no long-lived tokens
- Fluent — a builder API for query parameters keeps call sites readable
- Correct — integration-tested against
demo.ghost.io
Installation
[]
= "0.2"
= { = "1", = ["rt-multi-thread", "macros"] }
Content API
Quick Start
use ContentApiKey;
use ;
use Result;
async
Content API keys are 26-character hex strings found under Ghost Admin → Settings → Integrations → Content API.
Endpoint Coverage
| Resource | Browse | Read by ID | Read by Slug |
|---|---|---|---|
| Posts | ✅ | ✅ | ✅ |
| Pages | ✅ | ✅ | ✅ |
| Tags | ✅ | ✅ | ✅ |
| Authors | ✅ | ✅ | ✅ |
| Tiers | ✅ | — | — |
| Settings | ✅ | — | — |
Browsing posts
use BrowsePostsParams;
let response = client.browse_posts.await?;
Fluent query builder
use BrowseParams;
use BrowsePostsParams;
let browse = new
.limit
.page
.filter
.order
.include;
let params = BrowsePostsParams ;
Reading a single resource
// By ID
let post = client.read_post_by_id.await?;
// By slug, with relations embedded
let post = client.read_post_by_slug.await?;
// Pages, tags, authors follow the same pattern
let page = client.read_page_by_slug.await?;
let tag = client.read_tag_by_slug.await?;
let author = client.read_author_by_slug.await?;
Pagination
let pagination = &response.meta.pagination;
println!;
println!;
if pagination.has_next
Site settings
let settings = client.get_settings.await?;
println!;
println!;
Admin API (new in v0.2.0)
The Admin API provides write access to your Ghost installation. Every request carries a freshly-signed HS256 JWT so tokens never sit long enough to expire.
Authentication
Admin API keys take the form {id}:{hex-secret}. Obtain one under
Ghost Admin → Settings → Integrations → Add custom integration.
use AdminApiKey;
let key = new?;
Creating a client
use GhostAdminClient;
let client = new?;
Browsing posts
The Admin API returns posts of all statuses (draft, scheduled, published), unlike the Content API which only returns published posts.
use AdminBrowsePostsParams;
let response = client.browse_posts.await?;
for post in &response.posts
Reading a single post
// By Ghost ID
let post = client.read_post_by_id.await?;
// By slug, with authors and tags embedded
let post = client.read_post_by_slug.await?;
Creating a post
use ;
let post = client.create_post.await?;
println!;
Updating a post
Ghost uses optimistic concurrency: every update must include the
updated_at timestamp from the most recent read. If the value is stale
(someone else edited the post), Ghost returns a 409 ConflictError.
use ;
// Read first to get the current updated_at token
let existing = client.read_post_by_id.await?;
let updated = client.update_post.await?;
println!;
Deleting a post
client.delete_post.await?;
Posts CRUD reference
| Method | Description |
|---|---|
browse_posts(params) |
List posts — all statuses, optional NQL filter |
read_post_by_id(id, include?) |
Read one post by Ghost ID |
read_post_by_slug(slug, include?) |
Read one post by slug |
create_post(post) |
Create a new post |
update_post(id, update) |
Update an existing post |
delete_post(id) |
Permanently delete a post |
Error Handling
use GhostError;
match client.read_post_by_id.await
Examples
list_posts
Pages through all published posts and prints title, slug, and publication date.
# Uses demo.ghost.io by default
# Point at your own site
GHOST_URL=https://your-site.ghost.io \
GHOST_CONTENT_KEY=your-content-api-key \
publish_post (new in v0.2.0)
Demonstrates the full Admin API authoring workflow: create a draft, publish it, then delete it (so the example is safe to run repeatedly).
GHOST_URL=https://your-site.ghost.io \
GHOST_ADMIN_KEY=<id>:<hex-secret> \
cargo
Running Tests
# Unit + doc tests (no network required)
# Integration tests (hits demo.ghost.io)
License
MIT © 2026 Arunkumar Mourougappane