Do we have any API or way to get latest post details for a particular Topic in discourse?

AI-generated summary

In a discussion titled ‘Do we have any API or way to get latest post details for a particular Topic in discourse?’, Aaditya_Agrawal asks if there’s an API to fetch the latest or all posts for a specific topic. mikechristopher shares the official API documentation, and later provides a direct link to the topic endpoint: http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1t~1%7Bid%7D.json%2Fget. Aaditya_Agrawal confirms the endpoint works but notes it returns all posts — not just the latest — and that fetching the latest post for each topic in a category would require many API calls, degrading user experience. blake suggests using webhooks instead: they can notify your system in real-time when a new post is made to a topic, eliminating the need for repeated polling and improving performance. This approach is more efficient for tracking latest posts across multiple topics within a category.

Hi,
As mentioned, do we have any API or way to get latest post details for a particular Topic in discourse ?
Also is there any way to get All/Latest/Top posts for a particular Topic in discourse ?

Thanks in adv.

1 Like
2 Likes

I have already checked into docs. Please let me know url if I missed it .

1 Like

Thanks. This will get me list of all posts for a particular topic.
My goal : Get a latest post for each topic from a certain category.
Pros: I can get required solution to satisfy my solution.
Cons: Due to multiple API calls for each topic, user experience will get deteriorated by a measurable factor.

Do you have any suggestion or approach to satisfy my above goal ?

You probably want to setup a webhook if your goal is to find out when someone posts to a topic. A webhook can trigger on a new topic creation, new post, or when a new user was created. A webhook will send you a POST request to a specified endpoint that you setup so it will be significantly less api calls.

4 Likes