The discussion revolves around pagination on the /latest.json (Topics) endpoint of the Latest Topics API. fixr initially reported an issue where the more_topics_url field is present even when there are no more results, but Falco was unable to reproduce this and demonstrated a correct scenario where the field is missing on the last page.
fixr then revealed that the issue was caused by modifying the per_page setting in their development environment, which had an unintended side effect. They also discovered that passing ?per_page=X does not affect the number of results returned by the endpoint, which always seems to return 30 rows.
The conversation is ongoing, with swamidass and felixoi showing interest in finding a solution for adjusting the per_page setting.
Similar to this topic, 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 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.