How to get accurate reply count through API?

AI-generated summary

The reply_count parameter in the Discourse API does not always accurately represent the number of replies in a topic. nedbat noticed discrepancies between the API and user-experienced replies. simon explained that reply_count only accounts for direct replies to a post, not replies to the topic’s original post. For an accurate count, use the posts_count value on a topic and subtract 1 to get the total number of comments.

I pulled the topics from a specific category in my forum. Each topic has a reply_count, but it often seems to have no relationship to the user-experienced replies.

For example, this topic: Error 404 after installing a SSL certificate - Site Operations Help - Open edX discussions has 1 reply. But the JSON (https://discuss.openedx.org/posts/1578.json) says reply_count: 0. Why? How can I get an accurate reply count?

The reply_count parameter on a post gives you the number of direct replies to the post. A reply to a post is created by clicking the “Reply” button that is directly under the post. Replies to the topic’s original post are an exception to this. If a post is created by clicking the Reply button directly under the topic’s first post, it will not increment the OPs reply count.

The reply_count on a topic is the total number of direct replies to posts in that topic. It is not the total number of posts in the topic.

For finding the total number of comments in a topic, look at the topic’s posts_count value. The total number of comments in the topic will be posts_count - 1. You can see that if you go to https://discuss.openedx.org/t/error-404-after-installing-a-ssl-certificate/1578.json.