# Reddit Ultimate Scraper (`khnaami/actor-reddit-scraper`) Actor

Extract Reddit posts with markdown selftext, nested comment trees, media & galleries, subreddit subscriber metrics & rules, and keyword search without API keys.

- **URL**: https://apify.com/khnaami/actor-reddit-scraper.md
- **Developed by:** [khalid naami](https://apify.com/khnaami) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 50.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## 🤖 Reddit Ultimate Scraper (Posts, Comments, Subreddits & Users)

Comprehensive, high-speed, all-in-one Reddit scraper on Apify. Extract **Posts** (with markdown body, images, videos, galleries, and external links), **Nested Threaded Comments & Replies**, **Subreddit Metrics & Rules**, **User Profiles & Karma**, and **Keyword Search** across Reddit.

***

### ⚡ Key Features

- 📑 **Complete Post Metadata**: Full post title, selftext markdown body, author (`u/author`), upvotes/score, upvote ratio, comments count, post flair, and timestamps.
- 🖼️ **Full Media Extraction**: Handles Reddit Videos (with audio/video streams), image galleries (`i.redd.it`), single images, and external article URLs.
- 💬 **Threaded Comments & Replies**: Recursively extracts nested comment trees with upvote scores, OP badges, moderator tags, and parent-child hierarchy.
- 👥 **Subreddit Intelligence**: Scrapes community subscriber counts, active users currently online, community descriptions, and official subreddit rules.
- 👤 **User Profiles & Karma**: Extract user bio, total karma, post karma, comment karma, account age, and verified badges.
- 🔎 **Deep Search & Time Filters**: Search across Reddit or inside specific subreddits with filters (`hot`, `new`, `top`, `rising`, `relevance`) and time frames (`hour`, `day`, `week`, `month`, `year`, `all`).
- 📧 **Lead Generation**: Automatically extracts business emails and social media links (Twitter/X, Instagram, TikTok, LinkedIn, Discord, GitHub) mentioned in posts or bios.
- 🛡️ **Dual-Engine Speed & Reliability**: Fast direct JSON API queries backed by a Playwright headless browser fallback for anti-bot resilience.

***

### 📥 Input Configuration

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `mode` | String | `AUTO_DETECT` | Scraping mode: `AUTO_DETECT`, `POSTS`, `COMMENTS`, `SUBREDDITS`, `USERS`, `SEARCH`. |
| `targetUrls` | Array | `[...]` | List of Subreddit URLs, Post URLs, or User profile URLs. |
| `searchQueries` | Array | `[]` | Keywords to search across Reddit when using `SEARCH` mode. |
| `sort` | String | `"hot"` | Sorting method: `hot`, `new`, `top`, `rising`, `relevance`. |
| `timeFilter` | String | `"all"` | Time frame: `all`, `year`, `month`, `week`, `day`, `hour`. |
| `maxItems` | Integer | `50` | Maximum posts, search results, or items to scrape. |
| `maxComments` | Integer | `30` | Maximum comments and replies per post. |
| `includeComments`| Boolean | `true` | Automatically extract top comments alongside posts. |
| `proxyConfiguration` | Object | `{ useApifyProxy: true }` | Apify proxy configuration (`RESIDENTIAL` recommended for full JSON & Search). |
| `redditClientId` | String | `""` | Optional free Reddit App Client ID (`https://www.reddit.com/prefs/apps`) for `oauth.reddit.com`. |
| `redditClientSecret` | String | `""` | Optional Reddit App Client Secret paired with `redditClientId`. |
| `customCookies` | String | `""` | Optional Reddit session cookies (JSON array or `Cookie` header string) for authenticated access. |

***

### 📤 Output Data Format

#### 1. Reddit Post Record

```json
{
  "type": "POST",
  "id": "1bcxyz",
  "name": "t3_1bcxyz",
  "url": "https://www.reddit.com/r/technology/comments/1bcxyz/new_breakthrough_in_ai/",
  "title": "New Breakthrough in AI Architecture Revealed",
  "body": "Researchers have published a new transformer alternative that operates in linear time...",
  "author": "u/tech_enthusiast",
  "subreddit": "r/technology",
  "score": 4520,
  "upvoteRatio": 0.94,
  "numComments": 380,
  "postType": "text",
  "flair": "Artificial Intelligence",
  "isNsfw": false,
  "isStickied": false,
  "emails": ["researcher@lab.org"],
  "socialLinks": [
    { "platform": "github", "url": "https://github.com/open-research/model" }
  ],
  "createdAt": "2026-10-09T08:30:00.000Z",
  "scrapedAt": "2026-10-09T10:45:00.000Z"
}
```

#### 2. Threaded Comment Record

```json
{
  "type": "COMMENT",
  "id": "m1n2o3",
  "parentId": "t3_1bcxyz",
  "url": "https://www.reddit.com/r/technology/comments/1bcxyz/comment/m1n2o3/",
  "author": "u/datascience_guy",
  "body": "This could significantly reduce compute costs for edge deployment.",
  "score": 312,
  "depth": 0,
  "isOp": false,
  "createdAt": "2026-10-09T09:15:00.000Z",
  "scrapedAt": "2026-10-09T10:45:00.000Z"
}
```

#### 3. Subreddit Record

```json
{
  "type": "SUBREDDIT",
  "id": "2qh16",
  "name": "r/technology",
  "url": "https://www.reddit.com/r/technology/",
  "title": "Technology",
  "description": "A community dedicated to the news and discussions about the creation and use of technology...",
  "subscribers": 16500000,
  "activeUsers": 4200,
  "isNsfw": false,
  "iconUrl": "https://styles.redditmedia.com/...",
  "scrapedAt": "2026-10-09T10:45:00.000Z"
}
```

***

### 🤖 AI & LLM Use Cases

- **Sentiment Analysis & Brand Monitoring**: Analyze public sentiment towards companies, products, or competitors in real-time.
- **LLM Pretraining & RAG Pipelines**: Feed authentic community discussions and Q\&As into retrieval-augmented generation models.
- **Trend Spotting & Market Research**: Identify emerging consumer problems and viral topics before they hit mainstream media.

***

### 📄 License

Apache-2.0

# Actor input Schema

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

Select Reddit data extraction mode, or use AUTO_DETECT.

## `targetUrls` (type: `array`):

List of Reddit URLs (Subreddits, Post URLs, or User Profiles).

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

Keywords to search across Reddit when using SEARCH mode.

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

Sorting criteria for subreddit posts and search results.

## `timeFilter` (type: `string`):

Time range filter when sorting by 'top' or searching.

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

Maximum number of posts, search results, or user items to scrape.

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

Max comments & replies to extract per post.

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

If enabled, automatically extracts top comments alongside each post.

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

Apify Proxy settings. Reddit frequently blocks datacenter/cloud IPs with HTTP 403 on .json/search endpoints; RESIDENTIAL proxies or Reddit OAuth credentials below are recommended.

## `redditClientId` (type: `string`):

Optional free Reddit App Client ID (from https://www.reddit.com/prefs/apps) to use official oauth.reddit.com JSON API reliably without proxy blocks.

## `redditClientSecret` (type: `string`):

Optional Reddit App Client Secret paired with Client ID for official OAuth API access.

## `customCookies` (type: `string`):

Optional Reddit cookies (JSON array or 'reddit_session=...; token_v2=...' string) for authenticated access without OAuth app keys.

## Actor input object example

```json
{
  "mode": "AUTO_DETECT",
  "targetUrls": [
    "https://www.reddit.com/r/technology/hot/",
    "https://www.reddit.com/r/OpenAI/"
  ],
  "searchQueries": [
    "artificial intelligence news"
  ],
  "sort": "hot",
  "timeFilter": "all",
  "maxItems": 50,
  "maxComments": 30,
  "includeComments": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

Scraped Reddit records (Posts, Comments, Subreddits, Users, Search Results)

## `overview` (type: `string`):

High-level summary report and execution metrics stored in Key-Value store

# 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 = {
    "targetUrls": [
        "https://www.reddit.com/r/technology/hot/",
        "https://www.reddit.com/r/OpenAI/"
    ],
    "searchQueries": [
        "artificial intelligence news"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khnaami/actor-reddit-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 = {
    "targetUrls": [
        "https://www.reddit.com/r/technology/hot/",
        "https://www.reddit.com/r/OpenAI/",
    ],
    "searchQueries": ["artificial intelligence news"],
}

# Run the Actor and wait for it to finish
run = client.actor("khnaami/actor-reddit-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 '{
  "targetUrls": [
    "https://www.reddit.com/r/technology/hot/",
    "https://www.reddit.com/r/OpenAI/"
  ],
  "searchQueries": [
    "artificial intelligence news"
  ]
}' |
apify call khnaami/actor-reddit-scraper --silent --output-dataset

```

## MCP server setup

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