How to Get All Posts in JSON Format with Ghost Public API

In this small and easy tutorial we are going to get all posts from a Ghost blog using Ghost Public API. We need to cover a few steps:

Enable Ghost Public API

Enable Ghost Public API from your Ghost Admin Dashboard (Dashboard -> Settings -> Labs)

Get client_id and client_secret

Get client_id and client_secret. Go to your website and View page source. You should see something like this:

<script type="text/javascript">
ghost.init({
	clientId: "ghost-frontend",
	clientSecret: "xxxxxxxxxxxx"
});
</script>

Request URL

Go to:

https://example.com/ghost/api/v0.1/posts/?include=tags&formats=plaintext&client_id=ghost-frontend&client_secret=xxxxxxxxxxxx

Replace clientId and clientSecret with data that you found in the source. Also replace example.com with your domain. The request must come from a URL that the Ghost blog recognises or the request will not be authorised.

Example:
https://www.hauntedthemes.com/ghost/api/v0.1/posts/?include=tags&formats=plaintext&client_id=ghost-frontend&client_secret=d9de495ef4fc

More information about Ghost Public API you can find on Public API Beta or Ghost Docs.

I want more

Are you interested in a specific Ghost issue, feature or tutorial and we didn't cover it up in our blog? Drop us a message and we might write about it.