# API can pull only 20 posts

**URL:** https://meta.discourse.org/t/api-can-pull-only-20-posts/163406
**Category:** Development
**Tags:** rest-api
**Created:** [September 8, 2020, 7:07pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406 "2020-09-08T19:07:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![sdiscourse](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sdiscourse](https://meta.discourse.org/u/sdiscourse)
#### Post date: [September 8, 2020, 7:07pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/1 "2020-09-08T19:07:54Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [September 8, 2020, 7:29pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/2 "2020-09-08T19:29:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sdiscourse](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sdiscourse](https://meta.discourse.org/u/sdiscourse)
#### Post date: [September 8, 2020, 7:48pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/3 "2020-09-08T19:48:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [September 9, 2020, 2:52pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/4 "2020-09-09T14:52:57Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [September 9, 2020, 5:06pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/5 "2020-09-09T17:06:59Z")

</div>

See

> [@API: Getting all posts in a topic](https://meta.discourse.org/t/api-getting-all-posts-in-a-topic/41018/8):
>
> The best way to download all the posts to a topic via the api is to mimic what Discourse is doing in the web browser so please checkout [Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576) for details. Basically go the the topic in the browser open up your dev tools and look at the xhr requests as you scroll through the topic. Here are the steps to download all the posts in the topic via the api: Hit /t/-/{id}.json. This will contain a ‘posts\_stream’ hash that contains a ‘posts’ array and a ‘stream’ array. Th…

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

---

<div class="post-metadata">

### Author: ![sdiscourse](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sdiscourse](https://meta.discourse.org/u/sdiscourse)
#### Post date: [September 11, 2020, 5:16pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/6 "2020-09-11T17:16:10Z")

</div>

Thank you Blake!

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

---

<div class="post-metadata">

### Author: ![ClawdiaWolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clawdiawolf/32/262518_2.png) [@ClawdiaWolf](https://meta.discourse.org/u/ClawdiaWolf)
#### Post date: [September 11, 2020, 7:47pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/7 "2020-09-11T19:47:47Z")

</div>

> [@sdiscourse](#):
>
> for the print=true. I read in one of the other post that it has limitation of 1000 posts.

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.

---

<div class="post-metadata">

### Author: ![sdiscourse](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@sdiscourse](https://meta.discourse.org/u/sdiscourse)
#### Post date: [September 15, 2020, 1:17pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/8 "2020-09-15T13:17:28Z")

</div>

Thanks Clawdia for the suggestion.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 15, 2020, 1:17pm UTC](https://meta.discourse.org/t/api-can-pull-only-20-posts/163406/9 "2020-10-15T13:17:32Z")

</div>

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