# Latest Topics API pagination

**URL:** https://meta.discourse.org/t/latest-topics-api-pagination/127034
**Category:** Development
**Tags:** rest-api
**Created:** [August 28, 2019, 4:24pm UTC](https://meta.discourse.org/t/latest-topics-api-pagination/127034 "2019-08-28T16:24:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fixr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fixr/32/154603_2.png) [@fixr](https://meta.discourse.org/u/fixr)
#### Post date: [August 28, 2019, 4:24pm UTC](https://meta.discourse.org/t/latest-topics-api-pagination/127034/1 "2019-08-28T16:24:12Z")

</div>

Hello everyone!

Similar to [this topic](https://meta.discourse.org/t/latest-posts-api-pagination/88589), I’m looking for the proper way to do pagination on the `/latest.json` ( **Topics** ) endpoint, specifically knowing what’s the last page.

I’ve figured out that, when there are more results to be fetched, the response contains a `"more_topics_url": "/latest?page=X"` for the next page. However, from my tests, seems like even when there are no more results, we get another page under this field.

Is there a proper way to know when we hit the last page?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 28, 2019, 4:35pm UTC](https://meta.discourse.org/t/latest-topics-api-pagination/127034/2 "2019-08-28T16:35:33Z")

</div>

> [@fixr](#):
>
> However, from my tests, seems like even when there are no more results, we get another page under this field.

I can’t reproduce this.

For example, you can request

`https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1`

that contains 30 topics and a `more_topics_url` with `"/c/site-feedback/blog/l/latest?page=2"`.

Then you request that and get 25 more topics and a missing `more_topics_url` because it’s the end.

---

<div class="post-metadata">

### Author: ![fixr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fixr/32/154603_2.png) [@fixr](https://meta.discourse.org/u/fixr)
#### Post date: [August 29, 2019, 1:36pm UTC](https://meta.discourse.org/t/latest-topics-api-pagination/127034/3 "2019-08-29T13:36:41Z")

</div>

Thanks for such quick response and for checking it out!

You’re right. I was messing on my development environment on the `per_page` settings trying to avoid creating 30+ topics to test this, and came across [this method](https://github.com/discourse/discourse/blob/5276a827dd9d22cf4f09d8e838fe26d510b4281f/lib/topic_query.rb#L535-L535), but changing it there seems to have the side-effect I mentioned, though returning the amount of results I set there.

Seems like passing `?per_page=X` doesn’t have any effect on this endpoint (following your example: [https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1&per\_page=5](https://meta.discourse.org/c/site-feedback/blog/l/latest.json?page=1&per_page=5), still returns 30 rows). Is there a proper way to adjust this setting?

Thanks again in advance!

---

<div class="post-metadata">

### Author: ![swamidass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/swamidass/32/119549_2.png) [@swamidass](https://meta.discourse.org/u/swamidass)
#### Post date: [December 27, 2020, 9:34pm UTC](https://meta.discourse.org/t/latest-topics-api-pagination/127034/4 "2020-12-27T21:34:37Z")

</div>

Any one solve this problem?

---

<div class="post-metadata">

### Author: ![felixoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/felixoi/32/331959_2.png) [@felixoi](https://meta.discourse.org/u/felixoi)
#### Post date: [March 25, 2021, 12:03am UTC](https://meta.discourse.org/t/latest-topics-api-pagination/127034/5 "2021-03-25T00:03:44Z")

</div>

Would also be interested in this per\_page stuff.
