How can I get the list of Discourse Topic IDs dynamically

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

1 Like

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

Thanks @simon :+1:t2:

1 Like