# 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:** [Hipersoft](https://apify.com/hipersoft) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.002 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# 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, with automatic pagination so large tag or search result sets come back in one run. No key required; add an optional Stack Apps key to raise the daily quota. Built for developer researchers, community analysts and knowledge-base builders.

![Stack Exchange Scraper input — site, tags, search and sorting in the Apify Console](https://api.apify.com/v2/key-value-stores/SUfvnaFLd9z9eBCtV/records/stackexchange-scraper-input.png?v=2)

### 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.
- ⚡ **Deep pagination** — pages through large result sets up to `maxItems` automatically.

### What you get

![Stack Exchange Scraper output example — questions with scores, tags and bodies as structured JSON](https://api.apify.com/v2/key-value-stores/SUfvnaFLd9z9eBCtV/records/stackexchange-scraper-output.png?v=5)

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..."
}
```

#### Output schema

| Field | Type | Description |
|-------|------|-------------|
| `questionId` | integer | Unique Stack Exchange question ID. |
| `title` | string | Question title. |
| `tags` | array | Tags applied to the question. |
| `score` | integer | Net vote score of the question. |
| `viewCount` | integer | Number of times the question was viewed. |
| `answerCount` | integer | Number of answers on the question. |
| `isAnswered` | boolean | Whether the question is marked answered. |
| `acceptedAnswerId` | integer | ID of the accepted answer, if any. |
| `ownerName` | string | Display name of the question's author. |
| `ownerReputation` | integer | Reputation score of the author. |
| `ownerLink` | string (URL) | Link to the author's profile. |
| `creationDate` | string (ISO date) | When the question was created. |
| `lastActivityDate` | string (ISO date) | When the question last had activity. |
| `link` | string (URL) | Link to the question. |
| `body` | string | Cleaned-up question text (HTML stripped). |

### 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).

**Can I integrate this with other tools?**
The Stack Exchange Scraper can be connected with almost any cloud service or web app thanks to [integrations on the Apify platform](https://apify.com/integrations). It works with [Make](https://apify.com/integrations/make), [Zapier](https://apify.com/integrations/zapier), [Slack](https://docs.apify.com/platform/integrations/slack), [Airbyte](https://docs.apify.com/platform/integrations/airbyte), [GitHub](https://docs.apify.com/platform/integrations/github), [Google Drive](https://docs.apify.com/platform/integrations/drive) and [many more](https://apify.com/integrations), plus the [Apify API](https://docs.apify.com/api/v2), JavaScript/Python clients and MCP. Or use [webhooks](https://docs.apify.com/platform/integrations/webhooks) to trigger an action whenever a run finishes.

### 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
  }
}
```

# Actor output Schema

## `results` (type: `string`):

All dataset items produced by this run.

# 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(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 '{
  "tags": [
    "python"
  ]
}' |
apify call hipersoft/stackexchange-scraper --silent --output-dataset

```

## MCP server setup

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