# Reddit Scraper — Posts, Search & Deep Comments (`alias_md5/reddit-scraper`) Actor

Track brand mentions, SaaS customer pain points, and niche community discussions on Reddit — posts, keyword search, user profiles, and full nested comment trees exported to clean JSON, CSV, or Excel ($0 on deleted or unavailable posts).

- **URL**: https://apify.com/alias_md5/reddit-scraper.md
- **Developed by:** [Alias Data Studio](https://apify.com/alias_md5) (community)
- **Categories:** Social media, AI, Lead generation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.60 / 1,000 reddit post / profile / subreddit records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/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

## Reddit Scraper

Fast, reliable Reddit data extraction for posts, global and subreddit search, deep nested comment threads, user profiles, and subreddit statistics. Export clean, analysis-ready datasets directly to JSON, CSV, Excel, or downstream AI pipelines.

### What You Can Extract

- **Subreddit Posts (`subreddit_posts`)**: Collect `hot`, `new`, `top`, and `rising` posts across one or many subreddits (e.g. `r/MachineLearning`, `r/LocalLLaMA`, `r/nvidia`) with full pagination and time-range filters (`hour`, `day`, `week`, `month`, `year`, `all`).
- **Global & Subreddit Search (`search`)**: Run keyword searches (e.g. `"AI agents"`) across all of Reddit or scoped to specific subreddits, sorted by `relevance`, `hot`, `top`, `new`, or `comments`.
- **Deep Comment Threads (`comments`)**: Extract nested comment trees with `commentId`, `parentId`, `depth`, `author`, `score`, `isSubmitter` (OP badge), clean plain-text `body`, `createdAtIso`, and `permalink`. Also supports optional per-post comment expansion (`maxCommentsPerPost`) while collecting posts.
- **User Profiles & Submissions (`user`)**: Gather user karma breakdowns, account creation dates, and submitted post history (e.g. `karpathy`).
- **Subreddit Info & Statistics (`subreddit_info`)**: Pull subscriber counts, descriptions, community type, language, and creation timestamps.

### Flexible URL Support

Paste raw identifiers (`r/MachineLearning`, `karpathy`) or full Reddit URLs in any format—standard post links, subreddit feeds, user pages, or `redd.it` short links—and the scraper normalizes and routes them automatically.

Deleted posts, invalid URLs, and private or nonexistent communities are skipped cleanly and recorded in `RUN_SUMMARY` at no charge.

### Input Examples

#### 1. Collect Top Weekly Posts from AI & Tech Subreddits

```json
{
  "mode": "subreddit_posts",
  "subreddits": ["r/MachineLearning", "r/LocalLLaMA", "r/nvidia"],
  "sort": "top",
  "timeRange": "week",
  "maxPosts": 100
}
```

#### 2. Search Reddit for `"AI agents"`

```json
{
  "mode": "search",
  "queries": ["AI agents"],
  "searchSort": "relevance",
  "timeRange": "month",
  "maxPosts": 75
}
```

#### 3. Extract Deep Comment Threads from a Discussion

```json
{
  "mode": "comments",
  "postUrls": [
    "https://www.reddit.com/r/MachineLearning/comments/1xxqa3i/"
  ],
  "commentSort": "top",
  "maxComments": 200
}
```

#### 4. Collect User Profile & Submitted Posts

```json
{
  "mode": "user",
  "usernames": ["karpathy"],
  "sort": "top",
  "timeRange": "all",
  "maxPosts": 50,
  "includeUserProfile": true
}
```

### Output Schema

Every dataset record includes a `recordType` discriminator (`post`, `comment`, `subreddit_info`, or `user_profile`) so flat CSV/Excel exports and JSON streams stay clean and consistent.

#### Post Record (`recordType: "post"`)

```json
{
  "recordType": "post",
  "postId": "1xxqa3i",
  "fullname": "t3_1xxqa3i",
  "subreddit": "MachineLearning",
  "subredditPrefixed": "r/MachineLearning",
  "title": "AISTATS 2027 paper discussion [D]",
  "author": "LongjumpingAd4741",
  "selftext": "Paper discussion thread for AISTATS 2027 submissions.",
  "score": 47,
  "upvoteRatio": 0.96,
  "commentCount": 208,
  "createdAtIso": "2026-11-17T13:09:31.000Z",
  "permalink": "https://www.reddit.com/r/MachineLearning/comments/1xxqa3i/aistats_2027_paper_discussion_d/",
  "url": "https://www.reddit.com/r/MachineLearning/comments/1xxqa3i/aistats_2027_paper_discussion_d/",
  "domain": "self.MachineLearning",
  "flair": "Discussion",
  "isSelf": true,
  "isVideo": false,
  "isNsfw": false,
  "isStickied": true,
  "thumbnailUrl": null,
  "sourceMode": "subreddit_posts"
}
```

#### Comment Record (`recordType: "comment"`)

```json
{
  "recordType": "comment",
  "commentId": "t1_19sruzf86uhms",
  "shortId": "19sruzf86uhms",
  "postId": "t3_1xxqa3i",
  "parentId": "t1_19srtspl9hpz5",
  "subreddit": "MachineLearning",
  "author": "YamJealous4914",
  "score": 7,
  "depth": 1,
  "body": "Did they forget the deadline while finishing conference reviews?",
  "createdAtIso": "2026-11-17T13:11:54.969Z",
  "permalink": "https://www.reddit.com/r/MachineLearning/comments/1xxqa3i/comment/19sruzf86uhms/",
  "isSubmitter": false
}
```

#### Subreddit Info Record (`recordType: "subreddit_info"`)

```json
{
  "recordType": "subreddit_info",
  "subredditId": "t5_2r3gv",
  "name": "MachineLearning",
  "prefixedName": "r/MachineLearning",
  "title": "Machine Learning",
  "publicDescription": "Machine learning research, papers, and engineering discussions.",
  "description": "...",
  "subscribers": 3084332,
  "activeUsers": 1420,
  "createdAtIso": "2009-07-29T13:14:44.000Z",
  "over18": false,
  "subredditType": "public",
  "language": "en",
  "url": "https://www.reddit.com/r/MachineLearning/",
  "iconUrl": null
}
```

#### User Profile Record (`recordType: "user_profile"`)

```json
{
  "recordType": "user_profile",
  "userId": "t2_6qjyb",
  "username": "karpathy",
  "url": "https://www.reddit.com/user/karpathy/",
  "linkKarma": 2756,
  "commentKarma": 55,
  "totalKarma": 2811,
  "createdAtIso": "2012-01-23T22:53:22.000Z",
  "isGold": false,
  "verified": false,
  "description": "",
  "iconUrl": "https://www.redditstatic.com/avatars/defaults/v2/avatar_default_2.png"
}
```

### Pricing

Simple pay-per-event pricing based solely on delivered records. Skipped, invalid, private, or deleted targets are never billed, and runs honor your maximum total charge limit automatically.

| Event | Included Records | Free | Bronze | Silver | Gold | Platinum / Diamond |
| --- | --- | --- | --- | --- | --- | --- |
| `reddit-post` | Subreddit posts, search results, user posts, subreddit & user info | $1.00 / 1k | $0.85 / 1k | $0.70 / 1k | $0.60 / 1k | $0.50 / 1k |
| `reddit-comment` | Individual comments (comments mode or post expansion) | $0.75 / 1k | $0.65 / 1k | $0.55 / 1k | $0.45 / 1k | $0.35 / 1k |

### Run Summary

Every run writes a structured `RUN_SUMMARY` record to the default key-value store containing delivery totals, request duration, and any skipped targets with their reasons.

### Quick Integration (API, MCP & n8n)

#### Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("alias_md5/reddit-scraper").call(run_input={
    "mode": "search",
    "queries": ["AI agents"],
    "searchSort": "relevance",
    "timeRange": "week",
    "maxPosts": 50,
})
items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
print(f"Collected {len(items)} Reddit records")
```

#### Node.js (`apify-client`)

```javascript
import { ApifyClient } from "apify-client";

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor("alias_md5/reddit-scraper").call({
  mode: "subreddit_posts",
  subreddits: ["r/MachineLearning", "r/LocalLLaMA"],
  sort: "top",
  timeRange: "week",
  maxPosts: 50,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.slice(0, 3));
```

#### AI Agents (Apify MCP Server)

Connect this Actor directly to Claude Desktop, Cursor, or custom AI agents via **Apify MCP Server**:

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?actors=alias_md5/reddit-scraper",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_TOKEN>"
      }
    }
  }
}
```

#### n8n Automation

Add the official **Apify** node (`@apify/n8n-nodes-apify`) → **Run Actor** with `alias_md5/reddit-scraper`, pass your subreddit or search input JSON, and chain **Get Dataset Items** into Slack, Notion, Google Sheets, or an LLM summary step.

# Actor input Schema

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

Choose which Reddit dataset to collect.

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

Subreddit names or URLs (e.g. r/MachineLearning, r/LocalLLaMA, r/nvidia). Used in subreddit posts, subreddit info, and optional scoped search.

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

Keywords or phrases to search across Reddit or within the selected subreddits (e.g. "AI agents").

## `postUrls` (type: `array`):

Reddit post URLs, short links (redd.it/...), or post IDs for deep comment thread extraction.

## `usernames` (type: `array`):

Reddit usernames or profile URLs (e.g. karpathy) for user profile and submitted post extraction.

## `startUrls` (type: `array`):

Optional mixed list of Reddit URLs (subreddits, posts, search pages, or user profiles). Automatically normalized and routed.

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

Sort order for subreddit and user post feeds.

## `searchSort` (type: `string`):

Sort order when running in search mode.

## `commentSort` (type: `string`):

Sort order for comment threads.

## `timeRange` (type: `string`):

Time window applied to top posts and search queries.

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

Maximum number of posts to extract per subreddit, search query, or user.

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

Maximum number of comments to extract per post URL in comments mode.

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

Optional number of comments to extract for each post collected in subreddit, search, or user mode. Set to 0 to skip comment expansion.

## `includeUserProfile` (type: `boolean`):

When running in user mode, include a summary profile record with karma and account creation date.

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

Default managed network routing enabled automatically. For very large-scale collection, you can optionally select advanced routing groups in these settings.

## Actor input object example

```json
{
  "mode": "subreddit_posts",
  "subreddits": [
    "r/MachineLearning",
    "r/LocalLLaMA"
  ],
  "queries": [
    "AI agents"
  ],
  "sort": "hot",
  "searchSort": "relevance",
  "commentSort": "top",
  "timeRange": "week",
  "maxPosts": 50,
  "maxComments": 100,
  "maxCommentsPerPost": 0,
  "includeUserProfile": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

No description

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

No description

# 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": [
        "r/MachineLearning",
        "r/LocalLLaMA"
    ],
    "queries": [
        "AI agents"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alias_md5/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 = {
    "subreddits": [
        "r/MachineLearning",
        "r/LocalLLaMA",
    ],
    "queries": ["AI agents"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("alias_md5/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 '{
  "subreddits": [
    "r/MachineLearning",
    "r/LocalLLaMA"
  ],
  "queries": [
    "AI agents"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call alias_md5/reddit-scraper --silent --output-dataset

```

## MCP server setup

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