Stack Overflow hub

Stack Overflow Comments API

Every comment on one question or answer, oldest first, with its author and score.

GET /v1/stack-overflow/posts/{postId}/comments

1 credit Failed requests are free

About this endpoint

GET /v1/stack-overflow/posts/{postId}/comments returns the comments on a question or an answer, oldest first, up to 1,000. Each comment has id, postId, postType, url, score, edited, createdAt, author, replyTo, isByPostAuthor, license and bodyHtml.

complete is false when the post has more comments than one response holds. A post that does not exist is not_found; a post with no comments is found with an empty list.

This route is thinner than the comments returned inside the question route: bodyMarkdown is null and replyTo is always null because this list does not carry reply targets. isByPostAuthor is present. edited is the marker shown with the comment and can differ from the same comment on another route. When you need the fuller comment shape, use GET /v1/stack-overflow/questions/{questionId}?include=answers,comments or the answers route with include=comments.

Stack Overflow Comments API FAQ

Does it work for an answer as well as a question?

Yes. postId is a question id or an answer id. Read postType to see which it is.

How many credits does a comments lookup cost?

Pricing is documented on the operation in the API registry (shown on this page). Confirm on every response with meta.creditsCharged: that field is the billing source of truth.

Why is bodyMarkdown null?

This list carries the comment HTML but not its Markdown, so bodyMarkdown is null. The comments on the question and answers routes carry the fuller shape.

Why is replyTo always null?

This list does not carry reply targets, so replyTo is always null here. The comments nested in a question or answer do carry it.

What does the complete flag mean?

complete is true when the response holds every comment the post has. It is false when the post has more than 1,000 comments and the list stops at the ceiling.