# Theme-Component v Plugin: What's the difference

**URL:** https://meta.discourse.org/t/theme-component-v-plugin-whats-the-difference/153951
**Category:** Development
**Created:** [June 5, 2020, 2:56pm UTC](https://meta.discourse.org/t/theme-component-v-plugin-whats-the-difference/153951 "2020-06-05T14:56:51Z")
**Posts on this page:** 1
**Showing post:** 19

<div class="post-metadata">

### Author: ![JQ331](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@JQ331](https://meta.discourse.org/u/JQ331)
#### Post date: [June 6, 2020, 1:25pm UTC](https://meta.discourse.org/t/theme-component-v-plugin-whats-the-difference/153951/19 "2020-06-06T13:25:39Z")

</div>

Outstanding explanation. Thanks very much for this response. It highlights something I had not realized before:

> [@neounix](#):
>
> The API basically exposes a subset, but not all, of the data in the underlying PostgreSQL DB.

From these responses I am gathering that (like you say) interacting with the JSON API can be a good start in many cases, that could avoid the need for coding up a new theme or plugin. But there are some types of data that are not exposed by the API. To access and do stuff with those data types, you would need to use the Discourse data serializer to expose that data; and to do that serialization, you need to use a plugin.

Seems like one good example of data that is not available through the API are the group owners of a group. I say this because (regarding accessing group owners):

> [@How to retrieve group owners? (Rails code question)](https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610/6):
>
> Sure 🙂 The data isn’t exposed by default in the [BasicGroupSerializer](https://github.com/discourse/discourse/blob/master/app/serializers/basic_group_serializer.rb). We only include what we need.

One point of confusion–in the Discourse API, when you get a specific group, one of the returned traits is listed as `"is_group_owner": true`, so not sure what that is supposed to mean…

But seems like to get the group owner I’d need to serialize the group owner trait.

* * *

Are there good examples of using the Discourse serializer? I’ve seen [this](https://meta.discourse.org/t/what-is-this-code-add-to-serializer-in-all-these-plugins/58913), but given its importance a how-to with a few examples would be extremely helpful.

The closest example I’ve got is:

> [@How to retrieve group owners? (Rails code question)](https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610/4):
>
> ```plaintext
> after_initialize do
> add_to_serializer(:basic_group, :owners) do
> GroupUser.where(group_id: object.id, owner: true).pluck("user_id")
> end
> end
> 
> ```

This is helpful, but not quite right (at least it gives me errors saying “invalid plugin”). I’m not sure how to adjust it so that on the group index page I can access the group owners for each group.

---

_[View the full topic](https://meta.discourse.org/t/theme-component-v-plugin-whats-the-difference/153951)._
