# Stack Overflow & Stack Exchange Questions and Answers (`atesen-software/stack-exchange-questions`) Actor

Export Stack Overflow and Stack Exchange questions and top answers by keyword, tag, date or accepted answer from the official API. Scores, tags, authors and CC BY-SA attribution on every row. No login, no proxy.

- **URL**: https://apify.com/atesen-software/stack-exchange-questions.md
- **Developed by:** [Atesen Software](https://apify.com/atesen-software) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Stack Overflow & Stack Exchange Questions and Answers

Need the real questions developers ask on Stack Overflow / Stack Exchange, with scores, tags, accepted answers and the top answers, in a spreadsheet or JSON instead of copying them by hand? This Actor exports them from the official Stack Exchange API for **$1.50 per 1,000 rows**, with CC BY-SA attribution on every row.

### What does Stack Overflow & Stack Exchange Questions and Answers do?

It searches any Stack Exchange site (Stack Overflow, Super User, Server Fault, Mathematics, Ask Ubuntu and the other 170+ sites) through the **official [Stack Exchange API v2.3](https://api.stackexchange.com/docs)** and saves one clean row per question, plus optional rows for each question's top-voted answers.

- Filter by **keyword**, **tags**, **creation date**, **accepted answer** or **zero answers**.
- Sort by activity, creation date, votes or relevance.
- Every row carries the source link, author, author profile and license (`CC BY-SA 2.5 / 3.0 / 4.0`) so reused content stays correctly credited.
- No login, no browser, no proxy. The Actor reads only the public API and follows its quota and `backoff` rules.

### What can you use it for?

- **Developer pain research and content ideas**: find the most-voted or newest questions for your library, API or framework tag and see what people struggle with.
- **Support and documentation planning**: export tagged questions with their accepted and top answers to see which topics your own docs or FAQ should cover, with attribution fields ready to keep.
- **Developer relations and product monitoring**: schedule a daily run for your tags and get the new questions in Google Sheets, Slack or a webhook through Apify integrations.
- **Community analytics**: track scores, answer counts and accepted-answer ratios for a technology over time.

### How to export Stack Overflow questions

1. Open the **Input** tab. Keep `stackoverflow` as the site or enter another site identifier such as `superuser`, `serverfault`, `math` or `askubuntu` (the part of the site address, not a URL).
2. Enter a search query (for example `react hooks`) and/or semicolon-separated tags (for example `javascript;typescript`).
3. Set **Maximum questions** and, if you want answers, **Top answers per question**.
4. Click **Start**. Download the dataset as JSON, CSV, Excel, XML or HTML, or read it through the Apify API. The `SUMMARY` record in the key-value store shows how the run ended and the remaining API quota.

### Input

| Field | Default | Meaning |
| --- | --- | --- |
| `site` | `stackoverflow` | Stack Exchange site identifier, for example `superuser` or `math`. |
| `query` | empty | Free-text search. Empty returns the latest matching questions. |
| `tagged` | empty | Semicolon-separated tags; a question matches if it has at least one of them. |
| `maxQuestions` | 10 | 1 to 2,500 questions. The search reads at most 25 pages of 100. |
| `answersPerQuestion` | 0 | 0 to 100 top-voted answers per question (0 = no answers). |
| `maxAnswers` | 100 | Cap on answer rows across all questions. |
| `accepted` | not set | `true` = only questions with an accepted answer, `false` = only without. |
| `unanswered` | false | Only questions with zero answers. |
| `fromdate`, `todate` | not set | Creation-date bounds in UTC Unix seconds. |
| `sort`, `order` | `activity`, `desc` | `activity`, `creation`, `votes` or `relevance`; `asc` or `desc`. |
| `includeBody` | false | Adds the post HTML in `bodyHtml`. Sanitize it before showing it in a web page. |
| `maxApiRequests` | 50 | Per-run cap on API calls. |
| `maxRuntimeSeconds` | 120 | The run stops cleanly before this time. |
| `apiKey` | empty | Optional free Stack Apps key. It raises the API quota from about 300 to 10,000 requests per day. |
| `userAgent` | empty | Optional custom User-Agent. Empty sends `AtesenSoftware-Actor/1.0 (+https://atesensoftware.com; stack-exchange-questions)`. |

Example input:

```json
{
  "site": "stackoverflow",
  "query": "javascript array",
  "tagged": "javascript",
  "maxQuestions": 5,
  "accepted": true,
  "sort": "votes",
  "answersPerQuestion": 1,
  "maxAnswers": 2
}
```

### Output

One row per question (`type: "question"`) and one per answer (`type: "answer"`). A real question row from the example input above:

```json
{
  "type": "question",
  "site": "stackoverflow",
  "questionId": 5767325,
  "title": "How can I remove a specific item from an array in JavaScript?",
  "questionUrl": "https://stackoverflow.com/questions/5767325/how-can-i-remove-a-specific-item-from-an-array-in-javascript",
  "sourceUrl": "https://stackoverflow.com/questions/5767325/how-can-i-remove-a-specific-item-from-an-array-in-javascript",
  "score": 12260,
  "creationDate": 1303597038,
  "lastActivityDate": 1772333292,
  "tags": ["javascript", "arrays"],
  "answerCount": 51,
  "isAnswered": true,
  "acceptedAnswerId": 5767357,
  "owner": { "displayName": "Walker", "profileUrl": "https://stackoverflow.com/users/364969/walker", "userId": 364969 },
  "contentLicense": "CC BY-SA 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by-sa/4.0/",
  "attribution": {
    "source": "Stack Exchange",
    "sourceUrl": "https://stackoverflow.com/questions/5767325/how-can-i-remove-a-specific-item-from-an-array-in-javascript",
    "author": "Walker",
    "authorUrl": "https://stackoverflow.com/users/364969/walker",
    "license": "CC BY-SA 4.0",
    "modified": false
  },
  "fetchedAt": "2026-11-15T21:50:59.963Z"
}
```

Answer rows have the same shape plus `answerId` and `isAccepted`; their `sourceUrl` points straight to the answer and `questionUrl` to the parent question. Dates are Unix seconds (UTC). Titles and display names are returned as plain text.

### How much does it cost?

Pay per event: **$1.50 per 1,000 results** ($0.0015 per saved question or answer row). There is no start fee and no monthly fee. Status messages, the `SUMMARY` record, invalid input and runs that find nothing are free. You can cap the spend with the maximum cost per run setting; the Actor stops when it is reached.

**Maximum items is a hard cap on charged rows.** Set `maxItems` in the run options (or `?maxItems=` in the API) and the run stops after that many rows (questions plus answers): it never writes or charges more rows than that number. Leave it empty for no cap. Free status rows are not counted.

### Use via API

- Without a key the Stack Exchange API allows about **300 requests per day per IP address**, and that quota can be shared with other users on the same platform IP. One request returns up to 100 questions, so 10 questions cost 1 request and 1,000 questions cost 10. Fetching answers costs one more request per question.
- For larger or scheduled exports, register a free application key at [stackapps.com](https://stackapps.com/apps/oauth/register) and put it in `apiKey` (10,000 requests per day).
- The Actor sends requests one at a time, waits whenever the API returns a `backoff` value, stops at once on HTTP 429 or an exhausted quota, and never retries in a loop. A stopped run keeps the rows it already saved and explains why in the status message and in `SUMMARY`.
- An unknown site or other invalid input ends the run as succeeded with a clear status message, zero rows and no charge.

```bash
curl -X POST "https://api.apify.com/v2/acts/atesen-software~stack-exchange-questions/run-sync-get-dataset-items?timeout=120" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"site":"stackoverflow","query":"javascript array","tagged":"javascript","maxQuestions":5,"accepted":true,"sort":"votes"}'
```

**JavaScript** (`npm install apify-client`):

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('atesen-software/stack-exchange-questions').call({ site: "stackoverflow", query: "javascript array", tagged: "javascript", maxQuestions: 5, accepted: true, sort: "votes" });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

### Use with AI agents (MCP)

Claude Desktop, Cursor, VS Code and other MCP clients can call this Actor as a tool through the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp). Load only this Actor with:

```text
https://mcp.apify.com?tools=atesen-software/stack-exchange-questions
```

Client config (sign in with Apify OAuth when the browser opens, or add an `Authorization: Bearer <APIFY_TOKEN>` header instead):

```json
{
  "mcpServers": {
    "apify": { "url": "https://mcp.apify.com?tools=atesen-software/stack-exchange-questions" }
  }
}
```

Then ask in plain words, for example: "Find the 5 most voted Stack Overflow questions about javascript arrays that have an accepted answer." The agent fills the same input fields you see on the Input tab, and runs are billed to your Apify account at the prices on the Pricing tab.

### Data source and attribution

Data comes from the official [Stack Exchange API](https://api.stackexchange.com/docs). The content is written by Stack Exchange users and licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) (version shown in each row's `contentLicense`). When you publish or reuse it, the [Stack Exchange API terms](https://stackoverflow.com/legal/api-terms-of-use) and the license require you to show Stack Exchange as the source, link to the original post, name the author and keep the same license for adapted content. The `attribution` fields in every row contain what you need.

Users are responsible for complying with the Stack Exchange API Terms of Use and the [Stack Exchange Acceptable Use Policy](https://stackoverflow.com/legal/acceptable-use-policy). That policy does not allow automated collection of network content to build a similar or competing site, or to train, test, index or improve generative AI, chatbot, LLM or machine-learning models, without Stack Exchange's prior written consent. Do not use this Actor for those purposes unless you have that consent.

This Actor is not affiliated with or endorsed by Stack Exchange Inc.; Stack Overflow and Stack Exchange are trademarks of Stack Exchange Inc.

### FAQ

**Can I scrape a site other than Stack Overflow?**
Yes. Use the site's API identifier in `site`, for example `superuser`, `serverfault`, `math`, `askubuntu`, `unix`, `dba` or `datascience`. The full list is at [api.stackexchange.com/docs/sites](https://api.stackexchange.com/docs/sites).

**Why did I get fewer rows than I asked for?**
The search may have fewer matches, local filters such as `unanswered` drop rows, or a limit (request cap, runtime, quota, maximum cost) was reached. `SUMMARY.reason` tells you which one.

**Does it include personal data?**
Only what Stack Exchange publishes for every public post: the author's display name, public profile link and user ID. You need these for attribution; if you remove them downstream, check the CC BY-SA requirements first.

**Can I schedule it?**
Yes. A daily run with `sort: "creation"` and your tags returns the newest questions; keep `maxQuestions` modest or add a Stack Apps key.

### Support

Report problems or request features on the **Issues** tab of this Actor. Built and maintained by Atesen Software.

### Related actors

- [Hacker News Scraper: Search Stories & Comments API](https://apify.com/atesen-software/hacker-news-search-comments)
- [npm Package Intelligence](https://apify.com/atesen-software/npm-package-intelligence)
- [Hugging Face Models Scraper: Downloads, Likes & Licenses](https://apify.com/atesen-software/huggingface-model-intel)

# Actor input Schema

## `site` (type: `string`):

API site identifier: stackoverflow, math, superuser, etc. No URL.

## `query` (type: `string`):

Full-text query passed to official /search/advanced. Empty returns latest matching questions.

## `tagged` (type: `string`):

Semicolon-separated tags; official advanced search matches at least one tag.

## `maxQuestions` (type: `integer`):

1–2500. Search scans at most 25 pages; filters and changing results can return fewer.

## `answersPerQuestion` (type: `integer`):

0 disables answers; otherwise up to 100 answers by score for each returned question, subject to total/request/quota limits.

## `maxAnswers` (type: `integer`):

Total answer rows across all questions.

## `includeBody` (type: `boolean`):

Stores provider HTML as data only. Sanitize before rendering in your application.

## `accepted` (type: `boolean`):

Omit for both; true requires an accepted answer, false excludes questions with accepted answers.

## `unanswered` (type: `boolean`):

Filters the search results locally to answer_count=0; may return fewer than requested within 25 pages.

## `fromdate` (type: `integer`):

Optional inclusive creation-date lower bound in UTC Unix seconds.

## `todate` (type: `integer`):

Optional inclusive creation-date upper bound in UTC Unix seconds.

## `sort` (type: `string`):

Official advanced search sort.

## `order` (type: `string`):

Ascending or descending.

## `maxRuntimeSeconds` (type: `integer`):

Stops cleanly before requests or backoff waits would exceed this duration. The Actor's default run timeout is 660 s, which leaves time to save output at the 600 s maximum; if you set a shorter run timeout, keep this value at least 30 s below it.

## `maxApiRequests` (type: `integer`):

Conservative per-run cap; all requests share provider IP quota with other users.

## `userAgent` (type: `string`):

Leave empty to send the Actor's own descriptive User-Agent. Set your own app name and contact if you prefer to identify yourself to the API.

## `apiKey` (type: `string`):

Optional, free application key from stackapps.com. It raises the daily API quota from about 300 to 10,000 requests for this run. Not a secret access token; never put an OAuth access token here.

## Actor input object example

```json
{
  "site": "stackoverflow",
  "query": "react hooks",
  "tagged": "",
  "maxQuestions": 10,
  "answersPerQuestion": 0,
  "maxAnswers": 100,
  "includeBody": false,
  "unanswered": false,
  "sort": "activity",
  "order": "desc",
  "maxRuntimeSeconds": 120,
  "maxApiRequests": 50,
  "userAgent": ""
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "react hooks",
    "maxQuestions": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("atesen-software/stack-exchange-questions").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "query": "react hooks",
    "maxQuestions": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("atesen-software/stack-exchange-questions").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "react hooks",
  "maxQuestions": 10
}' |
apify call atesen-software/stack-exchange-questions --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,atesen-software/stack-exchange-questions"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ALMJxo1iJhV20o7BV/builds/XM50ZEeMIMvuBb9TR/openapi.json
