Skip to content

Instantly share code, notes, and snippets.

@naz
Created October 29, 2019 14:09
Show Gist options
  • Save naz/b71619cb04d35e0de97a91f8b41f95a0 to your computer and use it in GitHub Desktop.
Save naz/b71619cb04d35e0de97a91f8b41f95a0 to your computer and use it in GitHub Desktop.
Fetch all posts from Ghost API
// USAGE: node admin-read-posts.js http://localhost:2368 ADMIN_API_KEY
if (process.argv.length < 4) {
console.error('Missing an argument');
process.exit(1);
}
const url = process.argv[2];
const key = process.argv[3];
const GhostAdminAPI = require('@tryghost/admin-api');
const api = new GhostAdminAPI({
url,
key,
version: 'v3'
});
(async function main() {
try {
let posts = await api.posts.browse({limit: 'all'});
console.log(posts);
} catch (e) {
console.log(e);
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment