How can I get the list of Discourse Topic IDs dynamically

AI-generated summary

To dynamically get a list of Discourse topic IDs, simon suggests making requests to /latest.json. This route returns 30 topics per request, and the more_topics_url value can be used to fetch the next batch of topics. Topic IDs can be found in the topics array of the returned topic_list object.

Alternatively, if the Data Explorer plugin is installed, a Data Explorer query can be written to return the desired topic IDs, which can then be retrieved through the API.

Continuing the discussion from Embedding Discourse Comments via Javascript:

Which Discourse API should I call to from a PHP function in order to get all the Discourse topic IDs loaded in a searchable dropdown box in CMS?

Thanks

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.

Thanks @simon :+1:t2: