I noticed a glitch where topics that are only in a parent category are not counted as part of the API’s topic_count.
The forum in question where I am a user is running Discourse v2.4.0.beta11, so I can imagine that this may have already been fixed in newer versions, but in case it hasn’t, here’s the report.
The forum has a structure similar to the following, with categories B and C being children of A:
Forum
├── ...
├── Category A (n=0)
│ ├── Category B (n=92)
│ └── Category C (n=6)
└── ...
I have written the value of the topic_count (from /c/xx/show.json) according to the API after each category. But in fact, there’s one topic (only) in category A, although the topic_count says zero. Accordingly, the topics_all_time (from categories.json) for category A says 98, while browsing through the topic_list (from /c/xx.json) also reveals 99.
I can also share details on the forum in question via PM, in case that helps.