# Stack Exchange Q\&A Scraper — Questions, Answers & Votes (`celebrated-quadraphonic/stackexchange-qa-scraper`) Actor

Scrape Stack Overflow and 170+ Stack Exchange Q\&A sites via the official API: search questions by keyword/tag, collect votes, views, answers with body text. No browser, no proxies, no API key needed.

- **URL**: https://apify.com/celebrated-quadraphonic/stackexchange-qa-scraper.md
- **Developed by:** [XiaoZhi DataTools](https://apify.com/celebrated-quadraphonic) (community)
- **Categories:** Developer tools, AI, Automation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

Scrape **Stack Overflow** and 170+ Stack Exchange Q\&A sites through the **official Stack Exchange API v2.3** — no browser, no proxies, no API key required.

### What you get

**Question rows** — title, direct link, score, view count, answer count, answered/accepted flags, tags, asker name + reputation, creation & last-activity dates.

**Answer rows** — the top-voted answers for each question with full body text (HTML stripped to clean text), score, accepted-answer flag, author name + reputation, and creation date.

### Key features

- **15 curated sites** in a dropdown: Stack Overflow, Server Fault, Super User, Ask Ubuntu, DBA, Security, Data Science, DevOps, and more — or query any of the 170+ network sites
- **Keyword + tag search** with 4 sort orders (votes, activity, newest, relevance)
- **Smart filters**: date windows (from/to) and minimum score
- **Backoff-respecting**: honors the API's `backoff` signal so your runs never get banned
- **Optional API key**: 300 requests/day free per IP without a key; add a free Stack Apps key for 10,000/day
- **Never silently empty**: empty input returns a setup-guide row; API errors become readable error rows

### Input

Type keywords into `searchQuery`, tags into `tags` (or both), pick a site and sort order, run. That's it.

### Pick your mode

| You need | Fill in | You pay for |
|---|---|---|
| Questions only | Site + search/IDs | `question` $0.001 each |
| Answers too | Tick include answers | `answer` $0.0005 each |

Unfilled inputs cost nothing — first 20 items per run are free anyway.

### Pricing

- **$0.001 per question** ($1.00 / 1,000 questions)
- **$0.0005 per answer** ($0.50 / 1,000 answers)
- First **20 items of every run are free** (questions + answers combined)
- Actor start: **$0.00005**
- Setup-guide and error rows are never charged

### Typical uses

- **RAG / fine-tuning datasets**: clean question + accepted-answer pairs, the highest-signal developer text on the internet
- **Tech trend research**: what are developers asking about right now, by tag?
- **Support content mining**: real-world problems and community-vetted solutions
- **SEO content research**: find high-traffic questions your content can answer better

# Actor input Schema

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

Optional Stack Apps API key: raises the quota from 300 to 10,000 requests/day. Free at stackapps.com/apps/oauth/register.

## `fromDate` (type: `string`):

Only questions created on/after this date (YYYY-MM-DD). Leave empty for no limit.

## `includeAnswers` (type: `boolean`):

Fetch the top-voted answers for each question (with body text and scores).

## `maxAnswersPerQuestion` (type: `integer`):

How many top answers to fetch per question.

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

Maximum questions to collect (API paginates automatically).

## `minScore` (type: `string`):

Only questions with at least this score. Leave empty for no filter.

## `searchQuery` (type: `string`):

Keywords to search in question titles/bodies, e.g. "asyncio timeout". Leave empty to browse by tag.

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

Which Stack Exchange site to scrape.

## `sortBy` (type: `string`):

How to order the questions.

## `tags` (type: `array`):

Filter by tags, e.g. \["python", "asyncio"]. Questions must have ALL listed tags.

## `toDate` (type: `string`):

Only questions created on/before this date (YYYY-MM-DD). Leave empty for no limit.

## Actor input object example

```json
{
  "apiKey": "",
  "fromDate": "",
  "includeAnswers": true,
  "maxAnswersPerQuestion": 3,
  "maxQuestions": 50,
  "minScore": "",
  "searchQuery": "asyncio",
  "site": "stackoverflow",
  "sortBy": "votes",
  "tags": [
    "python"
  ],
  "toDate": ""
}
```

# Actor output Schema

## `results` (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 = {
    "apiKey": "",
    "fromDate": "",
    "includeAnswers": true,
    "maxAnswersPerQuestion": 3,
    "maxQuestions": 50,
    "minScore": "",
    "searchQuery": "asyncio",
    "site": "stackoverflow",
    "sortBy": "votes",
    "tags": [
        "python"
    ],
    "toDate": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("celebrated-quadraphonic/stackexchange-qa-scraper").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 = {
    "apiKey": "",
    "fromDate": "",
    "includeAnswers": True,
    "maxAnswersPerQuestion": 3,
    "maxQuestions": 50,
    "minScore": "",
    "searchQuery": "asyncio",
    "site": "stackoverflow",
    "sortBy": "votes",
    "tags": ["python"],
    "toDate": "",
}

# Run the Actor and wait for it to finish
run = client.actor("celebrated-quadraphonic/stackexchange-qa-scraper").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 '{
  "apiKey": "",
  "fromDate": "",
  "includeAnswers": true,
  "maxAnswersPerQuestion": 3,
  "maxQuestions": 50,
  "minScore": "",
  "searchQuery": "asyncio",
  "site": "stackoverflow",
  "sortBy": "votes",
  "tags": [
    "python"
  ],
  "toDate": ""
}' |
apify call celebrated-quadraphonic/stackexchange-qa-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,celebrated-quadraphonic/stackexchange-qa-scraper"
        }
    }
}
```

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/QMGQscvAnVGVcoJOq/builds/pGMKT9FLGcbQE4g17/openapi.json
