Use Ghost's API to retrieve posts

Use Ghost's API to retrieve posts

This blog is running Ghost, a relatively new blogging platform developed with NodeJS. It seemed like a perfect match for this website when I was first starting off because I only needed something lightweight and easy to manage. I also appreciated it being in JavaScript, the main language I use to program these days. If I ever needed to hack it, it would certainly be a lot more fun to work with than a lot of the long-in-the-tooth PHP CMSes out there.

When I was looking into gathering some information on my posts, I found Ghost has a ready-to-go JSON REST API readily available. To use it, you must first enable it in settings:


Then it is as simple as requesting this URL https://YOUR_DOMAIN/ghost/api/v0.1/posts/?client_id=ghost-frontend&client_secret=xxxxxxxxxx. The domain and the client secret will change from installation to installation. The 'client secret' is publically available on all Ghost pages. You can find it by viewing the source of any Ghost generated page or by looking in the database of your Ghost installation.

Below, I've included a quick example using Axios and React using this URL. I've also included the limit option as Ghost by default only returns the first page of results.