# What's a Post? (Discourse API question)

**URL:** https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497
**Category:** Development
**Created:** [August 23, 2021, 10:52pm UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497 "2021-08-23T22:52:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jcasman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jcasman/32/120874_2.png) [@jcasman](https://meta.discourse.org/u/jcasman)
#### Post date: [August 23, 2021, 10:52pm UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/1 "2021-08-23T22:52:36Z")

</div>

I’m trying to accurately gauge and report activity from a forum that I am running using Discourse. I think I fundamentally don’t understand what a Post is.

On the API, there’s Topics and Posts. For example, if I want to get Posts, I can use filter=5

/user\_actions.json?offset=0&username=USERNAME&filter=5

(Can anyone tell me what is “offset”?)

Here’s the mystery. Posts don’t appear to include Topics. Is this the expected behavior?

What are Posts in the relation to Replies? They do not appear to be a superset.

Are posts in the API the same as we get in the report (Admin → Reports → Posts)?

 ![reports-posts](https://global.discourse-cdn.com/meta/original/3X/c/e/ce850f3464fd036d40722542bc4734b7a2e5f246.png)

Any help appreciated.

---

<div class="post-metadata">

### Author: ![codetricity](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codetricity/32/3773_2.png) [@codetricity](https://meta.discourse.org/u/codetricity)
#### Post date: [August 24, 2021, 12:29am UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/2 "2021-08-24T00:29:11Z")

</div>

As far as I can tell, the filter=5 for posts on `/user_actions.json?offset=0&username=USERNAME&filter=5` does not correspond to the _Posts_ in the report. It looks like the _Posts_ on the report includes both the _posts_ (filter=5) and _topics_ (filter=4).

I’m assuming that _posts_ are supposed to be _replies_ + _topics_. It would be nice if someone more knowledgeable could confirm this.

If this is the case, I can try to use replies (filter 6) and topics (fliter 4). However, I’m a bit concerned about this as the report in the Discourse manager is giving the correct, expected numbers.

Try and search for an example of using the Discourse API to produce reports.

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [August 24, 2021, 1:36am UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/3 "2021-08-24T01:36:57Z")

</div>

> [@jcasman](#):
>
> Posts don’t appear to include Topics. Is this the expected behavior?

Yes, posts are within a topic. So searching for new posts will not search for new topics.

> [@jcasman](#):
>
> What are Posts in the relation to Replies?

When you create a Topic you have also created a Post - the first Post _is_ part of the Topic.  
However, all subsequent Replies are also considered Posts - you are posting your replies. 🙂

As for the `offset` and whether the posts in the API are the same as in Admin → Reports → Posts, I’ll leave that to someone else.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 24, 2021, 6:48am UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/4 "2021-08-24T06:48:30Z")

</div>

Is this any help?

> [@(Superseded) The difference between Topics and Posts](https://meta.discourse.org/t/the-difference-between-topics-and-posts-in-discourse/200943):
>
> information_source This has been superseded by parts of the [Discourse New User Guide](https://meta.discourse.org/t/discourse-new-user-guide/96331) Inspired by [this answer](https://meta.discourse.org/t/data-explorer-plugin/32566/225) by @jomaxro, this is a short explainer on the difference between topics and posts in Discourse. Topics are collections of posts. Let’s use a random topic here on Meta as an example: That topic has a title, “Don’t warn whisperers”, and ID, 199028 , and contains 5 posts at the time of writing this howto. Posts are the individual “content” within a topic. This includes the “OP”, or…

---

<div class="post-metadata">

### Author: ![codetricity](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codetricity/32/3773_2.png) [@codetricity](https://meta.discourse.org/u/codetricity)
#### Post date: [August 24, 2021, 7:06pm UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/5 "2021-08-24T19:06:31Z")

</div>

> [@JimPas](#):
>
> When you create a Topic you have also created a Post - the first Post _is_ part of the Topic.  
> However, all subsequent Replies are also considered Posts - you are posting your replies. 🙂

First, thank you for your help.

Using the `/user_actions.json?offset=0&username=USERNAME&filter=5`, I do not seem to be getting a post counted if it was the first post of a topic.

I may be using the API wrong.

I have a test account with 7 activities.

- 3 topics, each with a post
- 4 replies to existing topics.

When I filter for “posts”, I get a count of 4, not the expected 7.

to get the expected post count of 7, I think I need to add “replies” and “topics”.

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/a/ca1dc5f3539373977e3a0141a0b0626f5111260c.png)

from what I understand, I think the `filter" of `5` should return both the posts that are the first post of a topic as well as the replies, right?

I’d love to get some help trying to understand how to pull the `posts` count for specific users with the API.

```plaintext
 query = {'username': username, 'filter': '5'};

  var response = await getRequest(
      path: '/user_actions.json',
      queryParameters: query);

```

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [August 24, 2021, 10:02pm UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/6 "2021-08-24T22:02:11Z")

</div>

> [@codetricity](#):
>
> I do not seem to be getting a post counted if it was the first post of a topic.

That’s correct. All topics have a _first post_ as part of the topic creation. One couldn’t very well create a topic with only a topic header. That first post isn’t counted as a post (reply) in a post query (filter-5).

When you query for posts, that’s a query for **new** Replies to Existing Topics - **excluding** the OP. That is the expected behavior - to show only the _new_ posts.  
To include Topics (created by that user) as part of the query, then Filter=4 should return the topics that user created (including the OPs as part of the count [3]), and their replies [4]. That would return the 7 you see in the report. 3 Topics created + 4 replies to give a count of 7 (3 OPs + 4 Replies).

Anyone else more knowledgeable please feel free to jump in.

---

<div class="post-metadata">

### Author: ![codetricity](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codetricity/32/3773_2.png) [@codetricity](https://meta.discourse.org/u/codetricity)
#### Post date: [August 24, 2021, 10:04pm UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/7 "2021-08-24T22:04:50Z")

</div>

> [@JimPas](#):
>
> That’s correct. All topics have a _first post_ as part of the topic creation. One couldn’t very well create a topic with only a topic header. That first post isn’t counted as a post (reply) in a post query (filter-5).

@JimPas , thank you for your help. It is very useful. With this knowledge, I’m moving forward with the application dashboard with more confidence. Have a nice day. Very nice of you to help a stranger like me.

---

<div class="post-metadata">

### Author: ![jcasman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jcasman/32/120874_2.png) [@jcasman](https://meta.discourse.org/u/jcasman)
#### Post date: [August 24, 2021, 10:07pm UTC](https://meta.discourse.org/t/whats-a-post-discourse-api-question/201497/8 "2021-08-24T22:07:58Z")

</div>

Same here, @JimPas, very helpful and very much appreciated. Thank you.
