Get last ❤ via API


(Juliano) #1

Hello,

I want to use the Discourse API to get the last like or :heart:, that was given by any user on any topic for a specific Discourse instance. Unfortunately I have not found a good way of achieving this. Trying to crawl the latest topics does not seem to be a good idea.

Another thing I tried was using the Discourse webhooks, but unfortunately liking something does not trigger any event, so it seems the API is the only option.

Can somebody tell me how to achieve this? Is this funcionality already built into the API?

Thanks


(Simon Cossar) #2

There might be a better way to do it, but if you’re able to find what you’re looking for with the Data Explorer Plugin you could either make an API call to the data_explorer_plugin, or write a plugin that creates an API endpoint that returns the results of a similar query.


#3

Did you think some query Simon?

Maybe something like this?

SELECT p.topic_id, g.given_date, g.user_id
FROM posts p, given_daily_likes g
WHERE p.user_id = g.user_id 
AND like_count >= 1
ORDER BY g.given_date DESC
LIMIT 10