# Stack Overflow Scraper - Questions, Answers & Tags (`nominated_tupelo/stackoverflow-scraper`) Actor

Scrape Stack Overflow questions, answers, users, tags, and search results using the official StackExchange API. No auth required. Works across all StackExchange sites.

- **URL**: https://apify.com/nominated\_tupelo/stackoverflow-scraper.md
- **Developed by:** [kade](https://apify.com/nominated_tupelo) (community)
- **Categories:** Developer tools
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 results

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/actors/running/actors-in-store.md#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 Scraper — Questions, Answers, Users & Tags

Scrape Stack Overflow (and any StackExchange site) using the **official StackExchange API**. No browser. No proxies. No login required. Works across all 170+ StackExchange communities.

### What you can scrape

| Mode | What you get |
|---|---|
| `search` | Questions matching a keyword query (title, body, tags) |
| `questions` | Questions filtered by tag(s), sorted by activity/votes/creation/hot |
| `answers` | All answers for specific question IDs |
| `tags` | Most popular tags, or search tags by name |
| `users` | Top users by reputation, with badge counts and stats |
| `user_questions` | All questions asked by specific user IDs |

### Why use Stack Overflow Scraper?

- **Developer research** — analyze what problems developers actually face in a technology (Python async, React hooks, Kubernetes)
- **Content marketing** — find the most-asked questions to build SEO content around
- **Q\&A dataset building** — build training or evaluation datasets for LLMs from Q\&A pairs
- **Competitive analysis** — see which tags are growing, which frameworks have the most unresolved issues
- **Community analytics** — track top contributors, analyze user reputation growth
- **Works on any SE site** — stackoverflow, superuser, serverfault, datascience, ai, math, physics, and 160+ more

### How to use

1. Select a **Scrape Mode** in the Input tab
2. Enter your query, tags, question IDs, or user IDs as appropriate
3. Optionally add a **StackExchange API key** for higher daily quota (10,000/day vs 300/day)
4. Click **Start** — results appear in the Output tab immediately

### Input

| Parameter | Type | Default | Description |
|---|---|---|---|
| `scrapeMode` | string | `search` | `questions`, `search`, `answers`, `tags`, `users`, `user_questions` |
| `searchQuery` | string | — | Keyword query for `search` mode. Also filters tag names in `tags` mode. |
| `tags` | string\[] | — | Tag filter for `questions` mode (e.g. `['python', 'pandas']`). AND logic. |
| `questionIds` | string\[] | — | Question IDs for `answers` mode. |
| `userIds` | string\[] | — | User IDs for `users` and `user_questions` modes. |
| `sortBy` | string | `votes` | `activity`, `votes`, `creation`, `hot`, `week`, `month`, `relevance` |
| `site` | string | `stackoverflow` | StackExchange site name (e.g. `superuser`, `datascience`, `askubuntu`) |
| `maxItems` | integer | `100` | Max items to return (0 = no limit, subject to API quota) |
| `apiKey` | string | — | StackExchange API key for 10,000/day quota vs 300/day default |

### Example inputs

#### Search for Python async questions

```json
{
  "scrapeMode": "search",
  "searchQuery": "python async await performance",
  "sortBy": "votes",
  "maxItems": 50
}
```

#### Get top Python pandas questions

```json
{
  "scrapeMode": "questions",
  "tags": ["python", "pandas"],
  "sortBy": "votes",
  "maxItems": 200
}
```

#### Get answers for specific questions

```json
{
  "scrapeMode": "answers",
  "questionIds": ["11227809", "3437059"],
  "maxItems": 50
}
```

#### Scrape Data Science Stack Exchange instead

```json
{
  "scrapeMode": "questions",
  "site": "datascience",
  "tags": ["neural-network"],
  "sortBy": "votes",
  "maxItems": 100
}
```

### Output examples

#### Question

```json
{
  "type": "question",
  "questionId": 11227809,
  "title": "What does ** (double star/asterisk) and * (star/asterisk) do for parameters?",
  "link": "https://stackoverflow.com/questions/11227809",
  "score": 5864,
  "viewCount": 2891234,
  "answerCount": 22,
  "isAnswered": true,
  "acceptedAnswerId": 36908,
  "tags": ["python", "parameter-passing"],
  "owner": {
    "userId": 100297,
    "displayName": "user97370",
    "reputation": 1001
  },
  "createdAt": 1342517643,
  "body": "What do `*args` and `**kwargs` mean?..."
}
```

#### Answer

```json
{
  "type": "answer",
  "answerId": 36908,
  "questionId": 11227809,
  "score": 8921,
  "isAccepted": true,
  "owner": {
    "userId": 4279,
    "displayName": "Jochen Ritzel",
    "reputation": 103452
  },
  "createdAt": 1197839523,
  "body": "The `*args` and `**kwargs` is a common idiom..."
}
```

#### User

```json
{
  "type": "user",
  "userId": 22656,
  "displayName": "Jon Skeet",
  "reputation": 1421350,
  "badgeCounts": {"gold": 946, "silver": 3178, "bronze": 8038},
  "link": "https://stackoverflow.com/users/22656",
  "location": "Reading, United Kingdom",
  "answerCount": 40123,
  "questionCount": 58
}
```

### API Quota

Without an API key: 300 requests/day per IP. Each page = 1 request, 100 items/page. So 300 requests = 30,000 items/day free.

With an API key (free, register at stackapps.com): 10,000 requests/day = 1,000,000 items/day.

For most use cases the free quota is sufficient. Heavy bulk scraping should use an API key.

### Pricing

This actor uses **Pay Per Event** — you pay per item returned.

- **100 questions**: ~$0.01
- **1,000 answers**: ~$0.05
- **Top 500 users**: ~$0.03

### Tips

- Use `site: datascience` or `site: ai` to target ML-specific communities
- The `search` mode supports boolean operators: `python OR javascript async`
- `body` field is included when available — useful for building Q\&A training datasets for LLMs
- Combine `user_questions` + known expert user IDs to build curated expert answer datasets

# Actor input Schema

## `scrapeMode` (type: `string`):

What to scrape from Stack Overflow / StackExchange.

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

Keyword search query. Used by search mode (e.g. 'python async await', 'react hooks', 'kubernetes deployment').

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

Filter by tags (e.g. \['python', 'pandas']). Used by questions mode. AND logic — question must have all tags.

## `questionIds` (type: `array`):

List of question IDs to fetch answers for. Used by answers mode.

## `userIds` (type: `array`):

StackExchange numeric user IDs. Used by users and user\_questions modes.

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

Sort order for questions/answers.

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

Which StackExchange site to scrape. Default is stackoverflow. Other options: superuser, serverfault, askubuntu, math, physics, datascience, ai, etc.

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

Maximum items to return (0 = no limit, up to API quota).

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

Optional API key from stackapps.com to increase quota from 300/day to 10000/day. Leave blank for unauthenticated access.

## Actor input object example

```json
{
  "scrapeMode": "search",
  "searchQuery": "",
  "tags": [],
  "questionIds": [],
  "userIds": [],
  "sortBy": "votes",
  "site": "stackoverflow",
  "maxItems": 100
}
```

# 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("nominated_tupelo/stackoverflow-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("nominated_tupelo/stackoverflow-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 nominated_tupelo/stackoverflow-scraper --silent --output-dataset

```

## MCP server setup

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