# Stack Overflow & Stack Exchange Scraper (`hipersoft/stackexchange-scraper`) Actor

Scrape questions from Stack Overflow and any Stack Exchange site by tag or full-text search: title, tags, score, views, answer count, accepted answer, author, dates, link and full question body. Fast clean HTTP via the Stack Exchange API; optional key for higher quota.

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

## Pricing

from $0.004 / question scraped

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 & Stack Exchange Scraper — Questions by Tag or Search, Clean JSON

Scrape questions from Stack Overflow and any Stack Exchange site by tag or full-text search, and get back clean, structured JSON — title, tags, score, views, answer count, accepted-answer flag, author, dates, link and the full question body. It runs on the official Stack Exchange API v2.3 over fast, plain HTTP, with automatic pagination and rate-limit backoff. No key required; add an optional Stack Apps key to raise the daily quota. Built for developer researchers, community analysts and knowledge-base builders.

### Features

- 🌐 **Any Stack Exchange site** — `site` targets `stackoverflow`, `serverfault`, `superuser`, `askubuntu`, `math`, `stats`, `unix` and more.
- 🏷️ **Tag or search** — filter by `tags`, run a full-text `query`, or combine both.
- 🔀 **Smart sorting** — `sortBy` supports `votes`, `activity`, `creation`, `hot` (tag mode) or `relevance` (search mode).
- 📈 **Quality filter** — `minScore` keeps only questions above a score threshold.
- 📄 **Full question body** — the `body` field carries the cleaned-up question text, HTML stripped and entities decoded.
- 🔑 **Optional API key** — supply a Stack Apps key to lift the quota from 300 to 10,000 requests/day.
- ⚡ **Fast, paginated HTTP** — walks `has_more` pages up to `maxItems` with automatic backoff.

### What you get

Every question becomes one clean JSON record:

```json
{
  "questionId": 12345678,
  "title": "How do I merge two dictionaries in Python?",
  "tags": ["python", "dictionary", "merge"],
  "score": 4820,
  "viewCount": 3100000,
  "answerCount": 27,
  "isAnswered": true,
  "acceptedAnswerId": 12345699,
  "ownerName": "devuser",
  "ownerReputation": 15230,
  "ownerLink": "https://stackoverflow.com/users/1/devuser",
  "creationDate": "2016-09-02T10:12:00.000Z",
  "lastActivityDate": "2026-05-14T08:41:00.000Z",
  "link": "https://stackoverflow.com/questions/12345678/how-do-i-merge-two-dictionaries",
  "body": "I have two Python dictionaries and I want to combine them into one..."
}
```

### Input

```json
{
  "site": "stackoverflow",
  "tags": ["python"],
  "query": "",
  "sortBy": "votes",
  "minScore": 50,
  "maxItems": 500
}
```

| Field | Description |
| --- | --- |
| `site` | Stack Exchange site (e.g. `stackoverflow`, `serverfault`, `superuser`, `askubuntu`, `math`, `stats`, `unix`). |
| `tags` | Filter by tags (e.g. `python`, `javascript`). One per line. Combine with a query or use alone. |
| `query` | Full-text search over questions. Leave empty to list by tag. |
| `sortBy` | `votes`, `activity`, `creation`, `hot` (tag mode) or `relevance` (search mode). |
| `minScore` | Only questions with at least this score. |
| `maxItems` | Max questions to return. |
| `apiKey` | Optional Stack Apps key to raise the daily quota from 300 to 10,000 requests. |

### Use cases

- Mine the highest-voted questions for a tag to find common problems and gaps.
- Track new or trending questions on a niche Stack Exchange site.
- Build a developer knowledge base or FAQ dataset from accepted-answer questions.
- Analyze community activity by score, views and answer counts over time.

### Pricing

Pay-per-event: you're billed a small amount per run and per item scraped — you only pay for what you get. See the **Pricing** tab for current rates.

### FAQ

**Do I need a Stack Exchange account or API key?**
No. The actor runs on the official [Stack Exchange](https://stackexchange.com/) API v2.3 with no key. An optional Stack Apps key is only needed to raise the daily quota from 300 to 10,000 requests.

**How many questions can I scrape per run?**
As many as you set with `maxItems`. The actor walks the API's `has_more` pages automatically with rate-limit backoff until it hits your limit.

**Which sites can I scrape besides Stack Overflow?**
Any Stack Exchange site — set `site` to `stackoverflow`, `serverfault`, `superuser`, `askubuntu`, `math`, `stats`, `unix` and many more.

**What's the output format?**
Structured JSON — one record per question with `title`, `tags`, `score`, `viewCount`, `answerCount`, `isAnswered`, `acceptedAnswerId`, author, dates, `link` and the full cleaned-up `body`. Export as JSON, CSV, Excel or via the API.

**Can I filter by tag, score or search term?**
Yes. Filter by `tags`, run a full-text `query`, or combine both; keep only high-quality items with `minScore`; and order results with `sortBy` (`votes`, `activity`, `creation`, `hot`, or `relevance` in search mode).

### Related Actors

Building a developer knowledge base or research dataset? Combine this with our other developer-data scrapers:

- [Hacker News Scraper](https://apify.com/hipersoft/hacker-news-scraper) — stories, comments and Ask/Show HN by keyword and filters.
- [GitHub Scraper](https://apify.com/hipersoft/github-scraper) — repositories and user profiles with stars, topics, licenses and leads.
- [Wikipedia Scraper](https://apify.com/hipersoft/wikipedia-scraper) — full article text, summaries and pageviews in any language.
- [npm Package Scraper](https://apify.com/hipersoft/npm-scraper) — search and look up npm packages with metadata, dependencies and downloads.

### Notes

This Actor uses the official public Stack Exchange API (v2.3). It is an independent tool and is not affiliated with, endorsed by, or sponsored by Stack Exchange Inc.; "Stack Overflow" and "Stack Exchange" are trademarks of Stack Exchange Inc.

# Actor input Schema

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

Stack Exchange site (e.g. stackoverflow, serverfault, superuser, askubuntu, math, stats, unix).

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

Filter by tags (e.g. python, javascript). One per line. Combine with a query or use alone.

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

Full-text search over questions. Leave empty to list by tag.

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

votes, activity, creation, hot (tag mode) or relevance (search mode).

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

Only questions with at least this score.

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

Max questions to return.

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

Optional Stack Apps key to raise the daily quota from 300 to 10000 requests.

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

Optional. The Stack Exchange API works without a proxy.

## Actor input object example

```json
{
  "site": "stackoverflow",
  "tags": [
    "python"
  ],
  "sortBy": "votes",
  "minScore": 0,
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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 = {
    "tags": [
        "python"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("hipersoft/stackexchange-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 = { "tags": ["python"] }

# Run the Actor and wait for it to finish
run = client.actor("hipersoft/stackexchange-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 '{
  "tags": [
    "python"
  ]
}' |
apify call hipersoft/stackexchange-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/7chId35v4ib1dolrK/builds/amjvPj5683XhbdFeo/openapi.json
