How to retrieve all topics of a category

AI-generated summary

The discussion revolves around retrieving all topics of a particular category. Calabrone76 initially attempted to use the search.json endpoint with a category filter, but encountered issues. Arkshine suggested encoding the q parameter, and later, Calabrone76 found a working solution using category:magazzino-partner instead of the category tag.

Arkshine provided a list of core advanced filters and emphasized the importance of encoding parameters. Meanwhile, RGJ suggested using the category topic list JSON, but Calabrone76 noted that this method does not allow for date filtering. RGJ clarified that using after in search gives topics with activity after a certain date, not topics created after a certain date.

Hi everyone,
i need to get all and only topics of a particular category.
So, according to the documentation, it seems the right way is to use the search.json end-point.
The problem is i didn’t understand how to set the category filter.
I did something like this:

GET {{ _.base_url }}/search.json?q=#retail after:2023-12-05 order:latest_topic

but i get a null result

{
	"grouped_search_result": null
}

Where do i mistake? If i cut the categoy tag (#retail) it works, but on all categories.

Thank’s in advance

Hi,

You need to encode the q param.

That is what you want to send: ?q=%23retail%20after%3A2023-12-05%20order%3Alatest_topic

I’ve asked chat-gpt and he gave me a solution that works but it’s not documented anywhere :smiley:

GET {{ _.base_url }}/search.json?q=category:magazzino-partner after:2023-12-05

If i use category tag it works!

You’re right; it’s a valid alternative and advanced filter! You still should encode the param; that was your issue (and might become another, depending on what you use).

Here is a list of core advanced filters:

in:bookmarks
in:created
in:mine
in:likes
in:watching
in:tracking
in:all-pms
in:first
in:personal-direct
in:pinned
in:posted
in:seen
in:tagged
in:unseen
in:untagged
in:wiki
with:images
status:archived
status:closed
status:noreplies
status:open
status:public
status:single_user
max_posts:<number>
max_views:<number>
min_post_count:<number>
min_posts:<number>
min_views:<number>
posts_count:<number>
after:<date>
badge:<name|id>
before:<date>
category:<slug|id>
created:@<username>
filetypes:<ext[,ext,..]>
filetype:<ext[,ext,..]>
group_messages: <name|id>
group: <name|id>
tag:<name>
tags:<name,name>
-tag:<name>
-tags:<name,name>
user:<username|id>
#<[=]category_slug[:subcategory_slug]>
@<username>

No need to use search functionality for this, just use the category topic list json like

https://meta.discourse.org/c/dev/7.json

Yes, but in this way i can’t filter by date. Using search with “after” seems to be the solution for my use case.

Note that using after in search gives you the topics with activity after a certain date, not topics created after a certain date. This is the same as using the latest topic list and stopping when you get past your cutoff date.