The discussion revolves around retrieving the last (like) from a Discourse instance via API. juliano seeks a way to get the most recent like on any topic, noting that crawling the latest topics or using webhooks isn’t ideal since likes don’t trigger events. simon suggests using the Data Explorer plugin as a potential workaround, either via its API or by creating a custom plugin. SidV proposes a SQL query to fetch the latest likes, using the given_daily_likes table to retrieve the most recent likes with their timestamps and user IDs.
I want to use the Discourse API to get the last like or , 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?
There might be a better way to do it, but if you’re able to find what you’re looking for with the Discourse Data Explorer 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.
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