# Stack Overflow API

> Stack Overflow returns programming questions and answers through a workflow and API.

Stack Overflow finds programming questions from a required plain-language query, with optional technology, answer, sort, and result-count filters. Get answer returns a question and its best answers from a required question link or plain-word search.

- Page: https://fous.com/tools/stack-overflow
- Handle: `@stack-overflow`
- Category: [Developer tools](https://fous.com/tools/category/developer-tools)
- Source website: https://stackoverflow.com
- Last verified: Sep 29, 2026

## Methods

### Get answer

Operation `get_answer`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Get a Stack Overflow question and its best answers from a question link or a plain-word search. Searches choose the most relevant answered question; answers are ordered with the accepted answer first, then by score.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `question` | string | yes | `"how do I reverse a list in Python?"` | A Stack Overflow question link or the question in plain words, e.g. https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array or how do I reverse a list in Python? |
| `max_answers` | integer | no | `2` | Number of answers to return, e.g. 3 (up to 10). |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "question"
  ],
  "properties": {
    "question": {
      "type": "string",
      "minLength": 1,
      "description": "A Stack Overflow question link or the question in plain words, e.g. https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array or how do I reverse a list in Python?",
      "examples": [
        "how do I reverse a list in Python?",
        "https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array"
      ]
    },
    "max_answers": {
      "type": "integer",
      "default": 3,
      "maximum": 10,
      "minimum": 1,
      "description": "Number of answers to return, e.g. 3 (up to 10).",
      "x-fous-developer": true,
      "examples": [
        2,
        3
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "question": "how do I reverse a list in Python?",
      "max_answers": 2
    },
    {
      "question": "https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array",
      "max_answers": 3
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `tags` | array |  | Question tags. |
| `answers` | array |  | Accepted answer first, then highest scoring answers. |
| `answers[].date` | string or null | `"2010-10-15"` | Date the answer was posted. |
| `answers[].link` | string | `"https://stackoverflow.com/a/3940144"` | Answer link. |
| `answers[].score` | integer | `1738` | Answer score. |
| `answers[].author` | string or null | `"codaddict"` | Answer author name. |
| `answers[].accepted` | boolean | `true` | Whether this is the accepted answer. |
| `answers[].answer_text` | string | ````"To get a new reversed list, apply the reversed function and collect the items into a list:\n\n```\n>>> xs = [0, 10, 20,```` | Plain-text answer with code blocks. |
| `question_link` | string | `"https://stackoverflow.com/questions/3940128/how-do-i-reverse-a-list-or-loop-over-it-backwards"` | Stack Overflow question link. |
| `question_text` | string | `"How do I iterate over a list in reverse in Python?\n\nSee also: How can I get a reversed copy of a list (avoid a separa` | Question in plain text, with code blocks preserved. |
| `question_title` | string | `"How do I reverse a list or loop over it backwards?"` | Question title. |

**Example input**

```json
{
  "question": "how do I reverse a list in Python?",
  "max_answers": 2
}
```

**Example output**

````json
{
  "tags": [
    "python",
    "list",
    "reverse"
  ],
  "answers": [
    {
      "date": "2010-10-15",
      "link": "https://stackoverflow.com/a/3940144",
      "score": 1738,
      "author": "codaddict",
      "accepted": true,
      "answer_text": "To get a new reversed list, apply the reversed function and collect the items into a list:\n\n```\n>>> xs = [0, 10, 20, 40]\n>>> list(reversed(xs))\n[40, 20, 10, 0]\n```\n\nTo iterate backwards through a list…"
    },
    {
      "date": "2010-10-15",
      "link": "https://stackoverflow.com/a/3940137",
      "score": 1542,
      "author": "mechanical_meat",
      "accepted": false,
      "answer_text": "```\n>>> xs = [0, 10, 20, 40]\n>>> xs[::-1]\n[40, 20, 10, 0]\n```\n\nExtended slice syntax is explained here. See also, documentation."
    }
  ],
  "question_link": "https://stackoverflow.com/questions/3940128/how-do-i-reverse-a-list-or-loop-over-it-backwards",
  "question_text": "How do I iterate over a list in reverse in Python?\n\nSee also: How can I get a reversed copy of a list (avoid a separate statement when chaining a method after .reverse)?",
  "question_title": "How do I reverse a list or loop over it backwards?"
}
````

### Search questions

Operation `search_questions`, version 1. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.

Find Stack Overflow programming questions matching plain-language search words. Optionally filter by technology and answers, choose a sort order, and limit results to 50. Answered means at least one answer, not necessarily an accepted answer.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `tag` | string | no | `"python"` | Limit results to a technology tag, for example: python. |
| `sort` | string | no | `"votes"` | Order questions by match, score, or most recently asked; for example: relevance. |
| `query` | string | yes | `"how to merge two dictionaries in python"` | Describe the programming problem to find, for example: how to merge two dictionaries in python. |
| `max_results` | integer | no | `3` | Maximum number of questions to return, from 1 to 50; for example: 10. |
| `answered_only` | boolean | no | `false` | Return only questions with at least one answer; for example: true. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "query"
  ],
  "properties": {
    "tag": {
      "type": "string",
      "description": "Limit results to a technology tag, for example: python.",
      "examples": [
        "python"
      ]
    },
    "sort": {
      "enum": [
        "relevance",
        "votes",
        "newest"
      ],
      "type": "string",
      "default": "relevance",
      "description": "Order questions by match, score, or most recently asked; for example: relevance.",
      "examples": [
        "votes",
        "newest"
      ]
    },
    "query": {
      "type": "string",
      "minLength": 1,
      "description": "Describe the programming problem to find, for example: how to merge two dictionaries in python.",
      "examples": [
        "how to merge two dictionaries in python",
        "xyzzy madeup error avdolpher nquzzhp",
        "javascript array remove duplicates"
      ]
    },
    "max_results": {
      "type": "integer",
      "default": 10,
      "maximum": 50,
      "minimum": 1,
      "description": "Maximum number of questions to return, from 1 to 50; for example: 10.",
      "x-fous-developer": true,
      "examples": [
        3,
        5
      ]
    },
    "answered_only": {
      "type": "boolean",
      "default": true,
      "description": "Return only questions with at least one answer; for example: true.",
      "examples": [
        false
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "tag": "python",
      "sort": "votes",
      "query": "how to merge two dictionaries in python",
      "max_results": 3
    },
    {
      "query": "how to merge two dictionaries in python"
    },
    {
      "query": "xyzzy madeup error avdolpher nquzzhp",
      "max_results": 3,
      "answered_only": false
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `questions` | array |  | Matching Stack Overflow questions. |
| `questions[].link` | string | `"https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression-in-python"` | Question page link. |
| `questions[].tags` | array |  | Technology tags. |
| `questions[].score` | integer or null | `7126` | Net vote score. |
| `questions[].title` | string | `"How do I merge two dictionaries in a single expression in Python?"` | Question title. |
| `questions[].asked_date` | string or null | `"2008-09-02"` | Date the question was asked. |
| `questions[].view_count` | integer or null | `3686962` | Number of views. |
| `questions[].answer_count` | integer or null | `45` | Number of answers. |
| `questions[].question_number` | integer | `38987` | Stack Overflow question number. |
| `questions[].has_accepted_answer` | boolean | `true` | Whether the asker accepted an answer. |

**Example input**

```json
{
  "tag": "python",
  "sort": "votes",
  "query": "how to merge two dictionaries in python",
  "max_results": 3
}
```

**Example output**

```json
{
  "questions": [
    {
      "link": "https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression-in-python",
      "tags": [
        "python",
        "dictionary",
        "merge"
      ],
      "score": 7126,
      "title": "How do I merge two dictionaries in a single expression in Python?",
      "asked_date": "2008-09-02",
      "view_count": 3686962,
      "answer_count": 45,
      "question_number": 38987,
      "has_accepted_answer": true
    },
    {
      "link": "https://stackoverflow.com/questions/1452995/why-doesnt-a-python-dict-update-return-the-object",
      "tags": [
        "python",
        "dictionary",
        "language-design"
      ],
      "score": 209,
      "title": "Why doesn't a python dict.update() return the object?",
      "asked_date": "2009-09-21",
      "view_count": 111853,
      "answer_count": 12,
      "question_number": 1452995,
      "has_accepted_answer": true
    },
    {
      "link": "https://stackoverflow.com/questions/10461531/how-to-merge-and-sum-of-two-dictionaries-in-python",
      "tags": [
        "python",
        "dictionary"
      ],
      "score": 118,
      "title": "How to merge and sum of two dictionaries in Python?",
      "asked_date": "2012-05-05",
      "view_count": 143750,
      "answer_count": 13,
      "question_number": 10461531,
      "has_accepted_answer": true
    }
  ]
}
```

## Quick start

Replace `YOUR_API_KEY` with a Fous API key. To create one, open Developers at the bottom of Fous Studio, turn on Developer mode, then go to API keys (https://app.fous.com/keys). Change the values in `input` to run the same tool on new data.

```bash
curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 180 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "api": "@stack-overflow",
  "visibility": "public",
  "operation": "get_answer",
  "version": 1,
  "input": {
    "question": "how do I reverse a list in Python?",
    "max_answers": 2
  },
  "response": {
    "format": "json"
  }
}'
```

```python
# Save as fous.py and run with python3 fous.py. No packages needed.
import json
import urllib.error
import urllib.request

api_key = "YOUR_API_KEY"

body = json.loads("{\n  \"api\": \"@stack-overflow\",\n  \"visibility\": \"public\",\n  \"operation\": \"get_answer\",\n  \"version\": 1,\n  \"input\": {\n    \"question\": \"how do I reverse a list in Python?\",\n    \"max_answers\": 2\n  },\n  \"response\": {\n    \"format\": \"json\"\n  }\n}")
request = urllib.request.Request(
    "https://api.fous.com/v1/query",
    data=json.dumps(body).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urllib.request.urlopen(request, timeout=180) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8', errors='replace')}") from error
if result.get("success") is False:
    raise RuntimeError(result.get("error", {}).get("message", "Request failed"))
print(json.dumps(result["data"]["output"], indent=2))
```

```typescript
// Save as fous.mts and run with npx tsx fous.mts.
const apiKey = "YOUR_API_KEY";

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(180_000),
  body: JSON.stringify({
  "api": "@stack-overflow",
  "visibility": "public",
  "operation": "get_answer",
  "version": 1,
  "input": {
    "question": "how do I reverse a list in Python?",
    "max_answers": 2
  },
  "response": {
    "format": "json"
  }
}),
});
type ApiResult = { success: boolean; data?: { output: unknown }; error?: { message: string } };
const result: ApiResult = await response.json();
if (!response.ok || result.success === false) {
  throw new Error(result.error?.message ?? `HTTP ${response.status}`);
}
if (!result.data) throw new Error("Missing API response data");
console.log(result.data.output);
```

## Use from an AI assistant

Connect this tool to Claude Code, Claude Desktop, Cursor, VS Code, Codex and any MCP client as its own MCP server. Each method is a typed tool whose arguments are the method’s input.

- Server URL: `https://api.fous.com/mcp/tools/stack-overflow`
- Authorization: `Authorization: Bearer <Fous API key>`

**Tools**

- `get_answer`: Get answer. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `search_questions`: Search questions. 1 credit per completed call. Failed calls without a completed billing receipt are free; completed work can remain charged if delivery is interrupted.
- `fous_get_run`: the result of a run that was still going, by its `request_id`. Free.

Claude Code:

```bash
claude mcp add --scope user --transport http fous-stack-overflow https://api.fous.com/mcp/tools/stack-overflow --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"
```

To give the assistant every tool, connect `https://api.fous.com/mcp`: it finds one with `fous_search_tools` and runs it with `fous_run_tool`. Setup for other clients: https://fous.com/llms-full.txt.

## Use cases

- Find questions about a programming problem
- Filter questions by technology tag
- Review questions with at least one answer
- Retrieve accepted and highest-scoring answers
- Compare question scores, views, and answer counts

## FAQ

### Can I run it with my own inputs?

Yes. Change the inputs in Studio and press Run, or send new inputs from your code, or ask a connected AI assistant.

### Can I call this Stack Overflow tool as an API?

Yes. Send a POST request to /v1/query with your Fous API key and the inputs, and get JSON back.

### How much does it cost?

Each completed run costs 1 credit. Failed runs without a completed receipt are free; completed work can remain charged if delivery is interrupted. With pay as you go, a credit costs 1¢. Monthly plans cost less per credit.

### Do I need a Stack Overflow account?

No. You only need a Fous account.

### How current is the data?

Fous gets the data from stackoverflow.com when you run it. Some results are reused for up to 24 hours, and results that use your account or key are never reused. It was last verified on Sep 29, 2026.

### How can I find questions about a programming problem?

Search questions finds matching questions from a required plain-language query, with optional filters for technology, answers, sort order, and result count.

### How can I get answers to a Stack Overflow question?

Get answer returns a question and its best answers from a question link or plain-word search.

### Can I find questions with at least one answer?

Search questions can return only questions with at least one answer when answered only is enabled.

## Related

- [GitHub API](https://fous.com/tools/github.md): GitHub returns public repository matches and details, up to 25 trending projects, issues, pull requests, and newest-first published releases; release or commit dates may be unavailable.
- [Reddit API](https://fous.com/tools/reddit.md): Reddit returns searchable public posts, community feeds/details, user profiles and recent activity, posts with up to 200 comments; unavailable content limits results; Top defaults weekly.
- [Google Search API](https://fous.com/tools/google-search.md): Google Search returns public web, image, job, event, related-question, and autocomplete results in Google’s order, with answers and details when available; results may be fewer, omit information, or be empty.
- [Hacker News API](https://fous.com/tools/hacker-news.md): Hacker News provides current ranked story lists, searchable stories and comments, discussion threads with up to 500 visible comments excluding deleted or flagged ones, and monthly hiring posts with details when stated.
- [Substack API](https://fous.com/tools/substack.md): Substack returns public newsletters and recent public post details or text; paid posts expose previews or metadata, and some custom-domain newsletters may be unavailable.
- [Remote OK API](https://fous.com/tools/remote-ok.md): Remote job postings from Remote OK.
- [Goodreads API](https://fous.com/tools/goodreads.md): Goodreads returns public book searches, matched-book details with variable editions, popular or newest reviews, author books by popularity or date, and up to 100 quotes.
- [npm API](https://fous.com/tools/npm.md): npm provides package details, search results and latest versions, plus weekly download and publish data; daily and historical download counts may lag by a day or more.
- [All Developer tools tools](https://fous.com/tools/category/developer-tools)
