How to find Ghost Content API key

Ghost

December 28, 2024

Photo by NEOM / Unsplash

Ghost is an open-source Content Management System for publishers and bloggers, making writing and publishing online content easy.

Ghost was created in 2013 with a focus on simplicity in writing and sharing content, good performance, improved SEO, and accessibility. It provides features to manage your content and membership and supports various integrations with third parties to enhance your blog's features.

Ghost lets third-party services interact with your blog content through a REST API. From this API, here are examples query you can perform:

  • Retrieve the list of all posts published.
  • Retrieve all the pages created.
  • Retrieves the tags and authors.
  • Access blog settings in read-only mode.

Security on the Ghost content API

To prevent users from accessing these data, you must generate an API key called Content API Key.

This is named like this to make a difference with the Admin API key that allows doing admin actions through the Ghost REST API, which can be damageable for your blog if a malicious person gains access to it.

The Ghost content API key allows you to interact with publicly available data on your blog but in read mode only. This means you cannot send a request to update the content of a blog post or add/remove a tag on a post.

Get the Ghost content API key

The process for retrieving a content API key may vary depending on the Ghost major version. Ghost currently supports four major versions: v2, v3, v4 and v5.

As using the most recent version is encouraged for security and feature improvements, this post shows how to retrieve the content API for Ghost v5.

Log into the administration space of your blog. At the bottom left, click on the settings button.

The Ghost admin dashboard.
The Ghost admin dashboard.

A modal dialog appears displaying settings; on the left menu in the modal, scroll until you see the menu section named "Advanced" and click on the menu item "Integrations"

The Ghost blog modal settings.
The Ghost blog modal settings.

You will see the Integrations settings for your blog, such as the built-in integrations you can configure. At the top right, click on "Add custom integration"

Add a custom Ghost integration.
Add a custom Ghost integration.

A new modal appears with an input to fill the integration name. Give a name and click on the "Add" button.

Fill in the custom integration name.
Fill in the custom integration name.

You will see the integration details, such as the Content API key, the Admin API key, and the API URL. You can optionally add an icon and a description for your integration. Click on the "Save" button.

Save the custom integration details.
Save the custom integration details.

Hover the Content API key field and click the "Copy" button to store it in the clipboard. You can now use this API key to access the content data of your blog.

Use the Ghost content API key

Now that we have the content API key, let's use it to retrieve the list of published posts.

Making a request to the Ghost REST API requires the following information:

  • Ghost version: It is the version of Ghost your blog runs on. We wrote a complete guide on how to find your blog Ghost version.
  • Content API key: We generated and copied it in the clipboard.
  • API URL: It is the domain name of your blog.

The URL shape of the request to the content API is the following:


curl -H "Accept-Version: <GHOST_VERSION>" "https://<API_URL>/ghost/api/content/posts/?key=<CONTENT_API_KEY>&limit=all"

The code below shows how to send a request with cURL to receive all posts published.


curl -H "Accept-Version: v5.0" "https://writing.blogima.com/ghost/api/content/posts/?key=eb20d0b4606c7608bc960178af&limit=all"

Replace the request parameters with your blog's information, run it in the terminal, and see the result.

Use the content API key to retrieve blog data.
Use the content API key to retrieve blog data.

Wrap up

The Ghost content API makes it easy to programmatically access the data published on a blog. This allows developers to

  • Display blog content on other websites.
  • Enrich other applications with your data.
  • Build web extensions for managing blog content, such as Blogima.
  • And many more...

Interacting with the content API requires an API key generated in the blog settings' integration section. The content API key doesn't allow modifying blog content; you must use the Admin API key instead.