Skip to main content

Working Example

const api = new GhostAdminAPI({
  url: 'http://localhost:2368',
  key: 'YOUR_ADMIN_API_KEY',
  version: "v6.0",
});

api.posts.add({
    title: 'My first draft API post',
    lexical: '{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Hello, beautiful world! 👋","type":"extended-text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}'
});

Authentication

The client requires the host address of your Ghost API and an Admin API key in order to authenticate.
  • url - API domain, must not end in a trailing slash.
  • key - string copied from the “Integrations” screen in Ghost Admin
  • version - minimum version of the API your code works with
The url and key values can be obtained by creating a new Custom Integration under the Integrations screen in Ghost Admin.