Get number of comments and/or likes via API per topic?

What is the most efficient way to get the number of comments a topic has received (and perhaps the number of likes, either to first post post or all posts combined) via the API?

(I haven’t looked but I guess there is a counter cache which stores number of replies etc? Is it possible to fetch that via the API, rather than load the whole topic, etc?)

If you fetch a topic via the api like:

http://localhost:3000/t/welcome-to-discourse/8.json

It will return lots of things, but 2 of the values are:

posts_count:	214
like_count:	2

posts_count is the total number of posts the topic has. like_count is the total number of likes across all posts on the topic.

8 Likes

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