API can pull only 20 posts

With Admin privilege’s. When I use /t/{}.json API call I see only 20 posts. is there any setting which can show me all my posts on that particular topic?

1 Like

There’s a field in the JSON object returned with a load more URL where you can get the next set of posts. There’s no way to get all posts from the API at once.

5 Likes

Thanks for your reply.
That’s interesting… I don’t see any such field in my JSON response. Is it been introduced in any particular version of Discourse API.
I’m currently on v 2.5

I might be wrong on that specific thing. Next thing you can do is hit the browser inspector on the Network tab and see what calls are made when you load the next set of posts in the UI. That should give some hints :slight_smile:

See

And also the print=true flag is another option to get more than 20 posts.

3 Likes

Thank you Blake!

for the print=true. I read in one of the other post that it has limitation of 1000 posts.

1 Like

It does, but you can add &page=2 to get posts 1001-2000, &page=3 to get posts 2001-3000, and so on to get all the posts. You’ll need to do some math on the value of posts_count in the JSON to determine how many pages there are.

2 Likes

Thanks Clawdia for the suggestion.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.