# Reddit Intelligence Scraper (`nikhuge/reddit-intelligence-scraper`) Actor

Reddit is one of the largest real-time sources of consumer opinions, trends, and product feedback. Reddit Intelligence Scraper is an advanced Apify Actor built to turn Reddit into a powerful business, research, and growth-hacking intelligence engine.

- **URL**: https://apify.com/nikhuge/reddit-intelligence-scraper.md
- **Developed by:** [charith wijesundara](https://apify.com/nikhuge) (community)
- **Categories:** AI, Lead generation, Agents
- **Stats:** 4 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $8.00 / 1,000 reddit posts

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/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 Intelligence Scraper

A production-ready Apify Actor for scraping Reddit posts and comments with AI-powered intelligence extraction.

### Features

- **Multi-source scraping**: Subreddits, search results, and user profiles
- **Full comment trees**: Extract nested comment threads
- **AI-powered analysis**: Sentiment, topic extraction, entity recognition (via LlamaIndex + OpenAI)
- **Anti-ban system**: Proxy rotation, session pooling, CAPTCHA detection, human-like delays
- **Playwright support**: JavaScript rendering for dynamic content
- **LangGraph orchestration**: Agentic crawl decision-making

### Input Schema

```json
{
  "subreddits": ["entrepreneur", "startups"],
  "keywords": ["stripe", "shopify", "saas"],
  "users": ["spez"],
  "maxPosts": 100,
  "maxCommentsPerPost": 50,
  "sort": "hot",
  "time": "week",
  "minScore": 10,
  "includeNSFW": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  },
  "enablePlaywright": true,
  "enableAI": false,
  "openaiApiKey": ""
}
```

### Output Format

Each scraped post produces a dataset item:

```json
{
  "type": "reddit_post",
  "post": {
    "post_id": "abc123",
    "subreddit": "startups",
    "title": "Post title",
    "body": "Post content...",
    "author": "username",
    "score": 150,
    "upvote_ratio": 0.95,
    "num_comments": 42,
    "awards": ["Gold"],
    "flair": "Discussion",
    "created_utc": "2024-01-15T10:30:00Z",
    "post_age_hours": 24.5,
    "url": "https://...",
    "permalink": "/r/startups/comments/...",
    "is_nsfw": false,
    "is_locked": false,
    "is_archived": false
  },
  "comments": [
    {
      "comment_id": "xyz789",
      "parent_id": "abc123",
      "author": "commenter",
      "body": "Comment text...",
      "score": 25,
      "depth": 0,
      "created_utc": "2024-01-15T11:00:00Z",
      "is_op": false,
      "is_deleted": false
    }
  ],
  "ai": {
    "sentiment": 0.75,
    "topics": ["entrepreneurship", "funding", "product-market-fit"],
    "entities": ["Stripe", "Y Combinator", "Series A"]
  },
  "scraped_at": "2024-01-15T12:00:00Z",
  "source": "reddit"
}
```

### Local Development

```bash
## Install dependencies
pip install -r requirements.txt

## Install Playwright browsers
playwright install chromium

## Run locally
apify run
```

### Deployment

```bash
## Login to Apify
apify login

## Deploy to Apify platform
apify push
```

### Configuration

#### Proxy Settings

Residential proxies are strongly recommended for Reddit scraping:

```json
{
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

#### AI Processing

The actor supports three AI providers for sentiment analysis, topic extraction, and entity recognition:

| Provider | Models | Default |
|----------|--------|---------|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-3.5-turbo | gpt-4o |
| Gemini | gemini-2.0-flash, gemini-1.5-pro | gemini-2.0-flash |
| Anthropic | claude-3-5-sonnet, claude-3-5-haiku | claude-3-5-sonnet |

**Configuration Example:**

```json
{
  "enableAI": true,
  "aiProvider": "openai",
  "aiModel": "gpt-4o",
  "openaiApiKey": "sk-..."
}
```

For Gemini:

```json
{
  "enableAI": true,
  "aiProvider": "gemini",
  "geminiApiKey": "AIza..."
}
```

For Anthropic:

```json
{
  "enableAI": true,
  "aiProvider": "anthropic",
  "anthropicApiKey": "sk-ant-..."
}
```

### Architecture

```
src/
├── __init__.py          # Package init
├── __main__.py          # Entry point
├── main.py              # Actor initialization and orchestration
├── items.py             # Scrapy item definitions
├── middlewares.py       # Anti-ban middlewares
├── pipelines.py         # Data processing pipelines
├── settings.py          # Scrapy configuration
├── agents/              # LangGraph orchestration
│   ├── __init__.py
│   └── graph.py
├── ai/                  # LlamaIndex AI processing
│   ├── __init__.py
│   └── processor.py
└── spiders/             # Scrapy spiders
    ├── __init__.py
    └── reddit_spider.py
```

# Actor input Schema

## `subreddits` (type: `array`):

List of subreddit names to scrape (without r/ prefix)

## `keywords` (type: `array`):

Keywords to search across Reddit

## `users` (type: `array`):

Reddit usernames to scrape posts from (without u/ prefix)

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

Maximum number of posts to scrape

## `maxCommentsPerPost` (type: `integer`):

Maximum number of comments to scrape per post

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

How to sort posts

## `time` (type: `string`):

Time range for top posts (only applies when sort is 'top')

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

Only scrape posts with at least this score

## `includeNSFW` (type: `boolean`):

Whether to include NSFW (adult) content

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

Proxy settings for anti-blocking. Residential proxies are recommended for Reddit.

## `enablePlaywright` (type: `boolean`):

Use Playwright for JavaScript-rendered pages (slower but more reliable for comments)

## `enableAI` (type: `boolean`):

Enable AI-powered sentiment analysis, topic extraction, and entity recognition

## `aiProvider` (type: `string`):

Select the AI provider for processing

## `aiModel` (type: `string`):

Specific model to use (leave empty for default)

## `openaiApiKey` (type: `string`):

OpenAI API key (required if aiProvider is 'openai')

## `geminiApiKey` (type: `string`):

Google AI API key (required if aiProvider is 'gemini')

## `anthropicApiKey` (type: `string`):

Anthropic API key (required if aiProvider is 'anthropic')

## Actor input object example

```json
{
  "subreddits": [
    "entrepreneur",
    "startups"
  ],
  "keywords": [
    "stripe",
    "shopify",
    "saas"
  ],
  "users": [],
  "maxPosts": 100,
  "maxCommentsPerPost": 50,
  "sort": "hot",
  "time": "week",
  "minScore": 0,
  "includeNSFW": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "enablePlaywright": true,
  "enableAI": false,
  "aiProvider": "openai",
  "aiModel": ""
}
```

# 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 = {
    "subreddits": [
        "entrepreneur",
        "startups"
    ],
    "keywords": [
        "stripe",
        "shopify",
        "saas"
    ],
    "users": [],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("nikhuge/reddit-intelligence-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 = {
    "subreddits": [
        "entrepreneur",
        "startups",
    ],
    "keywords": [
        "stripe",
        "shopify",
        "saas",
    ],
    "users": [],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("nikhuge/reddit-intelligence-scraper").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 '{
  "subreddits": [
    "entrepreneur",
    "startups"
  ],
  "keywords": [
    "stripe",
    "shopify",
    "saas"
  ],
  "users": [],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call nikhuge/reddit-intelligence-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/cRXTrQhqXYxKVch8U/builds/cPnATfbDg0zdbdOaV/openapi.json
