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?
للأسف، يقوم Discourse بإزالة هذه الخاصية إذا لم يكن للمنشور أي إعجابات
أيضًا، ليست في وثائق واجهة برمجة التطبيقات: Discourse API DocsDiscourse API Docs
وبالتالي، فهي غير موثوقة ويتلوث الكود بـ “إذا كانت الخاصية موجودة” غير الضرورية
يجب تحسينها، في أفضل الأحوال.
شكراً على ملاحظاتك. نعم، بالنظر إلى وثائق واجهة برمجة التطبيقات، لا توجد معلومات حول جلب الإعجابات، فقط حول إنشائها. سأبدأ بتحسين وثائق واجهة برمجة التطبيقات في هذا القسم.
بالتأكيد أحبك على ذلك.
إذا كان بإمكاني المساعدة في ذلك (هل هو مكتوب بواسطة إنسان؟!) فأخبرني
لكنني أشك في أنك تستخدم شيئًا مثل PHPdoc، فقط لـ Ruby أو أيًا كان ما كُتب به Discourse؟
ليس لدي خبرة في تلك اللغة، لذا إذا كانت برمجية فلا يمكنني المساعدة فيها (حتى الآن)