# Stack Overflow Question Scraper (`electrabot.info/stackoverflow-question-scraper`) Actor

Search Stack Overflow questions by keyword or tag. Get title, full body, score, views, answers, accepted-answer status as JSON/CSV. Official API, pay per result.

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

## Pricing

from $3.00 / 1,000 questions

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 Question Scraper

Search Stack Overflow by **keywords or tags** and get structured question data —
title, **full question body**, score, views, answer counts, accepted-answer
status, tags, and author — as JSON, CSV, or Excel.

Built on the **official Stack Exchange API**: no fragile HTML scraping, no bot
walls, no breakage when the site redesigns.

**Pay per result** — you're only charged for questions actually delivered,
never for failed runs or empty searches.

***

### What can I use it for?

- **AI & LLM datasets** — every record includes the full question body (Markdown), ready for fine-tuning, RAG, or trend analysis.
- **Developer-tool market research** — what are people struggling with in your ecosystem? Sort by votes or recency.
- **Content & SEO research** — the highest-voted unanswered questions in a tag are a content-idea goldmine.
- **Competitive intelligence** — track question volume and sentiment around frameworks, APIs, and products.
- **Lead generation** — questions about problems your product solves, with links to engage.

***

### Input

| Field | Required | Description |
|-------|----------|-------------|
| **Search query** | ◐ | Free-text search (e.g. `react hooks useState`). At least one of query or tags is required. |
| **Tags** | ◐ | Only questions having **all** of these tags (e.g. `python`, `asyncio`). |
| **Sort by / Order** | – | `votes` (default), `activity`, `creation`, or `relevance`; descending or ascending. |
| **Max questions** | – | 1–10,000 (default 100). Each question = one billable result. |
| **Stack Exchange API key** | – | Optional, free ([stackapps.com](https://stackapps.com/apps/oauth/register)). Raises the daily request quota from 300 (shared per IP) to 10,000 — recommended for large or recurring jobs. |
| **Proxy configuration** | – | Off by default — the official API is scraper-friendly. Enable only if a shared IP's anonymous quota is exhausted. |

### Output

One dataset record per question. Example (shortened):

```json
{
  "questionId": 27435284,
  "title": "multiprocessing vs multithreading vs asyncio",
  "url": "https://stackoverflow.com/questions/27435284/...",
  "tags": ["python", "multithreading", "asyncio"],
  "score": 250,
  "viewCount": 150000,
  "answerCount": 8,
  "isAnswered": true,
  "hasAcceptedAnswer": true,
  "acceptedAnswerId": 27436839,
  "body": "I found that in Python 3.4 there are several libraries for ...",
  "createdAt": "2014-12-11T12:58:36Z",
  "lastActivityAt": "2023-11-14T22:13:20Z",
  "owner": {
    "displayName": "user3654650",
    "reputation": 5000,
    "userId": 3654650,
    "profileUrl": "https://stackoverflow.com/users/3654650/..."
  }
}
```

| Field | Description |
|-------|-------------|
| `body` | **Full question text as Markdown** — most competing scrapers return only titles |
| `score` / `viewCount` / `answerCount` | Community signals for ranking and filtering |
| `hasAcceptedAnswer` / `acceptedAnswerId` | Filter for solved (or unsolved!) questions |
| `owner` | Author display name, reputation, profile link (`null` for deleted users) |

***

### Why this scraper is reliable

- **Official API, not HTML** — Stack Overflow redesigns can't break it, and there are no bot walls to fight. Results are exactly what the site's own search returns.
- **Quota-aware** — honors the API's `backoff` signals (ignoring them gets IPs banned), reports remaining quota in the run summary, and stops loudly — never silently short — if quota runs out.
- **Honest run statuses** — a run only says *Succeeded* when the search completed. API failures mid-run are labeled `PARTIAL:` with the reason; a search that matches zero questions says so explicitly. Never a silent empty dataset.
- **Batch-safe** — questions are saved incrementally page by page and runs are checkpointed: an interruption never loses finished work, and a resurrected run resumes without re-charging.
- **Deduplicated** — question IDs are tracked across pages and restarts; you never pay for the same question twice.

### Tips & limits

- **Large jobs: bring a (free) API key.** Anonymous API quota is 300 requests/day *shared per IP address*; a key raises it to 10,000/day for your runs alone. One request fetches 100 questions, so a key covers up to 1M questions/day.
- Tags are ANDed: `["python", "pandas"]` returns questions tagged with *both*.
- `sort: creation, order: asc` walks a tag's history from the very first question — useful for building complete archives.

### FAQ

**Does it include answers?**
Records include answer *counts* and the accepted answer's ID. Full answer text is on the roadmap — tell us in the Issues tab if you need it.

**Can it scrape other Stack Exchange sites (Super User, Server Fault…)?**
This actor targets Stack Overflow. If you need other sites, open an issue — the engine supports them.

**Why did my run stop early?**
Check the `SUMMARY` record: it reports the exact reason (usually anonymous API quota exhausted — add a free API key) plus how many questions were delivered. You're only charged for what was delivered.

**Is this legal?**
The actor uses the official, documented Stack Exchange API and only accesses public data. Content is licensed CC BY-SA by Stack Exchange; attribution requirements apply to republication.

***

### Disclaimer

**This is an unofficial tool. It is not affiliated with, endorsed by, sponsored by,
or in any way officially connected to Stack Overflow or Stack Exchange, Inc.**
"Stack Overflow" and related names, marks, and logos are trademarks of their
respective owners and are used here for descriptive purposes only.

This actor accesses only **publicly available** data via the official Stack
Exchange API. You are responsible for ensuring your use complies with applicable
laws, the Stack Exchange API terms, and content licensing (CC BY-SA). Use it
ethically and at your own risk.

# Actor input Schema

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

Free-text search (e.g. 'react hooks useState'). At least one of search query or tags is required.

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

Only questions having ALL of these Stack Overflow tags (e.g. \['python', 'asyncio']). At least one of search query or tags is required.

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

How to sort the returned questions.

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

Sort direction.

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

Maximum number of questions to return (1-10,000). Each question is one billable result.

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

Optional but recommended for large jobs: raises the daily request quota from 300 (shared per IP) to 10,000. Free registration at stackapps.com.

## `proxyConfiguration` (type: `object`):

Off by default - the official Stack Exchange API is scraper-friendly. Enable only if the shared IP's anonymous quota is exhausted (or better: use a free API key).

## Actor input object example

```json
{
  "searchQuery": "python asyncio",
  "sort": "votes",
  "order": "desc",
  "maxResults": 100,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `questions` (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 = {
    "searchQuery": "python asyncio",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("electrabot.info/stackoverflow-question-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 = {
    "searchQuery": "python asyncio",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("electrabot.info/stackoverflow-question-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 '{
  "searchQuery": "python asyncio",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call electrabot.info/stackoverflow-question-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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