# Stack Overflow Q\&A Scraper (`sheshinmcfly/stackoverflow-scraper`) Actor

Extract quality-scored Q\&A from 30 Stack Exchange communities via the official API. Includes qualityScore (0-100), frustrationScore, linked questions, date range filters, and popular tags explorer. Perfect for AI training data, RAG pipelines, and market research.

- **URL**: https://apify.com/sheshinmcfly/stackoverflow-scraper.md
- **Developed by:** [Sheshinmcfly](https://apify.com/sheshinmcfly) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 6 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Stack Overflow Q\&A Scraper

Extract **questions and answers from Stack Overflow** via the official Stack Exchange API. Filter by tags, search by keywords, or get the top-voted questions of all time. Returns full question body, accepted answer, and top answers.

Perfect for AI training datasets, technical knowledge bases, RAG pipelines, and building Q\&A chatbots.

***

### What data does it extract?

#### Questions

| Field | Description | Example |
|---|---|---|
| `questionId` | Stack Overflow question ID | `11227809` |
| `title` | Question title | `"What does the yield keyword do?"` |
| `body` | Full question body (HTML) | `"<p>I'm trying to understand..."` |
| `tags` | Associated tags | `["python", "generator", "yield"]` |
| `score` | Net upvotes | `13133` |
| `viewCount` | Number of views | `4200000` |
| `answerCount` | Total number of answers | `32` |
| `isAnswered` | Has an accepted answer | `true` |
| `author` | Question author username | `"e-satis"` |
| `createdAt` | Question creation date | `"2012-03-15T10:00:00Z"` |
| `url` | Direct link | `"https://stackoverflow.com/q/11227809"` |
| `answers` | Array of top answers | `[...]` |
| `extractedAt` | Extraction timestamp | `"2026-04-21T12:00:00Z"` |

#### Answers (nested)

| Field | Description | Example |
|---|---|---|
| `answerId` | Answer ID | `231855` |
| `author` | Answer author | `"e-satis"` |
| `score` | Net upvotes | `18307` |
| `isAccepted` | Accepted by question author | `true` |
| `body` | Full answer body (HTML) | `"<p>To understand what yield does..."` |
| `createdAt` | Answer creation date | `"2012-03-15T10:30:00Z"` |
| `url` | Direct answer link | `"https://stackoverflow.com/a/231855"` |

***

### Use cases

- **AI training data**: High-quality problem/solution pairs for LLM fine-tuning
- **RAG pipelines**: Build a Q\&A bot that answers based on real Stack Overflow solutions
- **Technical knowledge base**: Export answers for a specific technology stack
- **Developer tools**: Power autocomplete or search features with curated Q\&A
- **Research**: Analyze how developers solve specific problems
- **Chatbot training**: Create domain-specific support bots

***

### How to use

1. Open the actor and configure:
   - **Mode**: By tags, keyword search, or top voted all-time
   - **Tags**: e.g. `python`, `javascript`, `docker`, `react`
   - **Keywords**: e.g. `"how to reverse a list in python"`
   - **Site**: Stack Overflow, Super User, Server Fault, etc.
   - **Include answers**: Fetch top answers for each question
   - **API key**: Optional — increases daily quota from 300 to 10,000 requests
2. Click **Start**
3. Download results as JSON, CSV, or Excel

> **Agent-ready via x402:** AI agents can run this actor directly with USDC on Base — no Apify account needed. See [x402 protocol docs](https://docs.apify.com/platform/integrations/x402).

***

### API Key (optional)

The Stack Exchange API allows 300 free requests/day without authentication. To increase this to **10,000 requests/day**, register a free app at [stackapps.com](https://stackapps.com) and paste the key in the `apiKey` field.

***

### Example output (JSON)

```json
{
  "questionId": 231767,
  "title": "What does the \"yield\" keyword do in Python?",
  "body": "<p>What is the use of the <code>yield</code> keyword in Python?...",
  "tags": ["python", "iterator", "generator", "yield"],
  "score": 13133,
  "viewCount": 4200000,
  "answerCount": 32,
  "isAnswered": true,
  "author": "e-satis",
  "createdAt": "2008-10-23T22:21:01.000Z",
  "url": "https://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do-in-python",
  "answers": [
    {
      "answerId": 231855,
      "author": "e-satis",
      "score": 18307,
      "isAccepted": true,
      "body": "<p>To understand what <code>yield</code> does, you must understand what generators are...",
      "createdAt": "2008-10-23T22:48:54.000Z",
      "url": "https://stackoverflow.com/a/231855"
    }
  ],
  "extractedAt": "2026-04-21T12:00:00.000Z"
}
```

***

### Pricing

This actor charges **$0.002 USD per question extracted**. Extracting 100 questions (with answers) costs approximately $0.20 USD.

***

### FAQ

**Does it work on other Stack Exchange sites (Super User, Server Fault, etc.)?**
Yes — set the `site` field to `superuser`, `serverfault`, `askubuntu`, `math`, or any Stack Exchange site slug.

**What is the daily API quota?**
Without an API key: 300 requests/day. With a free key from [stackapps.com](https://stackapps.com): 10,000 requests/day. Each page of 100 questions uses 1 request; fetching answers adds 1 request per question.

**Can I get unanswered questions?**
Yes — set `onlyAnswered` to `false`. By default only answered questions are returned.

**Is authentication required?**
No. The Stack Exchange API is public. An optional API key increases your daily quota.

**How many questions can I extract per run?**
Up to 10,000 (100 pages × 100 per page). For most use cases 50–500 is sufficient.

***

### Other actors you may like

- **[Reddit Thread Scraper](https://apify.com/sheshinmcfly/reddit-thread-scraper)** — posts and comments from any subreddit.
- **[ArXiv Paper Scraper](https://apify.com/sheshinmcfly/arxiv-paper-scraper)** — research papers and metadata.
- **[Trustpilot Reviews Scraper](https://apify.com/sheshinmcfly/trustpilot-reviews-scraper)** — business reviews and ratings.
- **[MercadoLibre Scraper](https://apify.com/sheshinmcfly/mercadolibre-scraper)** — product listings from MercadoLibre across 7 countries.

***

### Keywords

stackoverflow scraper, stack overflow Q\&A extractor, technical Q\&A dataset, stack exchange API scraper, developer knowledge base, AI training data, programming Q\&A, stack overflow answers, RAG dataset, LLM fine-tuning data

***

### Legal Disclaimer

This actor extracts **publicly available data only** from Stack Overflow and Stack Exchange sites using the **official Stack Exchange API v2.3**, in compliance with Chilean Law 19.628 on the Protection of Private Life (*Ley 19.628 sobre Protección de la Vida Privada*).

All content on Stack Exchange is licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Users are responsible for complying with attribution requirements when using extracted content.

**What this actor does NOT collect:**

- Private messages or non-public content
- User emails, passwords, or private account information
- Any data not freely accessible via the public API

**What this actor collects:**

- Question titles, bodies, and tags (public content)
- Publicly visible usernames and answer text
- Engagement metrics (scores, view counts)

Users are solely responsible for ensuring their use of this data complies with applicable laws and Stack Exchange's terms of service.

# Actor input Schema

## `mode` (type: `string`):

How to query Stack Exchange: by tags, keyword search, top voted all-time, or explore popular tags.

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

Filter questions by tags (used in 'By tags' mode). E.g. python, javascript, docker, react.

## `keywords` (type: `string`):

Search query (used in 'By keyword search' mode). Supports full text search: 'how to reverse a list in python'.

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

Which Stack Exchange community to query. 30 most popular sites available + any other via custom input.

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

How to sort questions.

## `onlyAnswered` (type: `boolean`):

Skip questions with no accepted answer. Turn off for broader discovery.

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

Fetch the top answers for each question. Disable for faster runs.

## `includeLinked` (type: `boolean`):

Also fetch questions linked to each result. Useful for building connected knowledge graphs.

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

How many top-voted answers to fetch per question.

## `maxLinkedQuestions` (type: `integer`):

How many linked questions to fetch per result.

## `maxResults` (type: `integer`):

Maximum number of questions (or tags in 'popular tags' mode) to extract.

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

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

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

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

## `minScore` (type: `integer`):

Only return questions with at least this score. E.g. set to 10 to get well-vetted content.

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

Only return questions with at most this many answers. 0 = no limit. Useful for finding unanswered questions.

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

Optional API key to increase daily quota from 300 to 10,000 requests. Get one free at stackapps.com.

## Actor input object example

```json
{
  "mode": "tags",
  "tags": [
    "python"
  ],
  "keywords": "",
  "site": "stackoverflow",
  "sortBy": "votes",
  "onlyAnswered": true,
  "includeAnswers": true,
  "includeLinked": false,
  "maxAnswersPerQuestion": 3,
  "maxLinkedQuestions": 5,
  "maxResults": 50,
  "fromDate": "",
  "toDate": "",
  "minScore": 0,
  "maxAnswers": 0,
  "apiKey": ""
}
```

# Actor output Schema

## `dataset` (type: `string`):

All scraped Stack Overflow questions stored in the default dataset.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("sheshinmcfly/stackoverflow-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("sheshinmcfly/stackoverflow-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 '{}' |
apify call sheshinmcfly/stackoverflow-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,sheshinmcfly/stackoverflow-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/dap13C4XmaqYvn8V0/builds/mZ3ndup1sFPi6E01m/openapi.json
