# Stack Exchange Scraper: Questions, Answers & Tags (`glitchbound/stackexchange-scraper`) Actor

Search Stack Overflow and 24 other Stack Exchange sites: question title and full body, score, views, tags, author reputation, and optionally every answer with the accepted one flagged. Official API, no key needed.

- **URL**: https://apify.com/glitchbound/stackexchange-scraper.md
- **Developed by:** [Daniel Meshulam](https://apify.com/glitchbound) (community)
- **Categories:** Developer tools, Automation, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 rows

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 Exchange Scraper: Questions, Answers & Tags

Search Stack Overflow and 24 other Stack Exchange sites, and get the **full text**
back, not just titles.

```json
{ "site": "stackoverflow", "tags": ["python", "asyncio"], "sortBy": "votes" }
```

No API key required.

### The filter that most Actors forget

Stack Exchange's API omits question and answer **bodies** unless you explicitly
pass `filter=withbody`. An Actor that does not pass it returns rows with a title,
a score, and no content, which looks exactly like a site that had nothing to
say, and is useless for anything downstream.

Every request here sends it. You get the body.

### What you can ask for

| | |
|---|---|
| `searchQueries` | free text, searched across titles and bodies |
| `tags` | all-of tag filter; use it **alone** to pull the top questions in a tag |
| `sortBy` | score, recent activity, newest, relevance |
| `minScore` | only questions above a score |
| `acceptedOnly` | only questions where an answer was accepted |
| `includeAnswers` | every answer to every question found, accepted one flagged |

25 sites are offered as a dropdown, Stack Overflow, Server Fault, Super User,
Ask Ubuntu, Security, DBA, Unix & Linux, Data Science, Cross Validated, Physics,
Math, WordPress, Magento, Salesforce, SharePoint, Law, Money, and more, so
there is no site slug to get wrong.

### Output

Rows carry `recordType`, so questions and answers stay separable:

- `question`, title, full body, tags, score, views, answer count, accepted answer id, author + reputation, asked and last-activity dates, close reason
- `answer`, full body, score, `isAccepted`, author + reputation, dates, and the `questionId` it belongs to

### The daily quota, stated plainly

Unauthenticated Stack Exchange allows **300 requests per day per IP**. Every
response reports what is left, and that number is read: when it hits zero you get
one `error` row saying the quota is spent, instead of an opaque failure.

Proxy rotation buys a fresh 300 per address, and answers are fetched **100
question ids per request** rather than one at a time, the difference between
one request and a hundred against the same budget.

### Use cases

- **Developer research**: what people actually struggle with in your library, ranked by views
- **Support content**: mine accepted answers for docs and FAQ material
- **Product feedback**: search your product name, sort by newest, watch what breaks
- **Training and RAG corpora**: question/answer pairs with scores as a quality signal
- **Competitive intelligence**: tag volume and sentiment around a competitor's tool

### Pricing

Charged per row returned. A query Stack Exchange rejects, or an exhausted daily
quota, produces an `error` row and costs **$0.00**.

### Which sites, and what a Stack Overflow scrape returns

This reads the **official Stack Exchange API 2.3**, not rendered HTML, so the
field names do not move when someone redesigns the site.

`site` picks the network member. All 25 supported:

| | |
|---|---|
| Programming | `stackoverflow` `softwareengineering` `datascience` `gis` |
| Sysadmin and ops | `serverfault` `superuser` `askubuntu` `unix` `dba` `security` |
| Vendor stacks | `sharepoint` `salesforce` `magento` `wordpress` `drupal` `apple` |
| Science and maths | `math` `stats` `physics` `electronics` |
| Everything else | `ell` `english` `money` `law` `cooking` |

**Per question**: title, body as plain text, score, view count, answer count,
tags, author, creation and activity dates, whether an answer was accepted, and
the canonical URL. Turn on `includeAnswers` and each accepted or top-voted
answer arrives as its own row tied to the question.

**Filters that run before you are charged**: `tags`, `minScore`,
`acceptedOnly`, and a `sortBy` of votes, activity, creation or relevance. A
question dropped by a filter is not billed, so a narrow query costs less rather
than the same.

**No API key is needed.** Stack Exchange allows a modest anonymous quota, which
is what this uses, and it paces requests to stay inside it.

### Do you need an API key? No. Is there a free tier? Yes.

The two things people search for in this category, measured, are **free** and
**API key**: `stack overflow api key`.

So, plainly:

- **No API key.** Nothing to register for, nothing to rotate, no key to leak in
  a repo. The source is a public API published deliberately by its owner.
- **No proxy setup.** The source does not bot-wall datacenter addresses, so the
  default works.
- **Pay per result, not per month.** There is no subscription and no minimum.
  Rows that error or that your filters drop are **not charged**.
- **Free to try.** Run it with the prefilled input and see real rows before
  deciding anything.

### Notes

- All content is CC BY-SA licensed by Stack Exchange. Attribution is your responsibility when republishing; the `url` field on every row is there for exactly that.
- Bodies are converted from HTML to plain text and capped at 4,000 characters.
- `minScore` forces sorting by score, because the API's minimum filter applies to whatever field the sort uses, asking for "score ≥ 50, newest first" is not a thing the API can express, and silently returning the wrong rows would be worse than saying so.

### FAQ

#### Do I need a Stack Exchange API key?

No. It works unauthenticated at 300 requests per day per IP. Every response
reports the remaining quota, and when it reaches zero you get one `error` row
saying the quota is spent rather than an opaque failure. Proxy rotation buys a
fresh 300 per address.

#### Does it return the full question and answer text?

Yes. Stack Exchange's API omits bodies unless the request passes
`filter=withbody`, and an Actor that forgets it returns titles and scores with no
content, which looks exactly like a site that had nothing to say. Every request
here sends it. Bodies are converted from HTML to plain text and capped at 4,000
characters.

#### Can I search sites other than Stack Overflow?

Yes, 25 of them, as a dropdown so there is no site slug to get wrong: Server
Fault, Super User, Ask Ubuntu, Security, DBA, Unix & Linux, Data Science, Cross
Validated, Physics, Math, WordPress, Magento, Salesforce, SharePoint, Law, Money
and more.

#### How do I get the top questions for a tag?

Use `tags` on its own, with no `searchQueries`, and set `sortBy` to `votes`. The
tag filter is all-of, so `["python", "asyncio"]` means both tags, not either.

#### Can I get only questions that have an accepted answer?

Set `acceptedOnly: true`, and `includeAnswers: true` to pull the answers
themselves. The accepted one is flagged with `isAccepted`.

#### Why does `minScore` change my sort order?

Because the API's minimum filter applies to whatever field the sort uses, so
"score ≥ 50, newest first" is not a query it can express. Setting `minScore`
forces sorting by score. Silently returning the wrong rows would be worse than
saying so.

#### Can I use this content in a product or a training set?

All Stack Exchange content is CC BY-SA. Attribution is your responsibility when
republishing, and the `url` field on every row exists for exactly that. Scores
make a reasonable quality signal for filtering a corpus.

# Actor input Schema

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

Which Stack Exchange site to search.

## `searchQueries` (type: `array`):

Free-text searches, one per line. Searches titles and bodies.

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

Restrict to questions carrying all of these tags, e.g. python, asyncio. Use tags on their own, with no query, to pull the top questions in a tag.

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

Ordering of the results.

## `maxResultsPerQuery` (type: `integer`):

Cap per query.

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

Only questions scoring at least this. Applying it forces sorting by score, since the API's minimum filter applies to whatever the sort field is.

## `acceptedOnly` (type: `boolean`):

Keep only questions where someone marked an answer as accepted.

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

Also return the answers to every question found, highest score first. Answers are fetched 100 questions at a time to stay inside the daily quota.

## `proxyConfiguration` (type: `object`):

Proxy settings. Rotation matters here: the unauthenticated quota is 300 requests per day per IP.

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

A hard ceiling on rows for the entire run, across every target. The per-target limits above cap each one separately, so fifty targets at twenty each is still a thousand rows; this caps the total. The run stops cleanly when it is reached and nothing beyond that point is fetched or charged. Leave empty for no ceiling.

## Actor input object example

```json
{
  "site": "stackoverflow",
  "searchQueries": [
    "memory leak"
  ],
  "sortBy": "votes",
  "maxResultsPerQuery": 100,
  "minScore": 0,
  "acceptedOnly": false,
  "includeAnswers": false,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Full body text, score, views, tags, author reputation and accepted-answer flag.

# 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 = {
    "searchQueries": [
        "memory leak"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("glitchbound/stackexchange-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 = { "searchQueries": ["memory leak"] }

# Run the Actor and wait for it to finish
run = client.actor("glitchbound/stackexchange-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 '{
  "searchQueries": [
    "memory leak"
  ]
}' |
apify call glitchbound/stackexchange-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/18N65r1a0UQhTgdPf/builds/axeLmTKW8dtZ7DvAd/openapi.json
