$ cli-blog docs

CLI

Use the first-party CLI for trusted publishing, editorial automation, smoke tests, and offline demos.

The @cli-blog/cli package is the supported command-line tool for the public Cli Blog content API. It manages posts, authors, media, categories, tags, locales, sitemap XML, feed XML, revisions, and slug redirects.

What is this?

Use the CLI when you want terminal-first publishing, CI automation, smoke tests, or agent-safe editorial workflows. It uses the first-party Node SDK internally, supports JSON output, and keeps saved local config restricted to the current OS user.

The CLI does not expose dashboard-only settings, billing, audit, admin, or API-key helper routes.

Getting started

Run a demo command if you want to inspect CLI output before using a key:

npx @cli-blog/cli posts list --demo --json

Create sample content with demo output:

npx @cli-blog/cli posts create --demo --title "Hello from demo mode"

Fetch sample feed XML:

npx @cli-blog/cli feed get --demo

Install it globally:

npm install -g @cli-blog/cli

Configure a trusted API key:

cli-blog config set --api-key "$CLI_BLOG_API_KEY"

Environment variables override saved config and are preferred for CI and shared shells:

CLI_BLOG_API_KEY=<private-api-key>

Use public keys for published-content reads. Use private keys only in trusted shells, CI, servers, or agent environments. Avoid passing private keys through --api-key because command arguments may be retained in shell history or exposed through local process inspection.

Reference

Global options:

OptionDescription
--api-key <key>API key override. Prefer CLI_BLOG_API_KEY for private keys.
--demoReturn offline demo content without setup.
--jsonPrint formatted JSON.
--yesSkip confirmation prompts for destructive real API commands.
--versionPrint the installed CLI version.

Commands:

CommandPurpose
config setSave CLI configuration.
versionPrint the installed CLI version.
posts listList posts.
posts getRetrieve one post.
posts relatedRetrieve ranked related posts with a recent-post fallback.
posts createCreate a post.
posts updateUpdate a post.
posts publishConvenience shortcut for setting status to published.
posts scheduleConvenience shortcut for setting status to scheduled with a date.
posts deleteDelete a post.
posts revisions listList post revision snapshots.
posts revisions getRetrieve a post revision snapshot.
posts redirects getResolve historical post slugs.
authors listList author profiles.
authors getRetrieve one author profile.
authors createCreate an author profile.
authors updateUpdate an author profile.
authors deleteDelete an author profile.
media listList media assets.
media getRetrieve one media asset.
media uploadUpload a media asset.
media updateUpdate media metadata.
media deleteDelete a media asset.
categories listList categories.
categories getRetrieve one category.
categories createCreate a category.
categories updateUpdate a category.
categories deleteDelete a category.
tags listList tags.
tags getRetrieve one tag.
tags createCreate a tag.
tags updateUpdate a tag.
tags deleteDelete a tag.
locales listList supported BCP 47 locale tags.
sitemap getFetch sitemap XML.
feed getFetch feed XML.

Post workflow is status-based. posts create defaults to draft when --status is omitted, and posts update can set --status directly. posts publish and posts schedule exist to make the common transitions easier to type and clearer in scripts.

Examples

Fetch related posts for an article page:

cli-blog posts related release-notes \
  --locale en-US \
  --limit 4 \
  --fields summary \
  --include authors,media \
  --json

Shared tags, categories, and authors rank first. If fewer than four posts match those relations, the API fills the response with the newest published posts in the same locale. The returned items use the normal post shape and do not include internal ranking scores.

Create publishing resources:

cli-blog authors create --public-name "Maya Chen" --bio "Field notes from San Francisco" --json
cli-blog categories create --name "San Francisco" --locale en-US --json
cli-blog tags create --name "city-notes" --locale en-US --json

Create and publish a post:

cli-blog posts create \
  --title "A developer's guide to San Francisco" \
  --body-markdown ./post.md \
  --author-ids author_123 \
  --category-ids term_category_123 \
  --tag-ids term_tag_123 \
  --seo-title "A developer's guide to San Francisco" \
  --json

cli-blog posts publish post_123 --expected-version 3

You can use direct status updates instead:

cli-blog posts update post_123 --status published --expected-version 3 --json

Or publish immediately on create:

cli-blog posts create \
  --title "Launch notes" \
  --body "Published immediately." \
  --status published \
  --json

Read delivery content:

cli-blog posts list \
  --status published \
  --fields summary,seo \
  --include authors,media \
  --json

Upload media:

cli-blog media upload ./cover.png --alt-text "Product screenshot" --caption "Launch dashboard" --json

Work with localization, revisions, redirects, and XML helpers:

cli-blog locales list --json
cli-blog categories create --name "Noticias" --locale es-MX --slug noticias
cli-blog posts revisions list post_123 --json
cli-blog posts revisions get post_123 rev_123 --json
cli-blog posts redirects get old-launch-notes --locale en-US --json
cli-blog sitemap get --locale en-US > sitemap.xml
cli-blog feed get --locale en-US > feed.xml

Use demo mode across command families:

cli-blog posts create --demo --title "A developer's guide to San Francisco"
cli-blog authors create --demo --public-name "Maya Chen"
cli-blog media upload --demo --file ./bay-walk.png --alt-text "Morning light over San Francisco Bay"
cli-blog categories create --demo --name "San Francisco"
cli-blog tags create --demo --name "city-notes"
cli-blog feed get --demo

Errors are written to stderr and failed commands exit non-zero. Destructive real API commands ask for confirmation unless --yes is passed.

On this page