Which Discourse API can directly get the last comment information of a post?

I would recommend using a data explorer query for that. You can programmatically run queries and get JSON results. Here you go:

-- [params]
-- post_id :post_id

SELECT
  p.id,
  p.topic_id,
  p.post_number,
  p.raw    AS raw_content,   -- Markdown/source
  p.cooked AS html_content,  -- Rendered HTML
  p.user_id,
  p.created_at,
  p.updated_at
FROM posts p
WHERE p.id = :post_id
  AND p.deleted_at IS NULL   -- drop if you want deleted posts too
-- AND p.hidden = false      -- optionally exclude hidden posts
LIMIT 1;

1 Like