Stack Overflow hub

Stack Overflow Question API

One question with its votes, views, accepted answer id and timestamps, plus answers or comments when you ask.

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

1 credit Failed requests are free

About this endpoint

GET /v1/stack-overflow/questions/{questionId} returns one question. On found, data.question has id, url, title, tags, score, votes, viewCount, answerCount, commentCount, favoriteCount, isAnswered, acceptedAnswerId, author, lastEditor, license, closed, bounty, notice, protectedAt, lockedAt, createdAt, lastActivityAt and lastEditedAt.

Add include=answers for the answer list, include=comments for the question's comments, or both. Each answer carries isAccepted, score, votes, author, commentCount and its own comments when included. answersComplete is false when the answer list is shorter than answerCount says. A missing or deleted question is HTTP 200 with lookupStatus of not_found and question null.

Stack Overflow Question API FAQ

Does a missing question return 404?

No. The request finished, so the status is 200 and data.lookupStatus is not_found with data.question null. Branch on lookupStatus before writing the row.

How many credits does a question 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.

How do I get the answers with the question?

Add include=answers. The answers are in data.question.answers and answersComplete says whether they are all there. For a question with more answers than one page holds, use GET /v1/stack-overflow/questions/{questionId}/answers and page with sort=creation.

Are comments included in the answers?

Only when you ask. Use include=answers,comments so each answer gets its comments as well as the question. answer.comments and question.comments are null when comments were not asked for.