# 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 a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Stack Overflow Question Scraper",
        "description": "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.",
        "version": "2.0",
        "x-build-id": "bJS22QspuUbdW0wmy"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/electrabot.info~stackoverflow-question-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-electrabot.info-stackoverflow-question-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/electrabot.info~stackoverflow-question-scraper/runs": {
            "post": {
                "operationId": "runs-sync-electrabot.info-stackoverflow-question-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/electrabot.info~stackoverflow-question-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-electrabot.info-stackoverflow-question-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "searchQuery": {
                        "title": "Search query",
                        "type": "string",
                        "description": "Free-text search (e.g. 'react hooks useState'). At least one of search query or tags is required."
                    },
                    "tags": {
                        "title": "Tags",
                        "type": "array",
                        "description": "Only questions having ALL of these Stack Overflow tags (e.g. ['python', 'asyncio']). At least one of search query or tags is required.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sort": {
                        "title": "Sort by",
                        "enum": [
                            "votes",
                            "activity",
                            "creation",
                            "relevance"
                        ],
                        "type": "string",
                        "description": "How to sort the returned questions.",
                        "default": "votes"
                    },
                    "order": {
                        "title": "Order",
                        "enum": [
                            "desc",
                            "asc"
                        ],
                        "type": "string",
                        "description": "Sort direction.",
                        "default": "desc"
                    },
                    "maxResults": {
                        "title": "Max questions",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Maximum number of questions to return (1-10,000). Each question is one billable result.",
                        "default": 100
                    },
                    "apiKey": {
                        "title": "Stack Exchange API key",
                        "type": "string",
                        "description": "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": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "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).",
                        "default": {
                            "useApifyProxy": false
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
