Browsing Past Published Articles on Ghost
I recently decided to spend some time editing past articles published on my Numeric Citizen Space website. I first thought that by going to my Ghost admin page, I could quickly browse past published articles by month. I couldn’t be more wrong. In fact, Ghost offers limited post management capabilities, thanks to its limited content browsing capabilities. I cannot go back, say, list articles published early in 2023. I can sort by ascending or descending order, but from there, I have to scroll through a long, dynamically created list of posts. Not very effective for a 600-plus posts website. I had to find a different option to locate a post up for an update. This is where Ghost’s content APIs come into play.
The following API request doesn’t the job (API key voluntarly removed!):
curl -H "Accept-Version: v5.0" "https://numeric-citizen-introspection.ghost.io/ghost/api/content/posts/?key={APIkeygoeshere}&fields=title,url,published_at,updated_at&filter=published_at:>2024-01-01%2Bpublished_at:<2024-02-01" | json_pp
Let me explain what is this API request.
First, I’m going the request using macOS command line, hence the curl
command. Next, the whole query follows in quotes. I query the content / posts API endpoint. Next, I pass my API key, followed by a fields selection (&fields
), next with the filter using the published date between two dates. Finally, I pipe the results in the pretty JSON print macro (is this a macro?) so the output looks like this:
jfm@CraftingMAChine ~ % curl -H "Accept-Version: v5.0" "https://numeric-citizen-introspection.ghost.io/ghost/api/content/posts/?key={API-key-goes-here}&fields=title,id,url,published_at,updated_at&filter=published_at:>2024-01-01%2Bpublished_at:<2024-02-01" | json_pp
{
"meta" : {
"pagination" : {
"limit" : 15,
"next" : null,
"page" : 1,
"pages" : 1,
"prev" : null,
"total" : 9
}
},
"posts" : [
{
"id" : "65b6a09840566000015b0d37",
"published_at" : "2024-01-28T13:50:19.000-05:00",
"title" : "My Weekly Creative Summary for the Week of 2024/03",
"updated_at" : "2024-01-28T13:50:19.000-05:00",
"url" : "https://numericcitizen.me/my-weekly-creative-summary-for-the-week-of-2024-03/"
},
{
"id" : "65b6540640566000015b0cf7",
"published_at" : "2024-01-28T08:23:26.000-05:00",
"title" : "Special Message to Paying Subscribers",
"updated_at" : "2024-01-28T08:23:26.000-05:00",
"url" : "https://numericcitizen.me/special-message-to-paying-subscribers/"
},
{
"id" : "65b16e25bc7fde0001314ccb",
"published_at" : "2024-01-24T15:09:24.000-05:00",
"title" : "The Mac Turns 40",
"updated_at" : "2024-01-24T15:09:24.000-05:00",
"url" : "https://numericcitizen.me/the-mac-turns-40/"
},
{
"id" : "65ad35418532ae000169ddd2",
"published_at" : "2024-01-21T10:22:33.000-05:00",
"title" : "My Weekly Creative Summary for the Week 2024/02",
"updated_at" : "2024-01-21T10:22:33.000-05:00",
"url" : "https://numericcitizen.me/my-weekly-creative-summary-for-the-week-2024-02/"
},
{
"id" : "65ac3aa68532ae000169ddb6",
"published_at" : "2024-01-20T16:28:20.000-05:00",
"title" : "New IT Rules at the Office Prompts Me to Revisit My Mac Usage at Home",
"updated_at" : "2024-01-20T16:28:20.000-05:00",
"url" : "https://numericcitizen.me/new-it-rules-at-the-office-prompts-me-to-revisit-my-mac-usage-at-home/"
},
{
"id" : "65a3ed6e8532ae000169dbe0",
"published_at" : "2024-01-14T09:24:25.000-05:00",
"title" : "My Weekly Creative Summary for the Week of 2024/01",
"updated_at" : "2024-01-14T09:24:25.000-05:00",
"url" : "https://numericcitizen.me/my-weekly-creative-summary-for-the-week-of-2024-01/"
},
{
"id" : "659e86018532ae000169dbbf",
"published_at" : "2024-01-10T06:58:44.000-05:00",
"title" : "Adobe Lightroom 2016-2024 RIP â How To Migrate From Adobe Lightroom to Photomator",
"updated_at" : "2024-01-10T06:58:44.000-05:00",
"url" : "https://numericcitizen.me/adobe-lightroom-2016-2024-rip-how-to-migrate-from-adobe-lightroom-to-photomator/"
},
{
"id" : "659d32eb8532ae000169dba7",
"published_at" : "2024-01-09T06:53:21.000-05:00",
"title" : "Apple Vision Pro â The Missing Apple Keynote Case",
"updated_at" : "2024-01-09T06:53:21.000-05:00",
"url" : "https://numericcitizen.me/apple-vision-pro-the-missing-apple-keynote-case/"
},
{
"id" : "659953468532ae000169db6d",
"published_at" : "2024-01-06T08:27:04.000-05:00",
"title" : "A Tough Year Ahead for Apple",
"updated_at" : "2024-01-06T16:52:59.000-05:00",
"url" : "https://numericcitizen.me/a-though-year-for-apple/"
}
]
}
Next, I copy the post ID of one article and paste it my browser for edition using this special URL:
https://numeric-citizen-introspection.ghost.io/ghost/#/editor/post/652e6eedb8a2650001ad9c5b
This URL brings me directly into the Ghost editor, provided that i was already authenticated with my account. That’s pretty much it. It could be much simpler. For this, I miss WordPress.
You can find the Ghost API document right here.
https://ghost.org/docs/content-api/
This article is also available here.