# StackOverflow Scraper (`muscular_quadruplet/stackoverflow-scraper`) Actor

Scrape Stack Overflow questions, answers, tags. Extract developer Q\&A, code snippets, vote counts. Build knowledge bases, analyze programming trends, find solutions. No login required.

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

## Pricing

from $0.01 / 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

Search and extract questions, answers, and users from Stack Overflow and other Stack Exchange sites.

### Features

- **Search questions** - Find questions by keywords
- **Filter by tags** - JavaScript, Python, React, etc.
- **Multiple sites** - Stack Overflow, Server Fault, Super User, Ask Ubuntu, and more
- **Include answers** - Optionally fetch all answers
- **Top users** - Find experts by tag
- **Date filtering** - Get questions from specific time periods

### Supported Sites

- Stack Overflow (programming)
- Server Fault (system administration)
- Super User (computer enthusiasts)
- Ask Ubuntu (Ubuntu)
- Unix & Linux
- Ask Different (Apple)
- Arqade (gaming)

### Output Example

```json
{
  "rank": 1,
  "questionId": 11227809,
  "title": "Why is processing a sorted array faster than an unsorted array?",
  "link": "https://stackoverflow.com/questions/11227809",
  "score": 27509,
  "viewCount": 1600000,
  "answerCount": 26,
  "isAnswered": true,
  "tags": ["java", "c++", "performance", "cpu-architecture", "branch-prediction"],
  "body": "<p>Here is a piece of C++ code...</p>",
  "owner": "GManNickG",
  "ownerReputation": 503000,
  "createdAt": "2012-06-27T13:51:36.000Z"
}
```

### Input Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| mode | string | search, questions, or users |
| searchQuery | string | Keywords to search |
| tags | string | Tags separated by semicolons |
| site | string | Stack Exchange site |
| sortBy | string | votes, activity, creation, relevance |
| order | string | desc or asc |
| maxItems | number | Maximum items to extract |
| minScore | number | Minimum question score |
| includeAnswers | boolean | Fetch answers for each question |
| dateFrom | string | Start date (YYYY-MM-DD) |
| dateTo | string | End date (YYYY-MM-DD) |

### Use Cases

- **Training data** - Build datasets for ML/NLP
- **Research** - Analyze programming trends
- **Knowledge base** - Extract Q\&A for documentation
- **Talent sourcing** - Find top contributors
- **Content curation** - Best answers on specific topics

### Rate Limits

Stack Exchange API limits:

- **Without key:** 300 requests/day
- **With key:** 10,000 requests/day

The scraper handles quotas and backoff automatically.

### Cost

Minimal - uses FREE Stack Exchange API, no browser needed.

***

Built by [flowbot.company](https://flowbot.company)

### Usage with AI (MCP)

Connect to [mcp.apify.com](https://mcp.apify.com) and use natural language:

- "Scrape data using Stackoverflow Scraper"
- "Get results from Stackoverflow Scraper"
- "Run Stackoverflow Scraper with default settings"

# Actor input Schema

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

Scraping mode: search questions, get by tags, or find top users

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

Search query for questions (e.g., 'how to parse JSON', 'async await error')

## `tags` (type: `string`):

Filter by tags, semicolon-separated (e.g., 'javascript;react' or 'python')

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

Stack Exchange site to scrape

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

Sort results by

## `order` (type: `string`):

Sort order

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

Maximum items to extract

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

Filter questions with at least this score

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

Fetch answers for each question (slower)

## `dateFrom` (type: `string`):

Filter questions from this date (YYYY-MM-DD)

## `dateTo` (type: `string`):

Filter questions until this date (YYYY-MM-DD)

## Actor input object example

```json
{
  "mode": "search",
  "searchQuery": "javascript",
  "tags": "",
  "site": "stackoverflow",
  "sortBy": "votes",
  "order": "desc",
  "maxItems": 100,
  "minScore": 0,
  "includeAnswers": false,
  "dateFrom": "",
  "dateTo": ""
}
```

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

```

## MCP server setup

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