API Reference | Content API | Admin API | JavaScript Client Libraries | JavaScript SDK
Demo scripts showing how to use Ghost's Admin and Content APIs to accomplish common tasks. These standalone Node scripts and browser examples are for people building integrations or learning the APIs; this repository is not an API server or an npm library.
Ghost's API is split into Content and Admin, each with its own authentication and tooling. Learn more about the Core API in our docs.
Use the Node version selected by .nvmrc and the pnpm version pinned in package.json.
git clone https://github.com/TryGhost/api-demos.git
cd api-demos
nvm install
nvm use
corepack enable
pnpm installIf you do not use nvm, install the latest patch of the major in .nvmrc with
your preferred Node version manager. The CI workflow
runs both CLI and browser checks on that same Node version.
Each demo has usage instructions at the top of its file. Choose the task and read those instructions before running it:
| Task | Demos |
|---|---|
| Read posts and settings | Read posts, Content settings, Legacy subscribers |
| Create and update posts | Random posts, Add a tag, Find and replace, Write HTML, Email cards |
| Rerender content | All posts, One post, Request images |
| Manage members and files | Bulk member deletion, Upload a file, Upload video |
| Look up a signing key | JWKS lookup |
| Display content in a browser | Read a post, Custom reading time |
Most Node demos take the site URL and an API key as positional arguments; the header specifies whether a Content or Admin key is required. Rerendering, image requests and bulk member deletion default to a dry run. For example, with your own environment variables set:
node force-rerender.js "$GHOST_API_URL" "$GHOST_ADMIN_API_KEY"Those demos require an extra literal true argument to execute. Other write
and upload demos act immediately; inspect their configuration and use a test
site when trying them.
write-posts.js, write-email-card-posts.js, upload-file.js and
upload-video.js accept GHOST_API_URL and GHOST_ADMIN_API_KEY from the
environment, overriding their inline examples. Upload paths are relative to
the script directory. Do not commit real keys into example code.
Open either HTML demo in a browser to use its configured public demo site. The legacy subscribers example explicitly targets an older API; local tests do not establish compatibility with every Ghost server version.
pnpm lint # JavaScript lint and formatting checks
pnpm test # CLI acceptance tests
pnpm test:coverage # CLI tests plus enforced V8 coverage
pnpm playwright install chromium
pnpm test:browser # Browser behaviour testsOn Linux, use pnpm playwright install --with-deps chromium to install browser
system dependencies too. Tests use local fixtures and synthetic credentials.
See Testing the demos for the tested boundaries, coverage
thresholds, browser assertions, CI gate and lint/format commands.
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license.