最新主题 API 分页

大家好!

这个主题 类似,我正在寻找对 /latest.json主题)端点进行分页的正确方法,特别是如何知道最后一页的位置。

我发现,当还有更多结果需要获取时,响应中会包含一个指向下一页的 \"more_topics_url\": \"/latest?page=X\"。然而,根据我的测试,即使没有更多结果,该字段下似乎仍然会返回另一个页面。

是否有正确的方法可以判断何时已到达最后一页?

提前感谢!

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.

2 个赞

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, 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, still returns 30 rows). Is there a proper way to adjust this setting?

Thanks again in advance!

2 个赞

有人解决过这个问题吗?

也对这个 per_page 功能感兴趣。

1 个赞