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

**URL:** https://meta.discourse.org/t/get-number-of-comments-and-or-likes-via-api-per-topic/98350
**Category:** Development
**Tags:** rest-api
**Created:** [9월 29, 2018, 4:52오후 UTC](https://meta.discourse.org/t/get-number-of-comments-and-or-likes-via-api-per-topic/98350 "2018-09-29T16:52:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)
#### Post date: [9월 29, 2018, 4:52오후 UTC](https://meta.discourse.org/t/get-number-of-comments-and-or-likes-via-api-per-topic/98350/1 "2018-09-29T16:52:27Z")

</div>

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?)

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [10월 1, 2018, 8:18오후 UTC](https://meta.discourse.org/t/get-number-of-comments-and-or-likes-via-api-per-topic/98350/2 "2018-10-01T20:18:51Z")

</div>

> [@AstonJ](#):
>
> 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?

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.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [11월 26, 2023, 10:08오전 UTC](https://meta.discourse.org/t/get-number-of-comments-and-or-likes-via-api-per-topic/98350/3 "2023-11-26T10:08:26Z")

</div>

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