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

Search Stack Overflow (or any Stack Exchange site) by keyword or tag and get one row per question: title, body, tags, score, views, answer count, accepted answer and author, with top answers optionally attached. For dev tool marketing, research and support teams. No API key needed.

- **URL**: https://apify.com/scrapemint/stackoverflow-scraper.md
- **Developed by:** [Ken M](https://apify.com/scrapemint) (community)
- **Categories:** Developer tools, Business
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 question rows

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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Stack Overflow Scraper: Questions, Answers & Tags

Search Stack Overflow by **keyword** or sweep a **tag**, and get one clean row per question: title, body text, tags, score, view count, answer count, accepted answer, author and reputation — with the **top answers optionally attached**. Works on any Stack Exchange site (Super User, Server Fault, Ask Ubuntu and 170+ more) with one input switch.

Built for **developer tool marketing (find the questions your product answers), AI and research datasets, support teams and technical content writers**. No login, no browser, and no API key needed to start.

### What you get for each question

- **title**, **bodyText** (clean text, no HTML) and **url**
- **tags**, **score**, **views**, **answerCount**, **isAnswered**, **acceptedAnswerId**
- **author**, **authorReputation** and profile link
- **createdAt** and **lastActivityAt**: freshness at a glance
- **topAnswers** (optional): up to 5 best answers with score, accepted flag, text and author

### Example output

```json
{
  "input": "playwright timeout",
  "mode": "search",
  "questionId": 70714523,
  "title": "Playwright: Timeout 30000ms exceeded waiting for selector",
  "tags": ["playwright", "node.js"],
  "score": 42,
  "views": 118234,
  "answerCount": 6,
  "isAnswered": true,
  "author": "jsmith",
  "createdAt": "2022-01-14T09:31:00.000Z",
  "url": "https://stackoverflow.com/questions/70714523/..."
}
```

### Searches or tags?

- **Searches**: free text, ranked by relevance ("memory leak nodejs", "pandas merge slow").
- **Tags**: a tag's top questions by votes ("web-scraping", "playwright"). Great for mapping a topic.
- **newerThanDays** filters to recent questions only, for trend and demand research.
- **site** switches to any Stack Exchange community: `superuser`, `serverfault`, `askubuntu`, `softwareengineering`...

### Pricing

**$0.003 per question row**, answers included at no extra charge. Searches and tags that match nothing are **free**, and the first 2 rows of every run are free. Mapping 1,000 questions in your product's niche costs $3.

### About the shared API quota

The public Stack Exchange API allows 300 requests/day per IP without a key, and one request fetches up to 100 questions, so normal runs use a handful of requests. On busy shared infrastructure the quota can run out; the actor then stops cleanly, keeps everything fetched so far, and never charges for what it could not get. Adding your own free key from [stackapps.com](https://stackapps.com) in the `apiKey` field raises the quota to 10,000/day — your key stays secret and is only sent to Stack Exchange.

### How to run it via API

```bash
curl -X POST "https://api.apify.com/v2/acts/scrapemint~stackoverflow-scraper/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"queries": ["playwright timeout"], "tags": ["web-scraping"], "maxPerQuery": 25, "includeAnswers": true}'
```

### Frequently asked questions

**Where does the data come from?** The official public Stack Exchange API. Content is user contributed under CC BY-SA; rows link back to the source question as attribution.

**Can I get full answer bodies?** Yes — set `includeAnswers` and each question row carries its top 5 answers by votes with clean text bodies.

**Does it cover comments or user profiles?** Not in this version. Question and answer data covers the main use cases; tell us if you need more.

**Why did my huge run stop early?** The shared keyless quota ran out. The run saves everything fetched and the log says exactly what happened; add your own free API key to raise the limit to 10,000/day.

### More tools from Scrapemint

- [GitHub Repo Stats](https://apify.com/scrapemint/github-repo-stats): stars, forks and metadata for repos in bulk.
- [Google Trends Scraper](https://apify.com/scrapemint/google-trends-scraper): search interest over time for any topic.
- [Website Content Scraper](https://apify.com/scrapemint/website-content-scraper): clean text from any page.

# Actor input Schema

## `queries` (type: `array`):

Free text searches, one per line ("memory leak nodejs", "pandas merge slow"). Each returns the most relevant questions.

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

Tags to sweep, one per line ("playwright", "apify"). Each returns that tag's top questions by votes.

## `maxPerQuery` (type: `integer`):

How many questions to return for each search or tag (max 100).

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

Attach the top answers (by votes, up to 5) to each question row. Costs one extra API call per 100 questions.

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

Which Stack Exchange site to search. Default stackoverflow; also works with superuser, serverfault, askubuntu, softwareengineering and any other site slug.

## `newerThanDays` (type: `integer`):

Skip questions created more than this many days ago. 0 = no age limit.

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

Optional: your own Stack Exchange app key. Raises the shared daily quota (300 requests/day per IP) to 10,000/day. Get one free at stackapps.com.

## `maxRows` (type: `integer`):

Stop after this many rows in total.

## Actor input object example

```json
{
  "queries": [
    "web scraping blocked",
    "playwright timeout"
  ],
  "tags": [
    "web-scraping"
  ],
  "maxPerQuery": 15,
  "includeAnswers": false,
  "site": "stackoverflow",
  "newerThanDays": 0,
  "maxRows": 1000
}
```

# 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 = {
    "queries": [
        "web scraping blocked",
        "playwright timeout"
    ],
    "tags": [
        "web-scraping"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapemint/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 = {
    "queries": [
        "web scraping blocked",
        "playwright timeout",
    ],
    "tags": ["web-scraping"],
}

# Run the Actor and wait for it to finish
run = client.actor("scrapemint/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 '{
  "queries": [
    "web scraping blocked",
    "playwright timeout"
  ],
  "tags": [
    "web-scraping"
  ]
}' |
apify call scrapemint/stackoverflow-scraper --silent --output-dataset

```

## MCP server setup

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