How can I filter/paginate the list CategoryTopics route?

We’re building a custom integration to our self-hosted discourse instance within our app and would like to filter the results from https://docs.discourse.org/#tag/Categories/operation/listCategoryTopics to allow us to show the newest and top topics. Currently, it’s paginated to 30 indexes per page.

We either need to:

  1. Filter the results so the 30 indexes returned are the newest, or top topics (ideal)
  2. Increase the pagination limit to do this filtering/sorting on the client (not ideal but would work)

Thank you in advance!

Hi,

I believe what you’re looking for is this:

/c/{slug}/{id}/l/{filter}.json?{query}

Where:

{filter} is either:

latest 
unread 
new 
unseen 
top 
read 
posted 
bookmarks

{query} can be (probably non-exhaustive)

page=<int>
before=<timestamp>
bumped_before=<timestamp>
topic_ids=<id1[,id2, ..]>
order=<likes|op_likes|views|posts|activity|posters|category|created>
ascending=<true|false>
min_posts=<int>
max_posts=<int>
status=<open|closed|archived|listed|unlisted|deleted>
state=<muted|regular|normal|tracking|watching>
search=<term>
subset=<topics|replied>
tags=<tag1[,tag2,..]>
match_all_tags=<true|false>
no_subcategories=<true|false>
no_tags=<true|false>
exclude_tag=<tag>

It doesn’t seem like you can change the per_page with the API.

You can play with order and paginate with page. you can know the next URL to use using more_topic_url, see below in the response example:

image

Worth to be noted: Experimental topics list filter feature

Hope that helps!