# Stack Exchange Scraper (`straightforward_hydra/stack-exchange-scraper`) Actor

Questions, answers and tags from Stack Overflow and 170+ Stack Exchange sites via the official API. No API key.

- **URL**: https://apify.com/straightforward\_hydra/stack-exchange-scraper.md
- **Developed by:** [Dev D](https://apify.com/straightforward_hydra) (community)
- **Categories:** Automation, Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 items

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 Exchange Scraper 💬

**Search and pull questions, answers and tags from Stack Overflow and 170+ Stack Exchange sites — Super User, Server Fault, Ask Ubuntu, Math, and more — straight from the official Stack Exchange API. No API key required.**

Whether you're monitoring how developers discuss your product, mining Q\&A for research, tracking unanswered questions in your niche, or building a dataset of technical content, this Actor turns the official Stack Exchange API into a clean, structured feed — no key, no scraping of HTML pages.

***

### Three modes

- **Search** — free-text query across titles and bodies, with rich filters: tags (must match all), excluded tags, minimum score, accepted-answer-only, answered-only, and date range.
- **Questions** — browse any site or tag by sort order (votes, activity, creation, hot).
- **Tags** — pull the tag catalog for a site with usage counts.

### What you get per question

| Field | Example |
|---|---|
| `title` | "How do I use async/await in Python?" |
| `score` · `view_count` · `answer_count` | 142 · 98,300 · 7 |
| `is_answered` · `has_accepted_answer` | true / true |
| `tags` | `["python", "async-await", "asyncio"]` |
| `owner` | display name + reputation |
| `creation_date` · `last_activity_date` | ISO-8601 |
| `link` | Link back to the question |
| `body` *(optional)* | Full question body (HTML + plain text) |
| `answers[]` *(optional)* | Top answers with score, accepted flag and body |

### Examples

**Search Stack Overflow for high-scoring Python async questions**

```json
{
  "mode": "search",
  "site": "stackoverflow",
  "query": "async await",
  "tags": ["python"],
  "minScore": 10,
  "sort": "votes"
}
```

**Recent unanswered questions for a tag**

```json
{
  "mode": "questions",
  "site": "stackoverflow",
  "tags": ["rust"],
  "answeredOnly": false,
  "sort": "creation"
}
```

**Pull questions with their top answers**

```json
{
  "mode": "search",
  "site": "serverfault",
  "query": "nginx 502",
  "includeAnswers": true,
  "answersPerQuestion": 3
}
```

### Which sites?

Any Stack Exchange site by its API slug: `stackoverflow`, `superuser`, `serverfault`, `askubuntu`, `math`, `stats`, `unix`, `dba`, `security`, `devops`, `datascience`, and 160+ more.

### Run it on a schedule

Schedule a daily run to track new questions for your tags, monitor mentions of your product or library, or keep a growing Q\&A dataset fresh in a sheet or database.

### Notes & limitations

- **No API key needed.** The Stack Exchange API is public; an optional free [Stack Apps key](https://stackapps.com/apps/oauth/register) can be supplied to raise the request quota for large runs.
- Question bodies and answers are fetched only when you enable them (each adds API cost/quota).
- Data source: the official **Stack Exchange API v2.3**. Content is licensed by Stack Exchange under Creative Commons — attribute and link back per their terms.
- The API returns public Q\&A content only.

***

#### Keywords

Stack Overflow scraper, Stack Exchange API, Stack Overflow API, questions and answers, Q\&A data, developer questions, tags, Super User, Server Fault, Ask Ubuntu, technical content, Stack Overflow search, unanswered questions, programming questions dataset, developer community data, no API key.

# Actor input Schema

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

Search = free-text + filters; Questions = browse a site/tag by sort; Tags = list a site's tags.

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

Which Stack Exchange site, e.g. stackoverflow, superuser, serverfault, askubuntu, math, unix, dba, softwareengineering, security, datascience, stats.

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

Free-text query for titles/bodies, e.g. "async await", "memory leak". Only used in Search mode.

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

Only questions with ALL these tags, e.g. \["python", "pandas"]. Used in Search and Questions modes.

## `excludeTags` (type: `array`):

Skip questions with any of these tags.

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

How to order results. votes/activity/creation for questions; hot/week/month for trending; popular for tags.

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

Only keep questions with at least this score.

## `acceptedOnly` (type: `boolean`):

Search mode: keep only questions that have an accepted answer.

## `answeredOnly` (type: `boolean`):

Search mode: keep only questions that have at least one answer.

## `fromDate` (type: `string`):

Only questions created on/after this date (YYYY-MM-DD).

## `toDate` (type: `string`):

Only questions created on/before this date (YYYY-MM-DD).

## `includeBody` (type: `boolean`):

Add the full question body as HTML and as plain text.

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

For each question, also fetch its top answers (costs extra API requests).

## `answersPerQuestion` (type: `integer`):

How many top answers to fetch when 'Include answers' is on.

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

Optional free Stack Apps key (stackapps.com/apps/oauth/register) to raise the daily quota from 300 to 10,000 requests. Not required.

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

How many items to return.

## Actor input object example

```json
{
  "mode": "search",
  "site": "stackoverflow",
  "acceptedOnly": false,
  "answeredOnly": false,
  "includeBody": false,
  "includeAnswers": false,
  "answersPerQuestion": 3,
  "maxResults": 50
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("straightforward_hydra/stack-exchange-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("straightforward_hydra/stack-exchange-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 '{}' |
apify call straightforward_hydra/stack-exchange-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,straightforward_hydra/stack-exchange-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/kVKZB0coBZwQbBQuu/builds/N9skqAIauNnRD76Oc/openapi.json
