# Reddit Scraper | All In One | Cheapest ($0.99/1K Result) (`scrapers-hub/reddit-scraper-enterprise`) Actor

\[𝘾𝙝𝙚𝙖𝙥𝙚𝙨𝙩] Reddit Scraper Enterprise extracts posts, comments, subreddits, user profiles, votes, timestamps, and other public Reddit data at scale 💬📊 Ideal for sentiment analysis, market research, trend monitoring, brand tracking, AI datasets, and competitive intelligence.

- **URL**: https://apify.com/scrapers-hub/reddit-scraper-enterprise.md
- **Developed by:** [Scrapers Hub](https://apify.com/scrapers-hub) (community)
- **Categories:** AI, Social media, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

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

## Reddit Search Scraper (Apify Actor)

Searches Reddit for one or more keyword queries and returns **enriched post objects**
(and optionally comments) as structured JSON in the Actor dataset. Uses Reddit's
public `.json` endpoints — no OAuth/API key required.

### Input

```json
{
  "queries": ["Cheesecake", "Swimming Pool"],
  "maxPosts": 100,
  "maxComments": 100,
  "sort": "relevance",
  "timeframe": "all",
  "subredditSort": "relevance",
  "subredditTimeframe": "all",
  "includeNsfw": false,
  "scrapeComments": false,
  "strictSearch": false,
  "strictTokenFilter": false,
  "maximize_coverage": false,
  "forceSortNewForTimeFilteredRuns": false,
  "content_analysis": false,
  "sentiment_analysis": false
}
```

| Field | Type | Meaning |
|---|---|---|
| `queries` | string\[] | Keywords/phrases to search. A value like `r/pics cats` restricts the search to a subreddit. |
| `maxPosts` | int | Max posts collected **per query** (paginates in pages of 100). |
| `sort` / `timeframe` | enum | Reddit search sort (`relevance/hot/top/new/comments`) and time window (`all/year/month/week/day/hour`). |
| `subredditSort` / `subredditTimeframe` | enum | Same, applied when a query targets a specific `r/subreddit`. |
| `strictSearch` | bool | Keep only posts where **every** query token appears in the title/body. |
| `strictTokenFilter` | bool | Keep only posts containing the **exact query phrase**. |
| `maximize_coverage` | bool | Sweep multiple sort orders to gather more unique posts. |
| `forceSortNewForTimeFilteredRuns` | bool | Force `new` sort whenever `timeframe != all`. |
| `includeNsfw` | bool | Include `over_18` posts. |
| `scrapeComments` / `maxComments` | bool / int | Also fetch and flatten each post's comment tree. |
| `content_analysis` | bool | Attach a `content_analysis` object (keywords, token stats, question/URL detection). |
| `sentiment_analysis` | bool | Attach a lexicon-based `sentiment` object (`positive/negative/neutral`). |

### Output

Each dataset item is either a **post** (`"kind": "post"`) or a **comment**
(`"kind": "comment"`). Posts include the raw Reddit fields plus derived metrics:

- `age_hours`, `score_per_hour`, `comments_per_hour`
- `engagement_total`, `comment_to_score_ratio`, `is_high_engagement`
- `media_type`, `has_media`, `gallery_images`, `gallery_count`, `outbound_url_host`
- `title_length`, `body_length`, `word_count`
- `is_deleted_or_removed`, `content_flags`
- `canonical_url`, `old_reddit_url`, `retrieved_at`

See `src/enrich.js` for the exact shape.

### How it avoids being blocked

Reddit returns a hard **403** to plain HTTP clients (even ones that impersonate a
TLS fingerprint) because they can't solve Reddit's JS/Cloudflare "Please wait for
verification" challenge. This Actor drives a real headless **Chromium
(Playwright)** session: it loads a Reddit page so the browser solves the
challenge and earns a valid session cookie, then fetches the `.json` endpoints
**from inside the page** (same-origin, `credentials: 'include'`). One warmed
session is reused for all search pagination and comment fetches; on a block/403
it relaunches with a fresh residential proxy. See `RedditBrowser` in
`src/reddit.py`.

### Project layout (Python)

```
.actor/actor.json          Actor config
.actor/input_schema.json   Input UI
Dockerfile                 apify/actor-python-playwright:3.13 (Chromium preinstalled)
requirements.txt           apify (pydantic/browserforge pinned)
src/__main__.py            Entry point (python -m src)
src/main.py                Orchestration + Playwright session lifecycle
src/reddit.py              RedditBrowser (browser fetch) + search/pagination
src/comments.py            Comment scraping
src/enrich.py              Derived fields
src/analysis.py            Content + sentiment analysis
```

### Run locally

```bash
pip install -r requirements.txt
apify run          # or: python -m src   (with local input in storage/)
```

### Deploy

```bash
apify login
apify push         # builds a NEW image with the current code
```

### Notes

- **Use residential proxies.** Reddit blocks datacenter IPs; the default
  `proxyConfiguration` is `useApifyProxy` + `RESIDENTIAL`.
- Because it runs a real browser, give the Actor enough memory (**≥ 2–4 GB**).
- If a network blocks/redirects Reddit itself (e.g. some ISPs), local runs will
  fail — validate on the Apify platform where the residential proxy is used.
- Content/sentiment analysis are lightweight offline heuristics — replace with a
  real NLP service if you need higher accuracy.

# Actor input Schema

## `queries` (type: `array`):

One or more keywords / phrases to search across all of Reddit.

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

How Reddit ranks the search results.

## `timeframe` (type: `string`):

Only include results from this time window.

## `subredditName` (type: `string`):

Subreddit name, with or without the r/ prefix (e.g. 'food' or 'r/food').

## `subredditKeywords` (type: `array`):

Optional keywords to search inside the subreddit. Leave empty to browse the subreddit's posts.

## `subredditSort` (type: `string`):

How Reddit ranks results within the subreddit.

## `subredditTimeframe` (type: `string`):

Only include subreddit results from this time window.

## `urls` (type: `array`):

Full Reddit post URLs to scrape directly.

## `scrapeComments` (type: `boolean`):

Also collect the comments of every scraped post.

## `maxComments` (type: `integer`):

Maximum number of comments to collect per post.

## `dateFrom` (type: `string`):

Keep only posts created on or after this date (YYYY-MM-DD, UTC).

## `dateTo` (type: `string`):

Keep only posts created on or before this date (YYYY-MM-DD, UTC).

## `commentDateFrom` (type: `string`):

Keep only comments created on or after this date (YYYY-MM-DD, UTC).

## `commentDateTo` (type: `string`):

Keep only comments created on or before this date (YYYY-MM-DD, UTC).

## `forceSortNewForTimeFilteredRuns` (type: `boolean`):

Force 'new' sort whenever a time range is set, so recent posts aren't missed.

## `includeNsfw` (type: `boolean`):

Include posts marked over\_18 / NSFW.

## `strictSearch` (type: `boolean`):

Keep only posts where every query token appears in the title or body.

## `strictTokenFilter` (type: `boolean`):

Keep only posts that contain the exact query phrase.

## `maxPosts` (type: `integer`):

Maximum number of posts to collect per search / subreddit / URL.

## `maximize_coverage` (type: `boolean`):

Sweep multiple sort orders per seed to gather more unique posts.

## `sentiment_analysis` (type: `boolean`):

Attach a lexicon-based sentiment score and label to each post.

## `content_analysis` (type: `boolean`):

Attach a content category (Finance, Sports, Gaming, Politics, …) and stats to each post.

## `mcpConnectors` (type: `array`):

Connector IDs to hand off the run summary to (optional).

## Actor input object example

```json
{
  "queries": [
    "Cheesecake",
    "Swimming Pool"
  ],
  "sort": "relevance",
  "timeframe": "all",
  "subredditSort": "relevance",
  "subredditTimeframe": "all",
  "scrapeComments": false,
  "maxComments": 50000,
  "forceSortNewForTimeFilteredRuns": false,
  "includeNsfw": false,
  "strictSearch": false,
  "strictTokenFilter": false,
  "maxPosts": 50000,
  "maximize_coverage": false,
  "sentiment_analysis": false,
  "content_analysis": false
}
```

# 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 = {
    "queries": [
        "Cheesecake",
        "Swimming Pool"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapers-hub/reddit-scraper-enterprise").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 = { "queries": [
        "Cheesecake",
        "Swimming Pool",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("scrapers-hub/reddit-scraper-enterprise").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 '{
  "queries": [
    "Cheesecake",
    "Swimming Pool"
  ]
}' |
apify call scrapers-hub/reddit-scraper-enterprise --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/X6Ke1drq8pbhwoQzn/builds/Xr3ONXJ4C3ytrc7OA/openapi.json
