How can I get the list of Discourse Topic IDs dynamically

You could get the topic ids by making requests to /latest.json Each request to that route will return 30 topics. After your initial request, use the value of the more_topics_url that is returned to get the next batch of topics, for example /latest?no_definitions=true&page=1. You’ll find the more_topics_url in the topic_list object that is returned with the request.

You’ll find the topic ids in the topics array that is returned from the request.

If your Discourse site has the Data Explorer plugin installed. You could also try writing a Data Explorer query that returns the topic ids you are interested in and then run the Data Explorer request through the API.

5 Likes