# 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:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 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("💾 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 '{}' |
apify call nominated_tupelo/stackoverflow-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Stack Overflow Scraper - Questions, Answers & Tags",
        "description": "Scrape Stack Overflow questions, answers, users, tags, and search results using the official StackExchange API. No auth required. Works across all StackExchange sites.",
        "version": "1.0",
        "x-build-id": "fdDBnd7lBl8VrHoMu"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/nominated_tupelo~stackoverflow-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-nominated_tupelo-stackoverflow-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/nominated_tupelo~stackoverflow-scraper/runs": {
            "post": {
                "operationId": "runs-sync-nominated_tupelo-stackoverflow-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/nominated_tupelo~stackoverflow-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-nominated_tupelo-stackoverflow-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": {
                    "scrapeMode": {
                        "title": "Scrape Mode",
                        "enum": [
                            "questions",
                            "search",
                            "answers",
                            "tags",
                            "users",
                            "user_questions"
                        ],
                        "type": "string",
                        "description": "What to scrape from Stack Overflow / StackExchange.",
                        "default": "search"
                    },
                    "searchQuery": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Keyword search query. Used by search mode (e.g. 'python async await', 'react hooks', 'kubernetes deployment').",
                        "default": ""
                    },
                    "tags": {
                        "title": "Tags",
                        "type": "array",
                        "description": "Filter by tags (e.g. ['python', 'pandas']). Used by questions mode. AND logic — question must have all tags.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "questionIds": {
                        "title": "Question IDs",
                        "type": "array",
                        "description": "List of question IDs to fetch answers for. Used by answers mode.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "userIds": {
                        "title": "User IDs",
                        "type": "array",
                        "description": "StackExchange numeric user IDs. Used by users and user_questions modes.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "sortBy": {
                        "title": "Sort By",
                        "enum": [
                            "activity",
                            "votes",
                            "creation",
                            "hot",
                            "week",
                            "month",
                            "relevance"
                        ],
                        "type": "string",
                        "description": "Sort order for questions/answers.",
                        "default": "votes"
                    },
                    "site": {
                        "title": "StackExchange Site",
                        "type": "string",
                        "description": "Which StackExchange site to scrape. Default is stackoverflow. Other options: superuser, serverfault, askubuntu, math, physics, datascience, ai, etc.",
                        "default": "stackoverflow"
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Maximum items to return (0 = no limit, up to API quota).",
                        "default": 100
                    },
                    "apiKey": {
                        "title": "StackExchange API Key (optional)",
                        "type": "string",
                        "description": "Optional API key from stackapps.com to increase quota from 300/day to 10000/day. Leave blank for unauthenticated access."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
