# Stack Overflow Question Search - Developer Q\&A Data (`northglasslabs/stackoverflow-search`) Actor

Search Stack Overflow questions using the free Stack Exchange API. Returns question titles, scores, view counts, answer counts, tags, owner reputation, and links. No authentication required.

- **URL**: https://apify.com/northglasslabs/stackoverflow-search.md
- **Developed by:** [North Glass Labs](https://apify.com/northglasslabs) (community)
- **Categories:** Social media, Developer tools
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 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.

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 Question Search — Developer Q\&A Data Export

Search and extract **Stack Overflow** questions with titles, scores, view counts, answer counts, tags, owner reputation, and timestamps via the Stack Exchange API. Export structured JSON without launching a browser.

### What it does

The Stack Overflow Question Search actor searches questions using the **Stack Exchange API** (`api.stackexchange.com/2.3/search/advanced`). It communicates directly with the public REST API rather than rendering web pages.

Each question returned includes an HTML-decoded title, direct URL, score, view count, answer count, answered status, tags, the asker's display name and reputation, plus creation and last-activity timestamps in ISO-8601 format. Results always use the API's descending relevance ordering.

This makes the actor ideal for developer relations, competitive intelligence, technical content research, and lead generation — you can discover which questions are getting traction in your technology stack, identify active community members by reputation, and build datasets of developer pain points for product planning or content marketing.

### Input parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `searchQuery` | string | ✅ Yes | — | The text to search for in Stack Overflow questions. Must not be empty. |
| `maxResults` | integer | No | `50` | Maximum number of questions to retrieve (1–100). |
| `tagged` | string | No | — | Optional tag to filter questions (e.g. `python`, `javascript`, `docker`). Only questions with this tag are returned. |

### Output fields

Each result item pushed to the dataset contains:

| Field | Type | Description |
|-------|------|-------------|
| `title` | string | HTML-decoded question title |
| `questionUrl` | string | Direct URL to the question on stackoverflow.com |
| `score` | integer | Question score (net upvotes) |
| `viewCount` | integer | Number of times the question has been viewed |
| `answerCount` | integer | Number of answers posted on the question |
| `isAnswered` | boolean | Whether the question has an accepted or upvoted answer |
| `tags` | array of strings | Technology tags on the question (e.g. `["python", "asyncio"]`) |
| `ownerName` | string | Display name of the user who asked the question |
| `ownerReputation` | integer | Reputation score of the question asker at time of query |
| `createdAt` | string | ISO-8601 timestamp of when the question was posted |
| `lastActivityDate` | string | ISO-8601 timestamp of the most recent activity on the question |

### Use cases

- **Developer relations** — find unanswered questions about your product or API to respond to proactively
- **Content marketing** — identify trending questions in your technology niche to write blog posts, tutorials, or documentation that address real developer needs
- **Lead generation** — discover active, high-reputation developers by their questions for recruiting or community outreach
- **Competitive intelligence** — track question volume and sentiment around competing technologies or frameworks
- **Product research** — collect common developer pain points and recurring questions to inform your product roadmap
- **Data collection** — build datasets of developer Q\&A for NLP, trend analysis, or knowledge base construction

### How it works

The actor calls `https://api.stackexchange.com/2.3/search/advanced` with `q`, optional `tagged`, `pagesize`, `site=stackoverflow`, `sort=relevance`, and `order=desc`. It HTML-decodes titles and converts Unix timestamps to ISO-8601 strings before pushing the eleven documented fields to the default dataset. A valid empty API response produces no dataset items. HTTP, network, malformed-response, and JSON errors fail the run. If the API returns a `backoff` value, the actor logs a warning; it does not sleep or retry automatically.

### Example usage

#### Example input

```json
{
    "searchQuery": "async await error handling",
    "maxResults": 5,
    "tagged": "python"
}
```

#### Example output

```json
{
    "title": "How to properly handle errors with async/await in Python",
    "questionUrl": "https://stackoverflow.com/questions/78912345/how-to-properly-handle-errors-with-async-await",
    "score": 42,
    "viewCount": 15823,
    "answerCount": 3,
    "isAnswered": true,
    "tags": ["python", "asyncio", "error-handling"],
    "ownerName": "dev_user123",
    "ownerReputation": 5420,
    "createdAt": "2025-06-10T14:30:00+00:00",
    "lastActivityDate": "2025-07-01T09:15:00+00:00"
}
```

### Pricing

This actor uses the **pay-per-event (PPE)** pricing model on Apify. You are charged a small fee for each successful actor run. Because the Stack Overflow Search uses a free public API and does not launch a browser, runs are extremely fast and cost-efficient — typically completing in under 5 seconds. Check the actor's Apify Store page for the current per-run pricing. Apify's free tier includes monthly platform credits that are sufficient for hundreds of searches.

### Tips

- **Use the `tagged` filter to narrow results** — combining a search query with a tag like `python` or `react` ensures you get questions specific to that technology, not generic matches.
- **Results use relevance ordering** — sorting is fixed to `relevance` in descending order and is not an input option.
- **Respect API backoff requests** — the actor logs `backoff` values but does not automatically delay or retry the request.

# Actor input Schema

## `searchQuery` (type: `string`):

The text to search for in Stack Overflow questions.

## `maxResults` (type: `integer`):

Maximum number of questions to retrieve (1-100).

## `tagged` (type: `string`):

Optional tag to filter questions (e.g. 'python', 'javascript', 'docker').

## Actor input object example

```json
{
  "searchQuery": "python async",
  "maxResults": 50
}
```

# Actor output Schema

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

Questions stored in the default dataset

# 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 = {
    "searchQuery": "python async"
};

// Run the Actor and wait for it to finish
const run = await client.actor("northglasslabs/stackoverflow-search").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 = { "searchQuery": "python async" }

# Run the Actor and wait for it to finish
run = client.actor("northglasslabs/stackoverflow-search").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 '{
  "searchQuery": "python async"
}' |
apify call northglasslabs/stackoverflow-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,northglasslabs/stackoverflow-search"
        }
    }
}
```

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/bUCtlu9sIhyfGhecR/builds/WDzT0nwGIA1dmgKPB/openapi.json
