How to retrieve all topics of a category

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>
2 Likes

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

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

1 Like

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

1 Like

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.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.