# Stack Overflow Scraper - Questions & Tags (`benthepythondev/stackoverflow-scraper`) Actor

Search Stack Overflow (or any Stack Exchange site) by keyword: question title, link, tags, score, views, answer count, accepted flag, asker and dates. Filter by tag, sort by relevance/votes/activity. Reliable via the public Stack Exchange API, no key.

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

## Pricing

from $1.50 / 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/platform/actors/running/actors-in-store#pay-per-event

## 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, Tags & Votes

Search **Stack Overflow** — or any Stack Exchange site — by keyword and get clean, structured question data for every result: title, direct link, tags, score, view count, answer count, answered and accepted-answer flags, the asker's name and reputation, and the creation and last-activity dates. Filter to a specific tag and sort by relevance, votes, activity or creation date to surface exactly the questions you need.

The actor is powered by the public **Stack Exchange API**, so it is fast and reliable with no browser, no login and no API key. Export to JSON/CSV/Excel, run on a schedule, call via API, or connect to Make, Zapier or n8n.

### 🔎 What is the Stack Overflow Scraper?

Stack Overflow is the world's largest developer Q&A community, and the wider Stack Exchange network covers everything from server administration to data science, math and security. This actor turns a keyword search into a structured dataset: give it terms like `asyncio` or `pandas merge`, optionally restrict to a tag such as `python`, choose a sort order, and it returns the top matching questions as tidy rows.

Because it queries the official Stack Exchange API instead of scraping HTML, results are consistent and well-typed, and every row carries the engagement signals that matter — score, views, answers and whether an accepted answer exists — so you can instantly rank questions by popularity or spot unanswered gaps worth writing about.

#### What data does it extract?

- **Question ID** and **title**
- **Link** — the direct URL to the question
- **Site** — the Stack Exchange site the question is from
- **Tags** — the full list of tags on the question
- **Score** — net upvotes
- **View count** — total views
- **Answer count** — number of answers
- **Is answered** — whether the question has any answers
- **Has accepted answer** — whether an answer has been accepted
- **Created date** and **last-activity date**
- **Asker** — the display name of the author
- **Asker reputation** — the author's Stack Exchange reputation
- **Query** — the search term that surfaced the row

### ⬇️ Input

| Field | Type | Description |
|-------|------|-------------|
| `searchTerms` | array | Keywords to search, e.g. `asyncio`, `pandas merge`. One or many. |
| `site` | string | Stack Exchange site to search. Default `stackoverflow` (e.g. `serverfault`, `superuser`, `datascience`). |
| `tagged` | string | Optional: restrict results to a tag, e.g. `python`. |
| `sort` | string | Result ordering: `relevance`, `votes`, `activity` or `creation`. Default `relevance`. |
| `maxPerTerm` | integer | Max questions to return per search term. Default `20`, up to `100`. |

#### Example input

```json
{
  "searchTerms": ["asyncio", "pandas merge"],
  "site": "stackoverflow",
  "tagged": "python",
  "sort": "votes",
  "maxPerTerm": 50
}
````

### ⬆️ Output

Each question is one clean row (view as a **table**, or export **JSON / CSV / Excel**):

```json
{
  "question_id": 123456,
  "title": "What is the difference between asyncio and threading?",
  "link": "https://stackoverflow.com/questions/123456/what-is-the-difference-between-asyncio-and-threading",
  "site": "stackoverflow",
  "tags": ["python", "asyncio", "multithreading", "concurrency"],
  "score": 412,
  "view_count": 285000,
  "answer_count": 7,
  "is_answered": true,
  "has_accepted_answer": true,
  "created_date": "2016-03-12",
  "last_activity_date": "2025-11-02",
  "asker": "jdoe",
  "asker_reputation": 18452,
  "query": "asyncio"
}
```

### 💡 Use cases

- 👩‍💻 **Developer & product research** — find the most-viewed, highest-voted questions about a library, framework or error to understand what users struggle with.
- 📈 **Tag & topic monitoring** — track activity around the tags that matter to your project, tool or open-source library over time.
- ✍️ **Content & SEO** — discover high-traffic, poorly-answered questions to target with blog posts, docs and tutorials.
- 📊 **Q\&A datasets & NLP** — build structured corpora of developer questions for analysis, benchmarking or LLM training.

### ❓ FAQ

**How do I scrape Stack Overflow questions?** Enter one or more `searchTerms`, optionally set `tagged` and `sort`, and Run. You get structured rows with title, link, tags, score, views, answers and asker.

**Do I need an API key or login?** No. It uses the public Stack Exchange API — just provide keywords.

**Can I search other Stack Exchange sites?** Yes — set `site` to any site slug, e.g. `serverfault`, `superuser`, `datascience`, `askubuntu` or `math`.

**Can I filter by tag?** Yes — set `tagged` (e.g. `python`) to restrict results to questions carrying that tag.

**How can I sort the results?** By `relevance`, `votes`, `activity` or `creation` date, so you can rank by popularity or find the newest questions.

**Does it return answer bodies?** No — it returns question metadata and engagement signals. Full answer text can bloat results, so it is omitted by design; the `link` takes you to the full thread.

**How many questions can it return?** Up to your `maxPerTerm` cap (max 100) for each search term.

**Can I run it on a schedule or via API?** Yes — schedule recurring runs on Apify, call it via the API/SDK, or connect it to Make, Zapier or n8n.

**How does pricing work?** Pay per question returned — no subscription, no fixed monthly fee.

**Is it legal?** It uses the public Stack Exchange API. User-contributed content on the network is licensed under Creative Commons (CC BY-SA) — attribute it accordingly and follow Stack Exchange's terms.

### 🔗 You might also like

- **[GitHub Repository Scraper](https://apify.com/benthepythondev/github-repository-scraper)** — repos, stars, topics & metadata.
- **[PyPI Scraper](https://apify.com/benthepythondev/pypi-scraper)** — Python package metadata & versions.
- **[Dev.to Articles Scraper](https://apify.com/benthepythondev/devto-articles-scraper)** — developer articles by tag.
- **[Hacker News Scraper](https://apify.com/benthepythondev/hacker-news-scraper)** — tech & startup discussions.

***

**Keywords:** stack overflow scraper, stack exchange api, developer questions, q\&a data, programming questions, tag monitoring, stackoverflow data, dev research, coding questions, question scraper, technical q\&a, stackexchange scraper, developer dataset, stackoverflow api, serverfault scraper, superuser scraper, q\&a dataset, stack overflow questions, developer content research, so scraper

# Actor input Schema

## `searchTerms` (type: `array`):

Keywords to search for, e.g. 'asyncio', 'pandas merge'.

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

Site to search, e.g. 'stackoverflow', 'serverfault', 'superuser'.

## `tagged` (type: `string`):

Optional: restrict to a tag, e.g. 'python'.

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

Result ordering.

## `maxPerTerm` (type: `integer`):

Max questions to return per search term.

## Actor input object example

```json
{
  "searchTerms": [
    "asyncio"
  ],
  "site": "stackoverflow",
  "sort": "relevance",
  "maxPerTerm": 20
}
```

# 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 = {
    "searchTerms": [
        "asyncio"
    ],
    "site": "stackoverflow",
    "sort": "relevance"
};

// Run the Actor and wait for it to finish
const run = await client.actor("benthepythondev/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 = {
    "searchTerms": ["asyncio"],
    "site": "stackoverflow",
    "sort": "relevance",
}

# Run the Actor and wait for it to finish
run = client.actor("benthepythondev/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 '{
  "searchTerms": [
    "asyncio"
  ],
  "site": "stackoverflow",
  "sort": "relevance"
}' |
apify call benthepythondev/stackoverflow-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Stack Overflow Scraper - Questions & Tags",
        "description": "Search Stack Overflow (or any Stack Exchange site) by keyword: question title, link, tags, score, views, answer count, accepted flag, asker and dates. Filter by tag, sort by relevance/votes/activity. Reliable via the public Stack Exchange API, no key.",
        "version": "1.0",
        "x-build-id": "8lEmOPA0PkpRIDfOI"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/benthepythondev~stackoverflow-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-benthepythondev-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/benthepythondev~stackoverflow-scraper/runs": {
            "post": {
                "operationId": "runs-sync-benthepythondev-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/benthepythondev~stackoverflow-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-benthepythondev-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": {
                    "searchTerms": {
                        "title": "Search terms",
                        "type": "array",
                        "description": "Keywords to search for, e.g. 'asyncio', 'pandas merge'.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "site": {
                        "title": "Stack Exchange site",
                        "type": "string",
                        "description": "Site to search, e.g. 'stackoverflow', 'serverfault', 'superuser'.",
                        "default": "stackoverflow"
                    },
                    "tagged": {
                        "title": "Tagged (filter)",
                        "type": "string",
                        "description": "Optional: restrict to a tag, e.g. 'python'."
                    },
                    "sort": {
                        "title": "Sort by",
                        "enum": [
                            "relevance",
                            "votes",
                            "activity",
                            "creation"
                        ],
                        "type": "string",
                        "description": "Result ordering.",
                        "default": "relevance"
                    },
                    "maxPerTerm": {
                        "title": "Max questions per term",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Max questions to return per search term.",
                        "default": 20
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
