# Description of fields returned by Discourse API

**URL:** https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968
**Category:** Development
**Tags:** rest-api
**Created:** [November 2, 2020, 7:28am UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968 "2020-11-02T07:28:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Goutham\_Tholpadi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/goutham_tholpadi/32/198857_2.png) [@Goutham\_Tholpadi](https://meta.discourse.org/u/Goutham_Tholpadi)
#### Post date: [November 2, 2020, 7:28am UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968/1 "2020-11-02T07:28:20Z")

</div>

I am using the [Discourse API](https://docs.discourse.org/) to extract posts from a forum. I need help in understanding the meanings of the fields returned by the API. For example, `post_type` field in each `post` is a number. What are the valid values and what do they mean? Similarly, the `id` under `actions_summary` is a number. There are other fields such as `reads`, `score`, etc. which I am not clear about. Any pointers on where I can get this information. Thanks!

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [November 2, 2020, 6:13pm UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968/2 "2020-11-02T18:13:54Z")

</div>

> [@Goutham\_Tholpadi](#):
>
> Any pointers on where I can get this information.

If you have the [Data Explorer plugin](https://meta.discourse.org/t/data-explorer-plugin/32566) installed on your site, you can get details about the number codes used by hovering over the entries:

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/7/f707a4fe2029d7be32b40292f7a22ba7cbeadd6c.png)

For example, hovering over the `posts` `post_type` field shows the following values:

- regular: 1
- moderator action: 2
- small action: 3
- whisper: 4

Other than the [Data Explorer](https://meta.discourse.org/t/32566?silent=true), the only place I know of to find this information is in the Discourse code. For example, to find the meaning of each `action_type` from the `user_actions` table, enter `UserAction.types` at the Rails console. That returns the following values:

`{:like=>1, :was_liked=>2, :bookmark=>3, :new_topic=>4, :reply=>5, :response=>6, :mention=>7, :quote=>9, :edit=>11, :new_private_message=>12, :got_private_message=>13, :solved=>15, :assigned=>16}`

---

<div class="post-metadata">

### Author: ![Goutham\_Tholpadi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/goutham_tholpadi/32/198857_2.png) [@Goutham\_Tholpadi](https://meta.discourse.org/u/Goutham_Tholpadi)
#### Post date: [November 3, 2020, 7:20am UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968/3 "2020-11-03T07:20:30Z")

</div>

Thanks @simon ! This is an interesting way to get this info. I did some digging based on your suggestions and found [this piece of code](https://github.com/discourse/discourse/blob/master/app/models/user_action.rb) for `user_actions`, but could not find something similar for `post_type` after considerable searching. I was hoping that every field returned by the API would be documented somewhere, at least for important fields that carry significant semantics.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [November 3, 2020, 10:34pm UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968/4 "2020-11-03T22:34:16Z")

</div>

> [@Goutham\_Tholpadi](#):
>
> I did some digging based on your suggestions and found [this piece of code](https://github.com/discourse/discourse/blob/master/app/models/user_action.rb) for `user_actions` , but could not find something similar for `post_type` after considerable searching.

That is understandable. There is similar code though. It’s here: [discourse/app/models/post.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/app/models/post.rb#L145). The structure of the DIscourse database is very consistent. Hopefully this helps to make up for the lack of documentation.

> [@Goutham\_Tholpadi](#):
>
> I was hoping that every field returned by the API would be documented somewhere, at least for important fields that carry significant semantics.

I’m not sure that every field returned by the API will get documented, but documenting the various places where number codes are returned seems important. Example of this are:

- `Post.types`
- `UserAction.types`
- `Notification.types`
- `NotificationLevels.all`
- `UserOption.email_level_types`

If we go ahead with this, I’m not sure what the best place would be for the documentation. Possibly at [https://docs.discourse.org/](https://docs.discourse.org/), but it’s possible there will be technical issues with doing that.

---

<div class="post-metadata">

### Author: ![Goutham\_Tholpadi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/goutham_tholpadi/32/198857_2.png) [@Goutham\_Tholpadi](https://meta.discourse.org/u/Goutham_Tholpadi)
#### Post date: [November 4, 2020, 5:14am UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968/5 "2020-11-04T05:14:16Z")

</div>

Thanks @simon! Yes, listing the English names/one-line descriptions for numeric codes would be very useful. Is there someplace I can place a request for this?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [November 6, 2020, 9:20pm UTC](https://meta.discourse.org/t/description-of-fields-returned-by-discourse-api/168968/6 "2020-11-06T21:20:38Z")

</div>

> [@Goutham\_Tholpadi](#):
>
> Is there someplace I can place a request for this?

I agree that these fields need to be documented. I’ll assign this topic to myself and make sure that it gets done.
