# Which users liked topic

**URL:** https://meta.discourse.org/t/which-users-liked-topic/46985
**Category:** Support
**Created:** [July 8, 2016, 5:56am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985 "2016-07-08T05:56:37Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![adam\_beers](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adam\_beers](https://meta.discourse.org/u/adam_beers)
#### Post date: [July 8, 2016, 5:56am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/1 "2016-07-08T05:56:37Z")

</div>

How do I tell which users liked a topic? In particular, if I grab a topic with /t/120.json (to get topic id 120), how can I tell if the currently logged in user has liked this topic? In the returned json, it just lists the number of likes in the actions\_summary section. In this json below, it shows one user liked this topic. How can I tell who? How could I tell if it was the currently logged in user?

```
{
    "post_stream" : {
        "posts" : [{
                "id" : 163,
                "username" : "fudoj8",
                "avatar_template" : "/letter_avatar/fudoj8/{size}/2.png",
                "uploaded_avatar_id" : null,
                "created_at" : "2015-09-02T02:15:17.213-04:00",
                "cooked" : "<p>alsdkfaoifaafvcxzslfdoiwefjafsdlaskdfpoaijs</p>",
                "post_number" : 1,
                "post_type" : 1,
                "updated_at" : "2015-09-02T02:15:17.213-04:00",
                "reply_count" : 0,
                "reply_to_post_number" : null,
                "quote_count" : 0,
                "avg_time" : null,
                "incoming_link_count" : 0,
                "reads" : 2,
                "score" : 0.2,
                "yours" : false,
                "topic_id" : 120,
                "topic_slug" : "will-my-question-show-up-immediately",
                "topic_auto_close_at" : null,
                "primary_group_name" : null,
                "version" : 1,
                "can_edit" : false,
                "can_delete" : false,
                "can_recover" : false,
                "read" : true,
                "user_title" : null,
                "actions_summary" : [{
                        "id" : 2,
                        "count" : 1,
                        "hidden" : false,
                        "can_act" : false,
                        "acted" : true,
                        "can_undo" : true
                    }, {
                        "id" : 3,
                        "count" : 0,
                        "hidden" : false,
                        "can_act" : true,
                        "can_defer_flags" : false
                    }, {
                        "id" : 4,
                        "count" : 0,
                        "hidden" : false,
                        "can_act" : true,
                        "can_defer_flags" : false
                    }, {
                        "id" : 5,
                        "count" : 0,
                        "hidden" : true,
                        "can_act" : true,
                        "can_defer_flags" : false
                    }, {
                        "id" : 6,
                        "count" : 0,
                        "hidden" : false,
                        "can_act" : true,
                        "can_defer_flags" : false
                    }, {
                        "id" : 7,
                        "count" : 0,
                        "hidden" : false,
                        "can_act" : true,
                        "can_defer_flags" : false
                    }, {
                        "id" : 8,
                        "count" : 0,
                        "hidden" : false,
                        "can_act" : true,
                        "can_defer_flags" : false
                    }
                ],
                "moderator" : false,
                "admin" : false,
                "staff" : false,
                "user_id" : 28,
                "hidden" : false,
                "hidden_reason_id" : null,
                "trust_level" : 0,
                "deleted_at" : null,
                "user_deleted" : false,
                "edit_reason" : null,
                "can_view_edit_history" : true,
                "wiki" : false
            }
        ],
        "stream" : [163]
    },
    "draft" : null,
    "draft_key" : "topic_120",
    "draft_sequence" : 0,
    "starred" : false,
    "posted" : false,
    "unpinned" : null,
    "pinned_globally" : false,
    "pinned" : false,
    "pinned_at" : null,
    "details" : {
        "auto_close_at" : null,
        "auto_close_hours" : null,
        "auto_close_based_on_last_post" : false,
        "created_by" : {
            "id" : 28,
            "username" : "fudoj8",
            "uploaded_avatar_id" : null,
            "avatar_template" : "/letter_avatar/fudoj8/{size}/2.png"
        },
        "last_poster" : {
            "id" : 28,
            "username" : "fudoj8",
            "uploaded_avatar_id" : null,
            "avatar_template" : "/letter_avatar/fudoj8/{size}/2.png"
        },
        "participants" : [{
                "id" : 28,
                "username" : "fudoj8",
                "uploaded_avatar_id" : null,
                "avatar_template" : "/letter_avatar/fudoj8/{size}/2.png",
                "post_count" : 1
            }
        ],
        "suggested_topics" : [{
                "id" : 275,
                "title" : "Does it work now for new user",
                "fancy_title" : "Does it work now for new user",
                "slug" : "does-it-work-now-for-new-user",
                "posts_count" : 1,
                "reply_count" : 0,
                "highest_post_number" : 1,
                "image_url" : null,
                "created_at" : "2016-05-04T14:13:01.167-04:00",
                "last_posted_at" : "2016-05-04T14:13:01.401-04:00",
                "bumped" : true,
                "bumped_at" : "2016-05-04T14:13:01.401-04:00",
                "unseen" : false,
                "pinned" : false,
                "unpinned" : null,
                "visible" : true,
                "closed" : false,
                "archived" : false,
                "archetype" : "regular",
                "like_count" : 0,
                "views" : 12,
                "category_id" : 1
            }, {
                "id" : 141,
                "title" : "Should I watch football on Sunday",
                "fancy_title" : "Should I watch football on Sunday",
                "slug" : "should-i-watch-football-on-sunday",
                "posts_count" : 1,
                "reply_count" : 0,
                "highest_post_number" : 1,
                "image_url" : null,
                "created_at" : "2015-09-04T22:50:44.464-04:00",
                "last_posted_at" : "2015-09-04T22:50:45.497-04:00",
                "bumped" : true,
                "bumped_at" : "2015-09-04T22:50:45.497-04:00",
                "unseen" : false,
                "pinned" : false,
                "unpinned" : null,
                "visible" : true,
                "closed" : false,
                "archived" : false,
                "archetype" : "regular",
                "like_count" : 0,
                "views" : 28,
                "category_id" : 1
            }, {
                "id" : 280,
                "title" : "Testing creation now after a delay?",
                "fancy_title" : "Testing creation now after a delay?",
                "slug" : "testing-creation-now-after-a-delay",
                "posts_count" : 5,
                "reply_count" : 0,
                "highest_post_number" : 5,
                "image_url" : null,
                "created_at" : "2016-05-04T14:21:08.483-04:00",
                "last_posted_at" : "2016-05-05T02:48:48.740-04:00",
                "bumped" : true,
                "bumped_at" : "2016-05-05T02:48:48.740-04:00",
                "unseen" : false,
                "last_read_post_number" : 5,
                "unread" : 0,
                "new_posts" : 0,
                "pinned" : false,
                "unpinned" : null,
                "visible" : true,
                "closed" : false,
                "archived" : false,
                "notification_level" : 2,
                "archetype" : "regular",
                "like_count" : 0,
                "views" : 14,
                "category_id" : 1
            }
        ],
        "notification_level" : 1,
        "notifications_reason_id" : null,
        "can_invite_to" : true,
        "can_create_post" : true,
        "can_reply_as_new_topic" : true,
        "can_flag_topic" : true
    },
    "highest_post_number" : 1,
    "last_read_post_number" : 1,
    "deleted_by" : null,
    "actions_summary" : [{
            "id" : 4,
            "count" : 0,
            "hidden" : false,
            "can_act" : true
        }, {
            "id" : 7,
            "count" : 0,
            "hidden" : false,
            "can_act" : true
        }, {
            "id" : 8,
            "count" : 0,
            "hidden" : false,
            "can_act" : true
        }
    ],
    "id" : 120,
    "title" : "Will my question show up immediately?",
    "fancy_title" : "Will my question show up immediately?",
    "posts_count" : 1,
    "created_at" : "2015-09-02T02:15:16.987-04:00",
    "views" : 32,
    "reply_count" : 0,
    "participant_count" : 1,
    "like_count" : 1,
    "last_posted_at" : "2015-09-02T02:15:17.213-04:00",
    "visible" : true,
    "closed" : false,
    "archived" : false,
    "has_summary" : false,
    "archetype" : "regular",
    "slug" : "will-my-question-show-up-immediately",
    "category_id" : 1,
    "word_count" : 1,
    "deleted_at" : null
}

```

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 8, 2016, 9:06am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/2 "2016-07-08T09:06:02Z")

</div>

> [@adam\_beers](#):
>
> how can I tell if the currently logged in user has liked this topic?

It’s listed right in the JSON you quoted, although it’s hidden quite well: :slight_smile:

```json
"id" : 2,
"count" : 1,
"hidden" : false,
"can_act" : false,
"acted" : true,
"can_undo" : true

```

Just look for the `acted` flag on the action with id `2`.

---

<div class="post-metadata">

### Author: ![adam\_beers](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adam\_beers](https://meta.discourse.org/u/adam_beers)
#### Post date: [July 9, 2016, 6:03am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/3 "2016-07-09T06:03:42Z")

</div>

I don’t think that works.

I’m talking about the post with id 120. Which would be the main topic thread. In this example it has the title: “Will my question show up immediately?” It has one post, 163, made by fudoj8. If I am logged in as jon129, how can I tell if I liked the main topic? Or if I liked any reply posts to the topic also? When getting the topic, it is done with www.websitename/t/120.json. The request has no idea who is logged in or making the request.

There is the ability to like a topic and the reply posts. I wanted to know, or get a list, of who liked a topic and reply posts. The discourse page shows a “You liked this” next to a topic or reply post when a user is logged in, but I can’t figure out how they did it.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [July 9, 2016, 6:43am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/4 "2016-07-09T06:43:17Z")

</div>

Ah, good old topic\_users

```
topic_users
user_id integer fkey users 
topic_id integer fkey topics 
posted boolean default false 
last_read_post_number integer null 
highest_seen_post_number integer null 
last_visited_at timestamp null 
first_visited_at timestamp null 
notification_level integer default 1 
notifications_changed_at timestamp null 
notifications_reason_id integer null 
total_msecs_viewed integer default 0 
cleared_pinned_at timestamp null 
id serial primary key 
last_emailed_post_number integer null 
liked boolean null, default false, denormal post_actions 
bookmarked boolean null, default false, denormal post_actions

```

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 9, 2016, 6:55am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/5 "2016-07-09T06:55:12Z")

</div>

> [@adam\_beers](#):
>
> The request has no idea who is logged in or making the request.

Wait who is making the request? In your original post, you were talking about the “currently logged in user”. If the request is made with proper credentials (a cookie, for example), it _will_ contain the `acted`-Flag, just as in the JSON you quoted in the original post.

---

<div class="post-metadata">

### Author: ![adam\_beers](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adam\_beers](https://meta.discourse.org/u/adam_beers)
#### Post date: [July 9, 2016, 3:34pm UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/6 "2016-07-09T15:34:56Z")

</div>

How do I get that information? The API doesn’t list any topic\_users.json endpoint?

---

<div class="post-metadata">

### Author: ![adam\_beers](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adam\_beers](https://meta.discourse.org/u/adam_beers)
#### Post date: [July 9, 2016, 4:03pm UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/7 "2016-07-09T16:03:22Z")

</div>

I was not requesting the topic with an api\_key and api\_username combination. I tried and it didn’t work before, but I tried again and now it is working. Thanks!!

---

<div class="post-metadata">

### Author: ![adam\_beers](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adam\_beers](https://meta.discourse.org/u/adam_beers)
#### Post date: [July 10, 2016, 4:34am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/8 "2016-07-10T04:34:04Z")

</div>

Question: when getting the latest.json, is there a way with that data to see if the current user has liked that topic? I don’t see any actions\_summary for the latest.json query.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 10, 2016, 7:41am UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/9 "2016-07-10T07:41:00Z")

</div>

I’m pretty sure you need separate requests to get this information.

---

<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: [June 8, 2024, 12:45pm UTC](https://meta.discourse.org/t/which-users-liked-topic/46985/10 "2024-06-08T12:45:31Z")

</div>

This topic was automatically closed after 2892 days. New replies are no longer allowed.
