Ghost Admin API Tutorial: How I Built My First Affiliate Site Dashboard
Last month, I decided I needed a better way to track my affiliate site stats without logging into Ghost every five minutes. So I built a simple dashboard using the Ghost Admin API. If you've ever wondered how to pull data directly from your Ghost blog without clicking around in the admin panel, this tutorial is for you.
I'm not a developer—I drive for Uber and learn to code at night. But the Ghost Admin API? It's genuinely beginner-friendly. Let me show you what I learned.
What the Ghost Admin API Actually Does
The Ghost Admin API lets you access your blog data programmatically. Instead of manually checking stats in the Ghost dashboard, you can fetch posts, pages, members, and analytics through code. For me, this meant building a simple dashboard that shows my top-performing posts without logging in.
Think of it like having a remote control for your Ghost blog. You're not changing the TV itself—you're just accessing its data from outside.
You'll need three things to get started: a Ghost blog (I'm on Ghost(Pro), but this works with self-hosted too), Node.js installed on your computer, and about 30 minutes of patience.
Getting Your API Key and Setting Up Authentication
First, log into your Ghost admin dashboard and go to Settings → Integrations → Add custom integration. Give it a name like "My Dashboard" and grab your Admin API Key. This key is like your password—don't share it or commit it to GitHub.
In your project folder, create a .env file and add it there:
GHOST_API_URL=https://yourblog.com
GHOST_ADMIN_API_KEY=your-key-here
Install the Ghost SDK: npm install @tryghost/admin-api
Now create a basic Node.js file called fetch-posts.js:
const GhostAdminAPI = require('@tryghost/admin-api').default;
require('dotenv').config();
const api = new GhostAdminAPI({
url: process.env.GHOST_API_URL,
key: process.env.GHOST_ADMIN_API_KEY,
version: 'v5.0'
});
This connects you to your Ghost blog. The version number matters—check your Ghost version in admin settings if you're not sure.
Fetching Your Posts and Their Performance Data
Here's where it gets useful. Run this to grab all your posts:
api.posts.browse({limit: 'all', include: 'count.clicks,count.conversions'}).then(posts => {
posts.forEach(post => {
console.log(`${post.title} - Views: ${post.count.clicks}`);
});
}).catch(err => console.error(err));
This pulls every post with engagement metrics. I run this daily to see which posts are actually making money for me. Usually, it's the traffic guides—boring stuff that ranks—not the opinion pieces I thought were clever.
The API also lets you filter by date, status (draft vs published), and tags. So if you want to see how many posts you published last month, that's three lines of code.
Automating Your Data Collection
The real power shows up when you automate this. I wrote a simple script that runs every morning and logs my stats to a spreadsheet using Google Sheets API. Now I see my blog performance while I'm driving—just quick numbers on my phone at stoplights.
Use node-schedule to run your fetch every 24 hours, or hook it up to a serverless function (Netlify Functions, AWS Lambda) if you're fancy. I'm not fancy, so I just set a cron job on my VPS.
The Ghost Admin API documentation is solid, and honestly, the hardest part isn't the code—it's remembering that you need the Admin API (not the Content API) for write access. I made that mistake twice.
Start small. Get your posts. See what data is available. Then build something that actually helps you. That's what I did, and now I'm tracking my progress toward that $100/day goal without wasting time in the admin panel.
If you're serious about building affiliate sites with Ghost, learning the API is worth a weekend. You'll save time every week after that.
Next step: watch how I'm actually using these tools on my build-in-public experiment.
Watch the real numbers at jims.one — I'm not pretending this is easy.