# 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.20 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 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

Download the OpenAPI definition: https://api.apify.com/v2/actors/InnhqfWXKKygZigT3/builds/8lEmOPA0PkpRIDfOI/openapi.json
