Stack Overflow question API
One Stack Overflow question by id or link: title, body, tags, score, views, answer count and accepted answer.
GET /v1/stackoverflow/questions/{id}1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/stackoverflow/questions/11227809",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "question_id": 11227809, "title": "Why is conditional processing of a sorted array faster than of an unsorted array?", "link": "https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-…", "body": "<p>In this C++ code, sorting the data (<em>before</em> the timed region) makes the primary loop ~6x faster:</p>\n<pre cla…", "tags": [ "java", "c++", "… 3 more" ], "owner": { "user_id": 87234, "display_name": "GManNickG", "reputation": 507447, "link": "https://stackoverflow.com/users/87234/gmannickg", "user_type": "registered", "account_id": 31692, "accept_rate": 100, "profile_image": "https://i.sstatic.net/FkjBe.png?s=256" }, "is_answered": true, "accepted_answer_id": 11227902, "answer_count": 25, "score": 27548, "view_count": 2044104, "creation_date": 1340805096, "last_activity_date": 1788489410, "protected_date": 1399067470, "last_edit_date": 1775626532, "content_license": "CC BY-SA 4.0"}Parameters
| Name | Type | Description |
|---|---|---|
idpath · required | string | A question id or its stackoverflow.com link. Example: 11227809. |
Response fields
200 with a StackOverflowQuestion, in Stack Overflow’s own JSON.
| Field | Type | Description |
|---|---|---|
question_id | integer | |
title | string | |
link | string | |
body | string | HTML. |
tags | string[] | |
owner | StackOverflowOwner | |
is_answered | boolean | |
accepted_answer_id | integer | |
answer_count | integer | |
score | integer | |
view_count | integer | |
creation_date | integer | |
last_activity_date | integer | |
closed_date | integer | |
closed_reason | string |
Status codes
| Status | Meaning |
|---|---|
200 | The question. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The question does not exist or was deleted. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | Stack Overflow is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
Does it take a link?
Yes, a stackoverflow.com/questions/… link works as the id.
Stack Overflow is a trademark of Stack Exchange, Inc. We are not affiliated with or endorsed by Stack Exchange, Inc.