Skip to main content

Working Example

const api = new GhostContentAPI({
  url: 'https://demo.ghost.io',
  key: '22444f78447824223cefc48062',
  version: "v6.0"
});

// fetch 5 posts, including related tags and authors
api.posts
    .browse({limit: 5, include: 'tags,authors'})
    .then((posts) => {
        posts.forEach((post) => {
            console.log(post.title);
        });
    })
    .catch((err) => {
        console.error(err);
    });

Authentication

The client requires the host address of your Ghost API and a Content API key in order to authenticate. The version string is optional, and indicates the minimum version of Ghost your integration can work with. The Content API URL and key can be obtained by creating a new Custom Integration under the Integrations screen in Ghost Admin.