Getting who liked a post from the API

(pontus) #1

So, when we get a post like so:

GET /posts/13.json

We can see in the json actions_summary which contains the number of likes the post has. And you can deduce if the user I am logged in as has liked if “acted” or “can_act” is present.

"actions_summary": [
            "id": 2,
            "count": 2,
            "acted": true

But, how do I lookup which users liked the post? We have 2 likes here, one is mine since “acted” is true. But there is one other like. How do I find out which user that is through the API? It is fine if we have to use an admin account to check.

(Rafael dos Santos Silva) #2

As explained at How to reverse engineer the Discourse API

curl ''

(pontus) #3

Your link does not work.

This works for me though:

GET /post_action_users?id=13&post_action_type_id=2

This outputs

  "post_action_users": [
      "id": 1,
      "username": "ausername",
      "name": null,
      "avatar_template": "/letter_avatar_proxy/v2/letter/i/{size}.png",
      "post_url": null,
      "username_lower": "ausername"
      "id": 10,
      "username": "anotherusername",
      "name": null,
      "avatar_template": "/letter_avatar_proxy/v2/letter/{size}.png",
      "post_url": null,
      "username_lower": "anotherusername"

Which is a list of users who liked the post with id 13

(Rafael dos Santos Silva) #4

It was missing the accept header:

curl '' -H 'Accept: application/json'