# Stack Overflow Scraper: Questions, Answers and Comments (`zhtech/stack-overflow-scraper`) Actor

Scrape Stack Overflow and every Stack Exchange site through the official API: questions by tag, search or URL with answers and comments, bodies in HTML, plain text and Markdown, score, views, tags, accepted answer, author and CC BY-SA attribution.

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

## Pricing

from $0.50 / 1,000 questions

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/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 and comments from any Stack Exchange site

Scrape **Stack Overflow** and every other **Stack Exchange** site (Super User, Server Fault, Ask Ubuntu, Mathematics, Unix & Linux, Database Administrators, Data Science and about 180 more) into clean JSON, CSV or Excel. Get questions **by tag**, **by search query** or **by URL**, with their **answers** (accepted answer first) and **comments**, bodies in **HTML, plain text and Markdown**, **score, views, tags, accepted answer, author, dates, links** and a ready made **CC BY-SA attribution** line on every row.

The actor uses the **official Stack Exchange API v2.3**, the sanctioned way to read the network by program. No login, no page scraping, no browser. Up to 100 questions with their full answer and comment threads come back in a single API request, so even the free API quota goes a long way.

### What can this Stack Overflow scraper do?

| You give it | You get |
|---|---|
| Tags (`python`, `c#`, `google-sheets`) on any site | The questions of each tag, sorted by votes, activity, newest, hot, week or month. Several tags as separate queries, or only questions that carry all of them |
| Search queries (`async await deadlock`), optionally inside some tags | The matching questions, sorted by relevance, votes, activity or newest |
| Question URLs, short links, answer links or IDs, from any mix of sites | Exactly those questions. Answer links are resolved to their question |
| Answers and comments on or off | Each question with its top answers (accepted first, then by score) and the comments of the question and of each answer |
| Filters | Date range, min score, min answers, min views, accepted answer yes or no, open or closed, title contains, excluded tags |

Fields on every question row: `site`, `siteName`, `questionId`, `title`, `link`, `shareLink`, `tags`, `score`, `upVoteCount`, `downVoteCount`, `viewCount`, `favoriteCount`, `answerCount`, `commentCount`, `isAnswered`, `hasAcceptedAnswer`, `acceptedAnswerId`, `acceptedAnswerLink`, `acceptedAnswer` (short summary with text), `isClosed`, `closedReason`, `closedDate`, `bountyAmount`, `bountyClosesDate`, `owner` (name, user ID, reputation, profile link, avatar), `lastEditor`, `creationDate`, `lastActivityDate`, `lastEditDate`, `communityOwnedDate`, `lockedDate`, `protectedDate`, `migratedTo`, `migratedFrom`, `bodyText`, `bodyHtml`, `bodyMarkdown`, `contentLicense`, `attribution`, `answers`, `comments`, `answersIncluded`, `input`, `query`, `scrapedAt`.

Answer fields: `answerId`, `questionId`, `isAccepted`, `score`, `upVoteCount`, `downVoteCount`, `owner`, `lastEditor`, `creationDate`, `lastActivityDate`, `lastEditDate`, `commentCount`, `link`, `shareLink`, `bodyText`, `bodyHtml`, `bodyMarkdown`, `contentLicense`, `attribution`, `comments`.

### Why this actor

- **Official API, nothing to break.** No HTML parsing, no blocked pages, no CAPTCHA. Stack Overflow's website forbids crawlers in its robots.txt; this actor never loads a site page and only talks to `api.stackexchange.com`.
- **Full threads for the price of one request.** Answers and comments come nested in the same API call as up to 100 questions. Other tools spend one request per question for answers and run out of quota quickly.
- **Three body formats.** HTML for display, clean plain text for analysis (code blocks kept verbatim, links as text and URL), and the original Markdown.
- **Attribution built in.** Every question, answer and comment carries its link, author, author profile, license (CC BY-SA 2.5, 3.0 or 4.0) and a ready made attribution sentence, so you can meet the license terms without extra work.
- **Quota aware.** The actor honors the API's `backoff` instructions, waits out short throttles, stops cleanly with a plain message when the daily quota is used up, and reports the remaining quota in the status and run summary.
- **Your own free API key, optional.** Without a key the API allows 300 requests per day per IP address. Add a free key and you get 10,000 per day.
- **Fair billing.** You pay per question and per answer you get. Comments are free. Duplicates (a question found by two tags), filtered questions and error rows are never charged. Invalid input stops the run before the start fee.

### Use cases

- **Developer research and DevRel**: see what people ask about your library, API or competitor, which questions stay unanswered, and which answers the community trusts.
- **Product and documentation gaps**: collect the most viewed questions in your tag and turn them into docs, FAQ entries or tutorials.
- **Support monitoring**: run every hour with sort Newest and a date filter, and push new questions in your tags to Slack, email or a ticket system.
- **Technology trend analysis**: compare tags by question volume, views and answer rates over time.
- **Hiring and community**: find the people who answer well in a niche (public profile links and reputation only).
- **Knowledge bases and internal search**: pull accepted answers with their text and links into your own help tools, with attribution (see the licensing section first).

### How to use

1. Pick **What to scrape**: Questions by tag, Search, or Question URLs or IDs.
2. Enter the **Site** (default `stackoverflow`), then your tags, queries or URLs.
3. Choose the **Sort** and **Max questions per tag or query**.
4. Decide on **answers** (and how many per question) and **comments**.
5. Optionally add **filters** and your free **API key**.
6. Click **Start**. Results appear in the **Questions**, **Answers** and **Errors** views and can be exported as JSON, CSV, Excel, XML or HTML.

### Input examples

The prefilled example: the 20 top voted questions in the `web-scraping` tag, each with its accepted (or best) answer. One API request.

```json
{
    "mode": "tags",
    "site": "stackoverflow",
    "tags": ["web-scraping"],
    "maxQuestionsPerQuery": 20,
    "maxAnswersPerQuestion": 1
}
```

Search inside a tag, with three answers and all comments per question:

```json
{
    "mode": "search",
    "searchQueries": ["async await deadlock"],
    "searchTags": ["c#"],
    "sort": "relevance",
    "maxQuestionsPerQuery": 50,
    "maxAnswersPerQuestion": 3,
    "includeComments": true
}
```

Newest questions that carry both `python` and `pandas`, asked in the last 7 days (good for a schedule):

```json
{
    "mode": "tags",
    "tags": ["python", "pandas"],
    "tagMatch": "all",
    "sort": "creation",
    "fromDate": "7 days",
    "maxQuestionsPerQuery": 500
}
```

Specific questions from different sites, answer links included:

```json
{
    "mode": "urls",
    "questionUrls": [
        "https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array",
        "https://stackoverflow.com/a/11227902",
        "https://math.stackexchange.com/q/11",
        "https://superuser.com/questions/1"
    ],
    "maxAnswersPerQuestion": 5,
    "includeComments": true
}
```

Other sites and filters: well viewed, open probability questions on Mathematics with an accepted answer, no answers included:

```json
{
    "mode": "tags",
    "site": "math",
    "tags": ["probability"],
    "acceptedAnswer": "yes",
    "minAnswers": 2,
    "minViews": 1000,
    "closedStatus": "open",
    "includeAnswers": false
}
```

Spreadsheet friendly layout, one row per answer:

```json
{
    "mode": "tags",
    "site": "superuser",
    "tags": ["windows-11"],
    "sort": "week",
    "maxAnswersPerQuestion": 3,
    "outputMode": "separate"
}
```

### Output example

A question row in the default nested layout (long texts shortened, user names replaced):

```json
{
    "type": "question",
    "site": "stackoverflow.com",
    "siteName": "Stack Overflow",
    "questionId": 58960005,
    "title": "async/await deadlock when using WindowsFormsSynchronizationContext in a console app",
    "link": "https://stackoverflow.com/questions/58960005/async-await-deadlock-when-using-windowsformssynchronizationcontext-in-a-console",
    "shareLink": "https://stackoverflow.com/q/58960005",
    "tags": ["c#", "async-await"],
    "score": 6,
    "upVoteCount": 7,
    "downVoteCount": 1,
    "viewCount": 1227,
    "answerCount": 3,
    "commentCount": 4,
    "isAnswered": true,
    "hasAcceptedAnswer": true,
    "acceptedAnswerId": 58960850,
    "acceptedAnswerLink": "https://stackoverflow.com/a/58960850",
    "acceptedAnswer": {
        "answerId": 58960850,
        "score": 3,
        "ownerName": "answer_author",
        "ownerLink": "https://stackoverflow.com/users/11178549/...",
        "creationDate": "2019-11-20T18:11:25.000Z",
        "bodyText": "This happens because the WindowsFormsSynchronizationContext ...",
        "link": "https://stackoverflow.com/questions/58960005/.../58960850#58960850"
    },
    "isClosed": false,
    "closedReason": null,
    "owner": {
        "userId": 162641,
        "displayName": "question_author",
        "reputation": 2666,
        "userType": "registered",
        "link": "https://stackoverflow.com/users/162641/..."
    },
    "creationDate": "2019-11-20T17:18:43.000Z",
    "lastActivityDate": "2019-12-16T09:37:59.000Z",
    "bodyText": "As a learning exercise, I'm trying to reproduce an async/await deadlock ...",
    "bodyHtml": "<p>As a learning exercise, I'm trying to reproduce ...",
    "bodyMarkdown": "As a learning exercise, I'm trying to reproduce ...",
    "contentLicense": "CC BY-SA 4.0",
    "contentLicenseInferred": true,
    "attribution": "\"async/await deadlock when using WindowsFormsSynchronizationContext in a console app\" by question_author, Stack Overflow, https://stackoverflow.com/q/58960005, licensed under CC BY-SA 4.0",
    "comments": [
        {
            "commentId": 104175377,
            "postId": 58960005,
            "score": 0,
            "creationDate": "2019-11-20T17:23:58.000Z",
            "owner": { "userId": 3346583, "displayName": "commenter", "reputation": 9760 },
            "bodyText": "My standing advice is ...",
            "link": "https://stackoverflow.com/questions/58960005/...#comment104175377_58960005",
            "contentLicense": "CC BY-SA 4.0"
        }
    ],
    "answers": [
        {
            "answerId": 58960850,
            "questionId": 58960005,
            "isAccepted": true,
            "score": 3,
            "owner": { "userId": 11178549, "displayName": "answer_author", "reputation": 47198 },
            "creationDate": "2019-11-20T18:11:25.000Z",
            "commentCount": 2,
            "link": "https://stackoverflow.com/questions/58960005/.../58960850#58960850",
            "shareLink": "https://stackoverflow.com/a/58960850",
            "bodyText": "This happens because the WindowsFormsSynchronizationContext ...",
            "bodyHtml": "<p>This happens because the <a href=...",
            "bodyMarkdown": "This happens because the ...",
            "contentLicense": "CC BY-SA 4.0",
            "attribution": "Answer to \"async/await deadlock when using WindowsFormsSynchronizationContext in a console app\" by answer_author, Stack Overflow, https://stackoverflow.com/a/58960850, licensed under CC BY-SA 4.0",
            "comments": []
        }
    ],
    "answersIncluded": 1,
    "input": "async await deadlock",
    "query": "search \"async await deadlock\" in [c#]",
    "scrapedAt": "2026-11-22T01:51:45.757Z"
}
```

An error row (never charged):

```json
{
    "type": "error",
    "input": "https://stackoverflow.com/questions/tagged/python",
    "errorCode": "INVALID_INPUT",
    "error": "\"https://stackoverflow.com/questions/tagged/python\" is a tag page, not a question. Put the tag \"python\" into Tags and the site \"stackoverflow.com\" into Site instead."
}
```

Error codes: `INVALID_INPUT` (not a question URL or ID), `NOT_FOUND` (deleted question or answer, or an ID from another site), `SITE_NOT_FOUND`, `QUOTA_EXHAUSTED`, `KEY_INVALID`, `THROTTLED`, `BAD_PARAMETER`, `FAILED`.

### Licensing and attribution (please read)

Questions, answers and comments on Stack Exchange are written by their users and licensed under **Creative Commons Attribution ShareAlike (CC BY-SA)**, version 2.5, 3.0 or 4.0 depending on the date of the post. The Stack Exchange API Terms of Use require that applications **visibly show that Stack Exchange is the source** of the content. If you publish or share the content, attribution means:

1. Name the source site (for example Stack Overflow).
2. Link to the original question or answer (`link` or `shareLink`).
3. Show the author's name and link to the author's profile (`owner.displayName`, `owner.link`).
4. Keep the license and share adaptations under the same license (`contentLicense`).

The `attribution` field on every row contains all of this as one sentence. For apps without a browser, plain text URLs are enough.

The Stack Exchange **Acceptable Use Policy** also says that automated collection may not be used to build a similar or competing Q\&A website or service, or to develop, train, test, index, benchmark or improve generative AI, chatbots, large language models or machine learning models, without Stack Exchange's written consent (for example a data license from Stack Overflow). Do not use the data for those purposes unless you have that consent. You are responsible for how you use the data. Read the API Terms of Use, the Terms of Service and the Acceptable Use Policy at stackoverflow.com/legal before large or commercial projects.

### API quota and your free API key

The Stack Exchange API counts requests per IP address: **300 per day without a key**, **10,000 per day with a key**. On Apify the IP address of a run is shared with other users, so the free 300 can already be partly used when your run starts. Each request returns up to 100 questions with their answers and comments, so the default run uses 1 request and 1,000 questions use about 10.

To get a key (free, takes two minutes): log in to stackapps.com with any Stack Exchange account, open **stackapps.com/apps/oauth/register**, fill in an application name and any domain (for example `localhost`), and copy the **Key** shown afterwards (not the client secret). Paste it into **Stack Exchange API key**. The field is stored encrypted.

Without a key the API also stops at page 25 of every query (2,500 questions). When the quota is used up, the run stops with a clear message, keeps everything it already saved, and tells you when more requests are available.

### Pricing

Pay per event, you only pay for what is delivered:

- **Actor start**: a small flat fee once per run.
- **Question**: per question row.
- **Answer**: per included answer (nested or as its own row).

Comments are free. The current prices are on the Pricing tab. Never charged: error rows, questions skipped by your filters, duplicates found by several tags or queries, answers beyond your Max answers per question, and anything after your max total charge or Max questions is reached. Invalid input stops the run before the start fee.

Typical runs: the prefilled example is 1 start, 20 questions and 20 answers. 1,000 questions with their accepted answers are 1,000 question events and up to 1,000 answer events.

### Use with the API, integrations and AI agents

- **API**: `POST https://api.apify.com/v2/acts/zhtech~stack-overflow-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN` with the JSON input as the body returns the rows in one call. Add `&view=questions` (or `answers`, `errors`) for one row type.
- **Clients**: `apify-client` for JavaScript and Python. Example (JavaScript): `await client.actor('zhtech/stack-overflow-scraper').call({ mode: 'search', searchQueries: ['useEffect cleanup'], maxQuestionsPerQuery: 30 })`.
- **Schedules and integrations**: run it hourly or daily with sort Newest and **Asked on or after** set to `1 day`, then connect Google Sheets, Slack, a webhook, Zapier, Make or n8n.
- **MCP and agents**: the actor works as a tool through the Apify MCP server (mcp.apify.com), so Claude, ChatGPT, Cursor and other agents can look up Stack Overflow threads on demand. Keep the attribution with any answer you show, and set a max total charge on the run to cap the cost.

### FAQ

**Do I need a Stack Overflow account or API key?**
No. The actor works without any account. A free API key is optional and raises the daily quota from 300 to 10,000 requests.

**Which sites are supported?**
All public Stack Exchange sites and their meta sites: Stack Overflow (and its Russian, Portuguese, Spanish and Japanese versions), Super User, Server Fault, Ask Ubuntu, MathOverflow, Stack Apps and every `<name>.stackexchange.com` site such as math, unix, dba, datascience, gaming, cooking or english. Use the short name or the domain in **Site**.

**How many answers and comments do I get?**
All answers of a question are available; **Max answers per question** decides how many you keep (accepted answer first, then by score). With **Include comments** on, you get all comments of the question and of each included answer.

**Why did my query return no questions?**
Check the tag spelling (as shown on the site, for example `google-sheets`, not `Google Sheets`) and the site. Filters and date ranges can also remove everything. Question volume on Stack Overflow has dropped a lot in recent years, so short date windows in smaller tags can be empty. The run ends with a plain message and no charge for questions.

**What happens when the API quota is used up?**
The run stops cleanly, keeps what it saved, writes a `QUOTA_EXHAUSTED` error row (free) and says when more requests become available. Add your own free API key to avoid this.

**Is HTML, Markdown or plain text better?**
Plain text (`bodyText`) is best for reading, search and analysis; code blocks keep their indentation and links show their URL. HTML (`bodyHtml`) is the rendered post. Markdown (`bodyMarkdown`) is what the author typed.

**Can I monitor new questions?**
Yes. Schedule the actor with sort **Newest** and **Asked on or after** set to the interval of your schedule (for example `1 day`), then send new rows to Slack or a sheet.

**Can I use the data to train an AI model?**
Not without written consent from Stack Exchange. Their Acceptable Use Policy forbids using automatically collected content to build or train generative AI, LLM or machine learning tools, or to build a competing Q\&A service. See the licensing section.

**Is it legal?**
The actor uses the official public API within its quotas and backoff rules and reads only public content. The content is CC BY-SA licensed and needs attribution when shared. You are responsible for following the Stack Exchange terms and the laws that apply to you, especially for any personal data such as user names.

### Limitations

- Public content only: no deleted posts, private Stack Overflow for Teams content, votes of specific users or anything that needs a login.
- Without an API key: 300 API requests per day per IP address (shared on Apify) and at most 25 pages (2,500 questions) per query.
- Search uses Stack Exchange's own search; its relevance ranking is not documented.
- The API returns no license for most questions; the actor then fills `contentLicense` from the Stack Exchange license dates (by the latest edit) and sets `contentLicenseInferred: true`.
- Sorting by hot, week or month works for tag listings only; filters combined with those sorts are applied after reading, which can use more of the quota.

### Support

Found a wrong field or need another data point? Open an issue on the Issues tab with the input you used and it will be looked at quickly.

# Actor input Schema

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

Questions by tag: the questions of one or more tags. Search: free text search, optionally inside some tags. Question URLs or IDs: specific questions (links from any Stack Exchange site, answer links work too).

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

Any Stack Exchange site: a short name (stackoverflow, superuser, serverfault, askubuntu, math, unix, dba, datascience, gaming, cooking and so on), a domain (math.stackexchange.com) or a link to the site. Question URLs carry their own site; this field is then only used for bare numeric IDs.

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

Tags exactly as on the site, one per line, for example python, javascript, c#, google-sheets. A tag page link (https://stackoverflow.com/questions/tagged/python) works too.

## `tagMatch` (type: `string`):

Any: each tag is its own query (duplicates are removed). All: only questions that carry every tag, for example python and pandas together.

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

Free text searches, one per line, for example: async await deadlock. Each query is searched separately in titles, bodies and tags.

## `searchTags` (type: `array`):

Optional. Search only questions that carry at least one of these tags.

## `questionUrls` (type: `array`):

One per line: question links (https://stackoverflow.com/questions/11227809/...), short links (https://superuser.com/q/123), answer links (https://stackoverflow.com/a/456, resolved to their question) or numeric IDs (Site is used for those). Links from different sites can be mixed. Up to 100 questions per API request.

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

Order of questions. Votes: highest score first. Activity: recently active first. Creation: newest first (best for monitoring). Relevance: search only. Hot, week and month: tag listings only, like the tabs on the site.

## `maxQuestionsPerQuery` (type: `integer`):

Stops each tag or search after this many saved questions. Without an API key the API serves at most 25 pages of 100 (2,500 questions) per query. Not used in the Question URLs mode.

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

Adds the answers of each question (accepted answer first, then by score) with body, score and author. They come in the same API request as the questions, so they cost no extra quota. Each included answer is a billable answer event.

## `maxAnswersPerQuestion` (type: `integer`):

1 keeps only the accepted (or top voted) answer. Raise it for full threads.

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

Adds the comments of each question and of each included answer. Comments are free (no extra event).

## `outputMode` (type: `string`):

Nested: one row per question with its answers inside (best for JSON and automations). Separate rows: answers become their own rows linked by questionId (best for spreadsheets).

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

Only questions created on or after this date. YYYY-MM-DD (UTC), a full ISO timestamp, or a relative value such as 24 hours, 7 days, 3 months. Applied by the API, so it costs no extra quota.

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

Only questions created on or before this date. Same formats; a plain date includes the whole UTC day.

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

Only questions with at least this score (upvotes minus downvotes). Leave empty for no limit.

## `minAnswers` (type: `integer`):

Only questions with at least this many answers.

## `minViews` (type: `integer`):

Only questions viewed at least this many times.

## `acceptedAnswer` (type: `string`):

Keep all questions, only those with an accepted answer, or only those without one.

## `closedStatus` (type: `string`):

Keep all questions, only open ones, or only closed ones.

## `titleContains` (type: `string`):

Only questions whose title contains this text.

## `excludeTags` (type: `array`):

Skip questions that carry any of these tags.

## `maxQuestions` (type: `integer`):

Stops the whole run after this many questions. 0 means no limit. Your maximum cost per run (set in the run options) is respected as well.

## `maxPagesPerQuery` (type: `integer`):

Protects your API quota. Each page holds up to 100 questions. Filters that the API cannot apply itself (several tags with All, or filters combined with the hot, week or month sort) may need several pages.

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

Optional and free. Without a key the API allows 300 requests per day per IP address, and on Apify that IP address is shared. With your own key you get 10,000 requests per day and no 25 page limit. Register an app at https://stackapps.com/apps/oauth/register and paste its Key (not the client secret).

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

Not needed: the official API is used. A proxy only changes the IP address of the run (one IP for the whole run). Residential proxy is replaced by datacenter automatically.

## Actor input object example

```json
{
  "mode": "tags",
  "site": "stackoverflow",
  "tags": [
    "web-scraping"
  ],
  "tagMatch": "any",
  "sort": "votes",
  "maxQuestionsPerQuery": 20,
  "includeAnswers": true,
  "maxAnswersPerQuestion": 1,
  "includeComments": false,
  "outputMode": "nested",
  "acceptedAnswer": "any",
  "closedStatus": "any",
  "maxQuestions": 0,
  "maxPagesPerQuery": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `questions` (type: `string`):

No description

## `answers` (type: `string`):

No description

## `errors` (type: `string`):

No description

## `allResults` (type: `string`):

No description

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

No description

# 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": "tags",
    "site": "stackoverflow",
    "tags": [
        "web-scraping"
    ],
    "maxQuestionsPerQuery": 20,
    "maxAnswersPerQuestion": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("zhtech/stack-overflow-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": "tags",
    "site": "stackoverflow",
    "tags": ["web-scraping"],
    "maxQuestionsPerQuery": 20,
    "maxAnswersPerQuestion": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("zhtech/stack-overflow-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": "tags",
  "site": "stackoverflow",
  "tags": [
    "web-scraping"
  ],
  "maxQuestionsPerQuery": 20,
  "maxAnswersPerQuestion": 1
}' |
apify call zhtech/stack-overflow-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zhtech/stack-overflow-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/2CzWWYjRZzY8vxMlv/builds/fdRLH9XE7zQ3OU6KU/openapi.json
