In a discussion titled “Get number of likes for a single post?” under the Dev category and tagged with rest-api, mr8 initially sought a way to retrieve the like count for an individual post via the Discourse API, noting that like_count only appeared for entire topics. After some exploration, mr8 discovered the like count is available under the actions_summary field in the API response — for example, {"id":2, "count":5,"acted":true} — though this field is omitted if a post has no likes. smileBeda pointed out this behavior makes the API unreliable and noted the absence of documentation for this feature in official API docs. blake acknowledged the gap and committed to improving the API documentation, explaining it’s partially auto-generated via rspec tests using rswag. smileBeda offered to help with documentation, asking whether it’s manually written or code-generated; blake clarified it’s a hybrid approach, and shared a link to a meta topic explaining how to contribute to the API docs.
Hello,
I’m trying to get the number of likes for a single post via the API, but can’t seem to find it…
I see a like_count for the entire topic, but can’t seem to find the individual like count for each post in either /t/123.json or /posts/222.json.
I noticed that I can get a list of users who liked a post via /post_action_users.json and add them up manually, but what is the recommended way to to get the “like count” for an individual post?
Purtroppo Discourse rimuove quella proprietà se il post non ha “mi piace”
Inoltre, non è nella documentazione dell’API: Discourse API Docs, Discourse API Docs
Pertanto, inaffidabile e il codice viene inquinato da inutili “if property object exist”
Dovrebbe essere migliorato, nel migliore dei casi.
Grazie per il feedback. Sì, guardando la documentazione dell’API non ci sono informazioni sul recupero dei “like”, solo sulla loro creazione. Inizierò migliorando la documentazione dell’API in quel reparto.
Lo adoro assolutamente per questo.
Se posso aiutare con questo (è scritto da un essere umano?!) fammelo sapere
Ma sospetto che tu usi qualcosa come PHPdoc, solo per Ruby o qualunque cosa sia in cui è scritto Discourse?
Non ho esperienza in quella lingua, quindi se è programmatico non posso aiutarti (ancora)