# Reddit Search Scraper (`codingfrontend/reddit-search-scraper`) Actor

Search Reddit by keyword and scrape matching posts with full metadata, images, videos, awards, and optional comments. Optionally restrict search to a single subreddit.

- **URL**: https://apify.com/codingfrontend/reddit-search-scraper.md
- **Developed by:** [Coding Frontned](https://apify.com/codingfrontend) (community)
- **Categories:** Social media, Developer tools, Other
- **Stats:** 6 total users, 2 monthly users, 67.4% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#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

## Reddit Search Scraper

Search Reddit's public Atom feed by keyword and store normalized post records. The Actor uses direct HTTP requests, bounded retries, and optional Apify proxy configuration. It does not launch a browser, spoof fingerprints, open individual posts, or extract comments.

### Input

| Field | Type | Default | Description |
|---|---|---:|---|
| `searchQuery` | string | required | Keyword or phrase, 1–200 characters |
| `subreddit` | string | none | Optional subreddit without `r/` |
| `sortBy` | string | `relevance` | `relevance`, `new`, `hot`, `top`, or `comments` |
| `topTime` | string | `all` | Time window used only with `sortBy: "top"` |
| `maxItems` | integer | `25` | Maximum unique posts, 1–100 |
| `maxPages` | integer | `3` | Maximum feed pages, 1–10 |
| `proxyConfiguration` | object | none | Optional Apify proxy configuration |

Unknown fields and type coercion are rejected.

### Output

Each dataset row is a real public feed entry with its Reddit ID, title, permalink, available author/subreddit/text/count metadata, search context, exact source feed URL, HTTP provenance, and explicit truth fields. Optional feed values are omitted when Reddit does not expose them. No placeholder or diagnostic row is written to the dataset.

The `OUTPUT` key-value-store record contains `SUCCESS`, `PARTIAL`, `NO_RESULTS`, or `FAILED`, request limits, page and row counts, proxy/browser provenance, and bounded failure messages. A failed run throws after writing this summary.

### Limits

Reddit may return rate limits or access denials. The Actor retries retryable responses three times with backoff. Configure an appropriate Apify proxy if the run environment cannot access the public feed. Feed text and counts are limited to what Reddit includes in Atom; this Actor does not claim full post bodies or comment trees.

### Local use

```powershell
npm ci
$env:APIFY_INPUT_FILE = 'test-input.json'
npm start
node validate-datasets.js storage/datasets/default
```

`validate-datasets.js` accepts a dataset directory, a JSON file, or JSON/JSONL on standard input.

# Actor input Schema

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

Keyword or phrase to search in Reddit's public Atom feed.

## `subreddit` (type: `string`):

Optional subreddit name without r/.

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

Reddit search ordering.

## `topTime` (type: `string`):

Used only when sortBy is top.

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

Maximum number of unique post records to store.

## `maxPages` (type: `integer`):

Maximum number of Atom feed pages to request.

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

Optional Apify proxy configuration for rate-limited networks.

## Actor input object example

```json
{
  "searchQuery": "openai",
  "sortBy": "relevance",
  "topTime": "all",
  "maxItems": 25,
  "maxPages": 3
}
```

# Actor output Schema

## `dataset` (type: `string`):

URL of the dataset containing successful Reddit post records.

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

Search context, request counts, saved results, and bounded failures.

# 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": "openai"
};

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,codingfrontend/reddit-search-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/8fbWFbSdyIbs24dxx/builds/uepkp7hH1kH7IZA49/openapi.json
