# Stack Overflow (/docs/stackoverflow) Search Stack Overflow questions by keyword and tag, then read one question with its answers and comments Stack Overflow is where developers ask and answer programming questions. These endpoints search questions by keyword and tag, read one question in full, and read its answers and the comments posted on it. A question uses the canonical `Post` shape and its answers and comments use the `Comment` shape, with the Stack Overflow-only facts in `ext.stackoverflow`. Base URL: `/v1/stackoverflow/...` Stack Overflow exposes 4 routes here. ## Quickstart ### Search questions Pass search terms as `query`, and narrow to tags with `tagged` (several separated by semicolons). `sort` is `relevance` (the default), `votes`, `activity` or `creation`. ```bash title="cURL" curl "https://www.socialcrawl.dev/v1/stackoverflow/search?query=pandas%20groupby&tagged=python&sort=votes" \ -H "x-api-key: YOUR_API_KEY" ``` ### Read one question Take `post.id` from a search row, or pass the question's link as `url`. ```bash title="cURL" curl "https://www.socialcrawl.dev/v1/stackoverflow/question?id=11227809" \ -H "x-api-key: YOUR_API_KEY" ``` ```json title="Response (trimmed)" { "success": true, "data": { "post": { "id": "11227809", "url": "https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array", "content": { "text": "Why is conditional processing of a sorted array faster than of an unsorted array?" }, "engagement": { "likes": 27549, "views": 2038548, "comments": 25 }, "ext": { "tags": ["java", "c++", "performance", "cpu-architecture", "branch-prediction"], "stackoverflow": { "is_answered": true, "accepted_answer_id": "11227902" } } } } } ``` ### Read its answers and comments `question/answers` returns the answers, highest voted first; the accepted one carries `comment.ext.stackoverflow.is_accepted: true`. `question/comments` returns the comments on the question itself, newest first. ```bash title="cURL" curl "https://www.socialcrawl.dev/v1/stackoverflow/question/answers?id=11227809" \ -H "x-api-key: YOUR_API_KEY" ``` ## Questions people ask ### How do I find the accepted answer? `GET /v1/stackoverflow/question` returns its id in `post.ext.stackoverflow.accepted_answer_id`, and in `GET /v1/stackoverflow/question/answers` that answer is the one with `comment.ext.stackoverflow.is_accepted` true. ### Are bodies HTML? No. Question bodies, answers and comments are published as plain text, with paragraphs and code on their own lines. ### How deep can I page? Search, answers and comments return up to 100 rows a page (30 by default) for up to 25 pages. Pass the returned `cursor` for the next page. ### What does a question number that does not exist return? A `404`, which is not charged. ## All endpoints **How far back and how deep** Each list returns one page at a time. Send `cursor` for the next page, or `max_items` or `max_pages` to collect several pages in one call. A page size appears only where it has been verified. [How paging works](/docs/pagination.md). | Path | Rows per page | Date window | One call collects | | --- | --- | --- | --- | | `/v1/stackoverflow/question/answers` | about 30 | `since` and `until`, applied to each page fetched | up to 5,000 rows or 50 pages; `limit` up to 100 | | `/v1/stackoverflow/question/comments` | about 30 | `since` and `until`, applied to each page fetched | up to 5,000 rows or 50 pages; `limit` up to 100 | | `/v1/stackoverflow/search` | about 30 | `since` and `until`, applied to each page fetched | up to 5,000 rows or 50 pages; `limit` up to 100 | ## Platform notes **Times are ISO 8601 in UTC.** `post.published_at` is when the question was asked; `ext.stackoverflow.last_activity_at` is its last activity. **Stack Overflow has no handles.** `author.username` and `author.display_name` both hold the display name; the numeric user id is `ext.stackoverflow.author_user_id`. **Content is published under Creative Commons.** `ext.stackoverflow.content_license` names the licence on each question, answer and comment; credit the author when you republish it. ## Next steps - [Hacker News](/docs/hackernews.md): Developer discussion in the same Post and Comment shapes. - [Pagination](/docs/pagination.md): How cursors work across every list endpoint.