We are using the ghostContentAPI to browse our Ghost [pro] hosted posts to include in our static build site with eleventy.
We have no more than a hundred posts but cannot browse them all.
The posts returned from the api.posts.browse method are always limited to 100.
const api = new ghostContentAPI({
url: process.env.GHOST_API_URL,
key: process.env.GHOST_CONTENT_API_KEY,
version: "v6.0",
});
const posts = await api.posts.browse({
include: "tags,authors",
limit: "all",
})
console.log(posts.length)
Is there a way around this limit?
jannis
October 16, 2025, 4:35pm
2
limit=all has been removed in Ghost 6:
If you have under 100 posts you should still get all your posts back from the API (not quite sure from how you described it).
If you have over 100 posts you’ll need to query through them.
1 Like
We do have more than a 100 posts.
How can we query through them with pagination?
The docs don’t really provide much information in this regard.
To fetch more than 100 items, pagination should be used, being mindful to build in small delays so as not to trigger any rate limits or fair usage policies of your hosts.
You’ll need to make multiple requests. The content API takes a page argument. Some examples here: Content API JavaScript Client - Ghost Developer Docs
3 Likes
There is a wacky way around this restriction if you can modify your config file, or set an environment variable. Could only be applicable to self-hosted websites…
// config.production.json
{
// "…"
"optimization": {
"allowLimitAll": true
}
}
# .env
optimization__allowLimitAll=true
Source: Ghost/ghost/core/core/shared/max-limit-cap.js at main · TryGhost/Ghost · GitHub
2 Likes
Thanks. I was able to work it out.
This snippet maybe helpful for others who hit the same issue.
let page = 1
let limit = 15;
let posts = await api.posts
.browse({
include: "tags,authors",
page,
limit,
})
.catch((err) => {
console.error(err);
});
page = posts.meta.pagination.next;
let pages = posts.meta.pagination.pages;
while (page < pages) {
const morePosts = await api.posts
.browse({
include: "tags,authors",
page,
limit,
})
.catch((err) => {
console.error(err);
});
//console.log(morePosts.meta)
posts = posts.concat(morePosts)
page = morePosts.meta.pagination.next;
}
2 Likes