# Stack Exchange & Stack Overflow Scraper (`powernaner/stack-exchange-scraper`) Actor

Scrape Stack Overflow and 180+ Stack Exchange sites via the official API: full Q\&A threads with answers and comments, edit history, bounties, tags, top answerers and user profiles. No login, no proxy.

- **URL**: https://apify.com/powernaner/stack-exchange-scraper.md
- **Developed by:** [Renan Teles](https://apify.com/powernaner) (community)
- **Categories:** Developer tools, Automation, Education
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 question with full threads

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 Exchange & Stack Overflow Scraper

Scrape Stack Overflow and 180+ Stack Exchange sites (Super User, Server Fault, Ask Ubuntu, Mathematics, Unix & Linux…) into clean JSON, CSV or Excel: **full Q\&A threads in one row**, tags, user profiles, open bounties and network statistics. It uses the official Stack Exchange API. No login, no proxy, no browser.

### What you get

- **The whole thread in one row.** Every question comes with all its answers (body, votes, accepted flag, author) and, optionally, every comment on the question and on each answer. No joining tables.
- **7 modes**: keyword/tag search · browse questions (newest, hot, top of the week/month, most voted) · threads by URL or id · open bounties · tags · user profiles · all network sites with live stats.
- **Attribution built in.** Every question, answer and comment carries its author, link and Creative Commons license (`contentLicense`, e.g. `CC BY-SA 4.0`), so you can reuse the content correctly.
- **Data the others don't give you:** edit history of each question, open bounty amount and deadline, "closed as duplicate of" links, tag wikis, tag synonyms, related tags, top answerers and askers per tag, a user's top tags and their accounts on other Stack Exchange sites.
- **Any site of the network.** Use the short name (`superuser`, `math`, `unix`) or paste a URL. One run can cover several sites.
- **Clean data.** Dates in ISO 8601 UTC. Text without HTML entities (`"` instead of `&quot;`). Body as Markdown (as the author typed it), HTML, both or none. `null` (never a fake `0`) when the API does not say.

### Example output (real, from a cloud run on 2026-11-17)

A question from the default input (Search mode, query `asyncio`), with its 3 answers. This row is complete, nothing removed:

````json
{
  "recordType": "question",
  "site": "stackoverflow",
  "questionId": 45600579,
  "title": "\"Asyncio Event Loop is Closed\" when getting loop",
  "link": "https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop",
  "tags": [
    "python",
    "python-asyncio",
    "python-3.5"
  ],
  "score": 137,
  "upVoteCount": 138,
  "downVoteCount": 1,
  "viewCount": 199374,
  "answerCount": 3,
  "commentCount": 1,
  "favoriteCount": 0,
  "isAnswered": true,
  "acceptedAnswerId": 45600858,
  "body": null,
  "bodyMarkdown": "When trying to run the asyncio hello world code example given in the docs:\r\n\r\n    import asyncio\r\n\r\n    async def hello_world():\r\n        print(\"Hello World!\")\r\n\r\n    loop = asyncio.get_event_loop()\r\n    # Blocking call which returns when the hello_world() coroutine is done\r\n    loop.run_until_complete(hello_world())\r\n    loop.close()\r\nI get the error: \r\n\r\n    RuntimeError: Event loop is closed\r\n\r\nI am using python 3.5.3.",
  "owner": {
    "userId": 6520128,
    "accountId": 8650873,
    "displayName": "TryingToTry",
    "reputation": 1293,
    "userType": "registered",
    "acceptRate": null,
    "profileUrl": "https://stackoverflow.com/users/6520128/tryingtotry"
  },
  "ownerProfile": null,
  "contentLicense": "CC BY-SA 4.0",
  "createdAt": "2017-08-09T21:01:46.000Z",
  "lastActivityAt": "2022-01-18T18:09:23.000Z",
  "lastEditedAt": "2021-03-22T17:52:28.000Z",
  "bountyAmount": null,
  "bountyClosesAt": null,
  "closedAt": null,
  "closedReason": null,
  "duplicateOfIds": [],
  "protectedAt": null,
  "lockedAt": null,
  "communityOwnedAt": null,
  "answers": [
    {
      "answerId": 45600858,
      "isAccepted": true,
      "score": 120,
      "upVoteCount": 121,
      "downVoteCount": 1,
      "createdAt": "2017-08-09T21:24:42.000Z",
      "lastActivityAt": "2020-10-15T09:25:31.000Z",
      "lastEditedAt": "2020-10-15T09:25:31.000Z",
      "body": null,
      "bodyMarkdown": "You have already called `loop.close()` before you ran that sample piece of code, on the global event loop:\r\n\r\n    >>> import asyncio\r\n    >>> asyncio.get_event_loop().close()\r\n    >>> asyncio.get_event_loop().is_closed()\r\n    True\r\n    >>> asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))\r\n    Traceback (most recent call last):\r\n      File \"<stdin>\", line 1, in <module>\r\n      File \"/.../lib/python3.6/asyncio/base_events.py\", line 443, in run_until_complete\r\n        self._check_closed()\r\n      File \"/.../lib/python3.6/asyncio/base_events.py\", line 357, in _check_closed\r\n        raise RuntimeError('Event loop is closed')\r\n    RuntimeError: Event loop is closed\r\n  \r\n\r\nYou need to create a *new* loop:\r\n\r\n    loop = asyncio.new_event_loop()\r\n\r\nYou can set that as the new global loop with:\r\n\r\n    asyncio.set_event_loop(asyncio.new_event_loop())\r\n\r\nand then just use `asyncio.get_event_loop()` again.\r\n\r\nAlternatively, just restart your Python interpreter, the first time you try to get the global event loop you get a fresh new one, unclosed.\r\n\r\nAs of Python 3.7, the process of creating, managing, then closing the loop (as well as a few other resources) is handled for you when use [`asyncio.run()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.run). It should be used instead of `loop.run_until_complete()`, and there is no need any more to first get or set the loop.",
      "owner": {
        "userId": 100297,
        "accountId": 35417,
        "displayName": "Martijn Pieters",
        "reputation": 1144177,
        "userType": "registered",
        "acceptRate": null,
        "profileUrl": "https://stackoverflow.com/users/100297/martijn-pieters"
      },
      "contentLicense": "CC BY-SA 4.0",
      "commentCount": 3,
      "comments": null
    },
    {
      "answerId": 66772242,
      "isAccepted": false,
      "score": 204,
      "upVoteCount": 204,
      "downVoteCount": 0,
      "createdAt": "2021-03-23T22:32:49.000Z",
      "lastActivityAt": "2021-03-23T22:32:49.000Z",
      "lastEditedAt": null,
      "body": null,
      "bodyMarkdown": "On Windows seems to be a problem with EventLoopPolicy, use this snippet to work around it:\r\n\r\n```python\r\nasyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\nasyncio.run(main())\r\n```\r\n\r\n",
      "owner": {
        "userId": 6387880,
        "accountId": 8520925,
        "displayName": "j4hangir",
        "reputation": 3257,
        "userType": "registered",
        "acceptRate": null,
        "profileUrl": "https://stackoverflow.com/users/6387880/j4hangir"
      },
      "contentLicense": "CC BY-SA 4.0",
      "commentCount": 6,
      "comments": null
    },
    {
      "answerId": 70758881,
      "isAccepted": false,
      "score": 41,
      "upVoteCount": 41,
      "downVoteCount": 0,
      "createdAt": "2022-01-18T16:17:08.000Z",
      "lastActivityAt": "2022-01-18T18:09:23.000Z",
      "lastEditedAt": "2022-01-18T18:09:23.000Z",
      "body": null,
      "bodyMarkdown": "...and just in case:\r\n\r\n```\r\nimport platform\r\nif platform.system()=='Windows':\r\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\n```\r\n\r\nIf you ever deploy your code in the cloud it might avoid painful debug.",
      "owner": {
        "userId": 17966338,
        "accountId": 23978561,
        "displayName": "daviidarr",
        "reputation": 411,
        "userType": "registered",
        "acceptRate": null,
        "profileUrl": "https://stackoverflow.com/users/17966338/daviidarr"
      },
      "contentLicense": "CC BY-SA 4.0",
      "commentCount": 1,
      "comments": null
    }
  ],
  "answersTruncated": false,
  "comments": null,
  "revisions": null,
  "source": "search:stackoverflow",
  "scrapedAt": "2026-11-17T18:34:33.213Z"
}
````

A tag (Tags mode). Only `wikiBody` is shortened here, because it is 11,505 characters long:

```json
{
  "recordType": "tag",
  "site": "stackoverflow",
  "name": "rust",
  "link": "https://stackoverflow.com/questions/tagged/rust",
  "questionCount": 43978,
  "hasSynonyms": false,
  "isModeratorOnly": false,
  "isRequired": false,
  "wikiExcerpt": "Rust is a systems programming language without a garbage collector focused on three goals: safety, speed, and concurrency. Use this tag for questions about code written in Rust. Use an edition specific tag for questions that refer to code which requires a particular edition, like [rust-2018]. Use more specific tags for subtopics like [rust-cargo] and [rust-macros].",
  "wikiBody": "<p><a href=\"https://www.rust-lang.org/\" rel=\"nofollow noreferrer\">Rust</a> is a systems programming language focused on three goals: safety, speed, and concurre… [11,505 characters in the real row, shortened here]",
  "wikiLastEditedAt": "2025-02-23T17:07:05.000Z",
  "synonyms": [],
  "relatedTags": [
    {
      "name": "rust-cargo",
      "questionCount": 2384
    },
    {
      "name": "borrow-checker",
      "questionCount": 1894
    },
    {
      "name": "lifetime",
      "questionCount": 1870
    },
    {
      "name": "traits",
      "questionCount": 1838
    },
    {
      "name": "rust-tokio",
      "questionCount": 1278
    },
    {
      "name": "generics",
      "questionCount": 1181
    },
    {
      "name": "serde",
      "questionCount": 975
    },
    {
      "name": "iterator",
      "questionCount": 931
    },
    {
      "name": "multithreading",
      "questionCount": 778
    },
    {
      "name": "string",
      "questionCount": 627
    }
  ],
  "topAnswerers": [
    {
      "userId": 155423,
      "displayName": "Shepmaster",
      "reputation": 442464,
      "profileUrl": "https://stackoverflow.com/users/155423/shepmaster",
      "postCount": 3074,
      "score": 39620
    },
    {
      "userId": 788207,
      "displayName": "Vladimir Matveev",
      "reputation": 129985,
      "profileUrl": "https://stackoverflow.com/users/788207/vladimir-matveev",
      "postCount": 447,
      "score": 8804
    },
    {
      "userId": 147192,
      "displayName": "Matthieu M.",
      "reputation": 304948,
      "profileUrl": "https://stackoverflow.com/users/147192/matthieu-m",
      "postCount": 695,
      "score": 7927
    },
    {
      "userId": 2408867,
      "displayName": "Lukas Kalbertodt",
      "reputation": 91622,
      "profileUrl": "https://stackoverflow.com/users/2408867/lukas-kalbertodt",
      "postCount": 416,
      "score": 7529
    },
    {
      "userId": 1256624,
      "displayName": "huon",
      "reputation": 104138,
      "profileUrl": "https://stackoverflow.com/users/1256624/huon",
      "postCount": 271,
      "score": 7215
    },
    {
      "userId": 234590,
      "displayName": "Francis Gagné",
      "reputation": 67306,
      "profileUrl": "https://stackoverflow.com/users/234590/francis-gagn%c3%a9",
      "postCount": 635,
      "score": 5947
    },
    {
      "userId": 7884305,
      "displayName": "Chayim Friedman",
      "reputation": 77578,
      "profileUrl": "https://stackoverflow.com/users/7884305/chayim-friedman",
      "postCount": 1916,
      "score": 5598
    },
    {
      "userId": 42353,
      "displayName": "DK.",
      "reputation": 60197,
      "profileUrl": "https://stackoverflow.com/users/42353/dk",
      "postCount": 444,
      "score": 5230
    },
    {
      "userId": 497043,
      "displayName": "Chris Morgan",
      "reputation": 91990,
      "profileUrl": "https://stackoverflow.com/users/497043/chris-morgan",
      "postCount": 339,
      "score": 4556
    },
    {
      "userId": 2189130,
      "displayName": "kmdreko",
      "reputation": 66526,
      "profileUrl": "https://stackoverflow.com/users/2189130/kmdreko",
      "postCount": 1264,
      "score": 4513
    }
  ],
  "topAskers": [
    {
      "userId": 155423,
      "displayName": "Shepmaster",
      "reputation": 442464,
      "profileUrl": "https://stackoverflow.com/users/155423/shepmaster",
      "postCount": 75,
      "score": 2149
    },
    {
      "userId": 432509,
      "displayName": "ideasman42",
      "reputation": 49976,
      "profileUrl": "https://stackoverflow.com/users/432509/ideasman42",
      "postCount": 159,
      "score": 1894
    },
    {
      "userId": 2408867,
      "displayName": "Lukas Kalbertodt",
      "reputation": 91622,
      "profileUrl": "https://stackoverflow.com/users/2408867/lukas-kalbertodt",
      "postCount": 90,
      "score": 1446
    },
    {
      "userId": 2813589,
      "displayName": "Incerteza",
      "reputation": 35684,
      "profileUrl": "https://stackoverflow.com/users/2813589/incerteza",
      "postCount": 47,
      "score": 1438
    },
    {
      "userId": 220485,
      "displayName": "Daniel Fath",
      "reputation": 18433,
      "profileUrl": "https://stackoverflow.com/users/220485/daniel-fath",
      "postCount": 36,
      "score": 1334
    },
    {
      "userId": 139802,
      "displayName": "Andrew Wagner",
      "reputation": 25123,
      "profileUrl": "https://stackoverflow.com/users/139802/andrew-wagner",
      "postCount": 24,
      "score": 1217
    },
    {
      "userId": 2558778,
      "displayName": "Jeroen",
      "reputation": 17304,
      "profileUrl": "https://stackoverflow.com/users/2558778/jeroen",
      "postCount": 16,
      "score": 1079
    },
    {
      "userId": 4140572,
      "displayName": "Angel Angel",
      "reputation": 22422,
      "profileUrl": "https://stackoverflow.com/users/4140572/angel-angel",
      "postCount": 34,
      "score": 1042
    },
    {
      "userId": 288703,
      "displayName": "Christoph",
      "reputation": 28643,
      "profileUrl": "https://stackoverflow.com/users/288703/christoph",
      "postCount": 42,
      "score": 978
    },
    {
      "userId": 4498831,
      "displayName": "Boiethios",
      "reputation": 43992,
      "profileUrl": "https://stackoverflow.com/users/4498831/boiethios",
      "postCount": 53,
      "score": 934
    }
  ],
  "topUsersPeriod": "all_time",
  "source": "tags:stackoverflow",
  "scrapedAt": "2026-11-17T18:36:09.846Z"
}
```

### Fields

One dataset, one row per result. The `recordType` column says what each row is. Fields that don't apply to a row type are absent from that row; the dataset views (Questions, Tags, Users, Sites) pick the right columns.

#### Question rows (`recordType: "question"`)

| Field | What it is |
|---|---|
| `title`, `link`, `tags` | Question title (entities decoded), URL, tags |
| `bodyMarkdown` / `body` | Question body as Markdown and/or HTML (see `bodyFormat`) |
| `score`, `upVoteCount`, `downVoteCount`, `viewCount` | Votes and views |
| `answerCount`, `isAnswered`, `acceptedAnswerId` | Answer status |
| `answers[]` | Every answer: `answerId`, `isAccepted`, `score`, votes, dates, body, `owner`, `contentLicense`, `commentCount`, `comments[]` |
| `comments[]` | Comments on the question (with `includeComments`) |
| `owner` | Asker: `userId`, `accountId`, `displayName`, `reputation`, `userType`, `acceptRate`, `profileUrl` |
| `ownerProfile` | Asker's badges, location, website, dates, answer/question counts (with `includeOwnerProfiles`) |
| `contentLicense` | `CC BY-SA 2.5`, `3.0` or `4.0`. `null` for closed questions (the API does not return it) |
| `createdAt`, `lastActivityAt`, `lastEditedAt` | Dates (ISO 8601 UTC) |
| `bountyAmount`, `bountyClosesAt` | Open bounty in reputation points, and when it expires |
| `closedAt`, `closedReason`, `duplicateOfIds` | Closing info; original question ids when closed as duplicate |
| `protectedAt`, `lockedAt`, `communityOwnedAt` | Moderation dates |
| `revisions[]` | Edit history: who, when, comment, title and tag changes (with `includeRevisions`) |
| `answersTruncated` | `true` if the API returned fewer answers than `answerCount` |
| `site`, `questionId`, `commentCount`, `favoriteCount`, `source`, `scrapedAt` | Context |

#### Tag rows (`recordType: "tag"`)

`name`, `link`, `questionCount`, `wikiExcerpt`, `wikiBody` (HTML), `wikiLastEditedAt`, `synonyms[]`, `relatedTags[]` (top 10 with counts), `topAnswerers[]` and `topAskers[]` (top 10: user, posts, score; all time or last month), `hasSynonyms`, `isModeratorOnly`, `isRequired`.

#### User rows (`recordType: "user"`)

`displayName`, `profileUrl`, `reputation`, `badgeGold`/`badgeSilver`/`badgeBronze`, `location`, `websiteUrl`, `aboutMe` (HTML), `answerCount`, `questionCount`, `upVoteCount`, `downVoteCount`, `reputationChangeYear`/`Quarter`/`Month`/`Week`, `createdAt`, `lastAccessAt`, `topTags[]` (top 10 with answer/question counts and scores), `associatedAccounts[]` (the same person on other Stack Exchange sites), `userType`, `isEmployee`, `acceptRate`, `userId`, `accountId`.

#### Site rows (`recordType: "site"`)

`name`, `siteUrl`, `audience`, `siteType`, `siteState`, `launchedAt`, `openBetaAt`, `totalQuestions`, `totalAnswers`, `totalAccepted`, `totalUnanswered`, `totalComments`, `totalVotes`, `totalBadges`, `totalUsers`, `questionsPerMinute`, `answersPerMinute`, `badgesPerMinute`, `newActiveUsers`.

A run summary (`RUN_SUMMARY` in the key-value store) lists what each source delivered, what was skipped and why, and how much API quota is left.

### Use cases

- **Developer research and documentation:** collect the best Q\&A on a library, error message or API, with accepted answers and votes, to write docs, FAQs or tutorials.
- **Product and DevRel monitoring:** follow questions about your product, SDK or competitors (by keyword or tag), see what is unanswered and what gets votes.
- **Technology trends:** compare tags, related tags and question volume across sites and periods.
- **Finding experts:** top answerers per tag, with reputation and their top tags across the network.
- **Bounty hunting:** list open bounties across the network with amount and deadline.
- **Datasets for analysis:** export threads with full text, scores and dates to CSV or JSON for your own analysis. Mind the CC BY-SA license (see FAQ).

### Pricing

Pay per result. You only pay for rows delivered to your dataset. Failed sources, missing ids, empty items and duplicates are never charged, and there is no start fee.

| Result | Price per result | Per 1,000 |
|---|---|---|
| Question **with all its answers and comments inside** | $0.001 | **$1.00** |
| Tag (wiki, synonyms, related tags, top users) | $0.002 | **$2.00** |
| User profile (top tags, accounts on other sites) | $0.002 | **$2.00** |
| Site with live statistics | $0.001 | **$1.00** |

**Examples:**

- 1,000 Stack Overflow questions about `python`, each with its full thread: **$1.00**, no matter how many answers and comments they have.
- One thread with 30 answers and 100 comments: **$0.001**.
- Wiki and top users for 20 tags: 20 × $0.002 = **$0.04**.

Measured platform cost on 2026-11-17 (512 MB): 100 questions with all answers and comments took 45 s; 10 questions took 3 s.

### Limitations (honest)

- **API limits without your own key.** The Stack Exchange API allows 300 requests per day per IP and stops at page 25 (2,500 results per query). Two requests bring up to 100 questions with all their answers, so most runs need only a handful of requests. For large jobs, register a free app key at stackapps.com and paste it in the `apiKey` field (10,000 requests per day, no page cap).
- **No emails or private data.** Only what the public API exposes. No deleted content.
- **Licenses:** closed questions come with `contentLicense: null`, because the API does not return it for them (their answers do). An open question asked again within a few minutes of a previous request can also come back without it; the run summary says how many and why.
- **Bounties are rare** on Stack Overflow right now (zero on both checks on 2026-11-17). Other sites had some. Add several sites in Bounties mode.
- **The `site` column shows what you typed**: `stackoverflow` for a short name, `stackoverflow.com` when the site came from a pasted URL.
- **Sites mode is slow:** about 3–4 seconds per site in our tests, so the whole network (~180 sites) takes several minutes.
- **No analysis layer:** this Actor returns the raw data only (no sentiment, no scoring).
- Not affiliated with or endorsed by Stack Exchange, Inc.

### FAQ

**Do I need a Stack Exchange account or API key?** No. The key is optional and only raises the API limits.

**Can I reuse the content?** User contributions on Stack Exchange are licensed under Creative Commons BY-SA (the version is in `contentLicense`). Reuse requires attribution (author and link, both included in every row) and share-alike. Check the license and Stack Exchange's terms for your use case.

**Which sites are supported?** All public Stack Exchange sites. Run the Sites mode to get the full list with the short name to use in `sites`.

**How do I get every answer of a thread?** Use Threads mode with the question URL. Answers are included by default; turn on `includeComments` for comments.

**Why did I get fewer results than `maxItems`?** The query had fewer matches (for example "hot this week" for a small tag). The run summary says when the 25-page limit or the API quota stopped a run.

**Is the API key safe?** The `apiKey` field is a secret input field, and the Actor never writes it to the log. It is a public app key (it identifies an app, it is not a password).

# Actor input Schema

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

Search = keyword/tag search. Browse questions = latest/top questions, optionally by tag. Threads = specific questions by URL or id. Bounties = questions with an open bounty (reputation reward). Tags = tag details (wiki, synonyms, related tags, top answerers and askers). Users = profiles (top users by reputation, or by URL/id). Sites = every site in the Stack Exchange network with live statistics.

## `sites` (type: `array`):

One or more Stack Exchange sites. Use the short name (stackoverflow, superuser, serverfault, askubuntu, math, unix...) or the domain (math.stackexchange.com). Each site is scraped separately and gets up to 'Max results' rows. Ignored in the 'Sites' mode. In 'Threads' and 'Users' modes, a pasted URL already says the site.

## `query` (type: `string`):

Free-text search in title and body (Search mode only). Example: asyncio, kubernetes ingress, "null pointer".

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

Stack Exchange tags, e.g. python, reactjs, c#. In Search mode a question needs AT LEAST ONE of the tags; in Browse and Bounties modes it needs ALL of them. In Tags mode, these are the tags to detail (empty = most popular tags).

## `fromDate` (type: `string`):

Only questions created on or after this day (YYYY-MM-DD, UTC). Search, Browse and Bounties modes.

## `toDate` (type: `string`):

Only questions created on or before this day, inclusive (YYYY-MM-DD, UTC). Search, Browse and Bounties modes.

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

Search: relevance, activity, creation, votes. Browse: activity, creation, votes, hot, week, month. Bounties: activity, creation, votes. If the option doesn't exist in the chosen mode, the mode's default is used and the run summary says so.

## `questionIds` (type: `array`):

Threads mode: paste question URLs (https://stackoverflow.com/questions/231767/...) or ids. Bare ids are looked up on the first site in 'Sites'.

## `userIds` (type: `array`):

Users mode: profile URLs (https://stackoverflow.com/users/22656/jon-skeet) or ids. Empty = top users of each site by reputation.

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

Maximum rows per site (per source). Without your own API key, the Stack Exchange API stops at page 25 (2,500 rows) and allows 300 requests per day per IP.

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

Put every answer (body, votes, accepted flag, author) inside the question row. Costs no extra requests.

## `includeComments` (type: `boolean`):

Put the comments of the question and of each answer inside the row. Costs no extra requests.

## `bodyFormat` (type: `string`):

How question, answer and comment bodies are delivered: Markdown (as the author typed it), HTML (as rendered on the site), both, or none (smaller output).

## `includeRevisions` (type: `boolean`):

Add the question's revisions (who edited, when, what changed in title and tags). One extra request per 100 questions.

## `includeOwnerProfiles` (type: `boolean`):

Add the asker's badges, location, website, signup date and answer/question counts. One extra request per 100 questions.

## `topUsersPeriod` (type: `string`):

Top answerers and askers of each tag: all time or the last 30 days.

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

Optional. Your own Stack Exchange app key (free, register at stackapps.com/apps/oauth/register). Raises the API limit from 300 to 10,000 requests per day and removes the 25-page cap. It is a public app key, not a password; it is never logged.

## `healthCheck` (type: `boolean`):

Internal: daily self-test used by the maintainers. Ignores every other field and saves nothing to the dataset.

## `healthCheckSimulateFailure` (type: `boolean`):

Internal: with health check on, uses ids that do not exist so the failure alert can be tested.

## Actor input object example

```json
{
  "mode": "search",
  "sites": [
    "stackoverflow"
  ],
  "query": "asyncio",
  "maxItems": 10,
  "includeAnswers": true,
  "includeComments": false,
  "bodyFormat": "markdown",
  "includeRevisions": false,
  "includeOwnerProfiles": false,
  "topUsersPeriod": "all_time",
  "healthCheck": false,
  "healthCheckSimulateFailure": false
}
```

# Actor output Schema

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

All results. Filter by the recordType column: question, tag, user, site.

## `runSummary` (type: `string`):

Counts per source and per type, API quota left, what failed and why, and inputs that were ignored.

# 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 = {
    "mode": "search",
    "sites": [
        "stackoverflow"
    ],
    "query": "asyncio",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("powernaner/stack-exchange-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 = {
    "mode": "search",
    "sites": ["stackoverflow"],
    "query": "asyncio",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("powernaner/stack-exchange-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 '{
  "mode": "search",
  "sites": [
    "stackoverflow"
  ],
  "query": "asyncio",
  "maxItems": 10
}' |
apify call powernaner/stack-exchange-scraper --silent --output-dataset

```

## MCP server setup

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