Stack Overflow hub

Stack Overflow Answers API

All answers to one question, each with its score, accepted flag, author, edit times and optional comments.

GET /v1/stack-overflow/questions/{questionId}/answers

1 credit Failed requests are free

About this endpoint

GET /v1/stack-overflow/questions/{questionId}/answers returns a page of answers. Each answer has id, questionId, questionTitle, tags (empty on this list because it does not carry the question's tags), url, score, votes, isAccepted, author, lastEditor, license, commentCount, createdAt, lastActivityAt, lastEditedAt, communityWikiAt, lockedAt and any awarded bounty.

Sort by votes (the default), activity or creation; only creation pages without a ceiling. Add include=comments for each answer's comments. A question with no answers is found with an empty list; a question that does not exist is not_found. limitReached says whether a non-creation list hit the 25-page ceiling (2,500 rows); rows with equal scores can repeat or skip on votes and activity.

Stack Overflow Answers API FAQ

How do I get the comments on each answer?

Add include=comments. Each answer gets a comments array with the comment id, author, score, bodyHtml and the reply details when present.

How many credits does an answers page 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. Each paginated page is a separate billed request.

What is the difference between an empty list and not_found?

An existing question with no answers is lookupStatus found with data.answers empty. A question id that does not exist is lookupStatus not_found and the list is still empty, so read the status before deciding.

Which sort should I use to walk every answer?

Use sort=creation. votes and activity stop at 2,500 rows and set limitReached; rows with equal scores can repeat or skip. creation keeps paging past that.