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

$1/1K 🔥 Fast Stack Overflow scraper! Questions, answers, votes, tags, authors & accepted answers. JSON, CSV, Excel or API in seconds. Search by tag or keyword & pull thousands of Q\&A for dev research & AI training data ⚡

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

## Pricing

from $1.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/platform/actors/running/actors-in-store#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 Scraper – Stack Exchange Q\&A Data

**Scrape Stack Overflow and any Stack Exchange site (Super User, Server Fault, Ask Ubuntu, Math, Unix…) for questions, scores, views, tags, answers and owners — by search, by tag, or by question id. As JSON, CSV or Excel. No key, no proxy.**

### 💵 Pricing

**Pay per result — ~$0.0005 per item ($0.50 / 1,000 questions).** No subscription, no proxy needed. You only pay for the data you scrape, and new Apify accounts include free monthly credits, so you can test it for **$0**.

### 🔎 What can it extract?

- Question title, URL, score, view count, answer count, answered flag
- **Tags** array + Stack Exchange site
- Owner display name and reputation
- Question body (HTML stripped to clean text, capped at 8,000 chars)
- Creation date as ISO-8601
- Optional **answers** (score, accepted flag, body, owner) per question

### 🚀 How do I use it?

1. Click **Try for free**.
2. Set the input (see example below) — pick a mode, query/tags, and a site.
3. Click **Start** and download results as JSON, CSV or Excel — or pull them via the API / schedule them.

### ⚙️ Input example

```json
{
  "mode": "search",
  "query": "python async",
  "tags": "python",
  "site": "stackoverflow",
  "sort": "votes",
  "includeAnswers": false,
  "maxItems": 100
}
```

Other modes:

```json
{ "mode": "questions", "tags": "docker, kubernetes", "site": "serverfault", "maxItems": 50 }
```

```json
{ "mode": "ids", "questionIds": ["11227809", "231767"], "includeAnswers": true }
```

### 📦 Output example

```json
{
  "question_id": 36342899,
  "title": "asyncio.gather vs asyncio.wait (vs asyncio.TaskGroup)",
  "url": "https://stackoverflow.com/questions/36342899/...",
  "score": 345,
  "view_count": 403844,
  "answer_count": 5,
  "is_answered": true,
  "tags": ["python", "asynchronous", "async-await", "python-asyncio"],
  "owner_name": "Claude",
  "owner_reputation": 10250,
  "created_iso": "2017-02-14T16:21:47+00:00",
  "body_text": "asyncio.gather and asyncio.wait both...",
  "site": "stackoverflow",
  "answers": [],
  "scraped_at": "2026-06-29T12:00:00+00:00"
}
```

### 🎯 Use cases

- Build developer Q\&A / knowledge datasets for RAG and LLM fine-tuning
- Monitor trending tags, errors and libraries on Stack Overflow
- Track answered vs unanswered questions for a tag or product
- Research developer pain points, competitor mentions and tooling

### 💰 How much will it cost?

You pay only the per-result price (no proxy cost):

| Questions | Approx cost |
|---|---|
| 100 | ~$0.05 |
| 1,000 | ~$0.50 |
| 10,000 | ~$5 |

The free Stack Exchange API allows roughly 300 requests/day per IP; the actor handles throttling (HTTP 429 + the API `backoff` field) gracefully.

### 🆚 Why this one

| Feature | This actor | Others |
|---|---|---|
| Any Stack Exchange site | ✅ | SO only |
| Search, by tag, by id | ✅ | partial |
| Answers + owner reputation | ✅ | rare |
| No key / no proxy | ✅ | sometimes |
| Clean text + ISO dates | ✅ | raw HTML |

### 🔗 Related actors

- [GitHub Scraper](https://apify.com/ninhothedev/github-scraper) — repos, issues, users
- [Hacker News Scraper](https://apify.com/ninhothedev/hacker-news-scraper) — HN stories & comments
- [Dev.to Scraper](https://apify.com/ninhothedev/devto-scraper) — developer articles
- [npm Package Scraper](https://apify.com/ninhothedev/npm-package-scraper) — package metadata

### ❓ FAQ

**Do I need an API key?** No — the free Stack Exchange API tier needs no key for low volume.
**Which sites work?** stackoverflow, superuser, serverfault, askubuntu, math, unix, and any other Stack Exchange site (set `site`).
**Can I get answers too?** Yes — set `includeAnswers: true` (uses extra quota).

### 🛟 Support

Found a bug or need an extra field? Open an issue on the actor — fixes and new fields ship fast.

### Legal & privacy

Data is retrieved via the public Stack Exchange API v2.3. Content is licensed under CC BY-SA by Stack Exchange; respect their attribution requirements when republishing.

***

**Keywords:** stack overflow scraper, stack exchange api, developer questions data, q\&a scraper, programming questions, tags, answers, super user, server fault, ask ubuntu, JSON CSV Excel, RAG dataset

# Actor input Schema

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

How to fetch questions: 'search' (full-text query + optional tags), 'questions' (top questions for given tags), or 'ids' (specific question ids).

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

Full-text search terms (mode=search). e.g. 'python async', 'pandas merge', 'docker compose'.

## `tags` (type: `string`):

Comma- or space-separated tags to filter by, e.g. 'python' or 'python, asyncio'. Used in search and questions modes.

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

Which Stack Exchange site to query, e.g. stackoverflow, superuser, serverfault, askubuntu, math, unix.

## `questionIds` (type: `array`):

Specific Stack Exchange question ids to fetch (mode=ids), e.g. \['11227809', '231767'].

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

If true, fetch the answers (score, body, owner, accepted flag) for each question. Uses extra API calls and quota.

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

Ordering for search/questions modes: by votes (score), recent activity, or creation date.

## `maxItems` (type: `integer`):

Maximum number of questions to return (search/questions modes). Capped to respect API quota.

## Actor input object example

```json
{
  "mode": "search",
  "query": "python async",
  "tags": "python",
  "site": "stackoverflow",
  "questionIds": [],
  "includeAnswers": false,
  "sort": "votes",
  "maxItems": 100
}
```

# Actor output Schema

## `questions` (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": "python async",
    "tags": "python",
    "site": "stackoverflow",
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/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 = {
    "query": "python async",
    "tags": "python",
    "site": "stackoverflow",
    "maxItems": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/stackoverflow-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": "python async",
  "tags": "python",
  "site": "stackoverflow",
  "maxItems": 100
}' |
apify call ninhothedev/stackoverflow-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=ninhothedev/stackoverflow-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/qRCeUEgLUlAjDgQCR/builds/LNVOAaNFnYaFDEe3A/openapi.json
