# Reddit Posts & Subreddit Comment Scraper (`taroyamada/reddit-data-scraper`) Actor

Scrape Reddit posts and nested comment trees from specific subreddits. Proxy-aware fallback for the legacy public surface. Sort by hot, top, new, rising with optional comment depth control.

- **URL**: https://apify.com/taroyamada/reddit-data-scraper.md
- **Developed by:** [naoki anzai](https://apify.com/taroyamada) (community)
- **Categories:** Social media, SEO tools, News
- **Stats:** 8 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 public reddit result rows

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/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 Scraper (Legacy Fallback)

Dive deep into niche communities with the Subreddit & Comment Scraper, a powerful extraction utility built for proxy-sensitive environments where users control their own access setup. It serves as a legacy fallback for workflows that require explicit proxy configuration and list-based subreddit collection. It can scrape high-volume subreddits, pulling down both parent posts and the complex, nested comment trees that contain valuable user opinions and sentiment.

Research teams, community managers, and OSINT analysts utilize this scraper to conduct historical audits of specific subreddits, track viral topics, and analyze authentic user feedback. By specifying target subreddits and applying granular sort filters (such as Top of All Time or Newest), you can precisely control what data enters your pipeline. The actor is intended for compliant research on public subreddit pages, with clear warnings when Reddit blocks datacenter traffic.

Your resulting datasets will include rich, structured details: accurate timestamps, total upvotes, author handles, full comment bodies, and post URLs. This allows for seamless downstream analysis of social trends. Note that this is a legacy-focused actor prioritizing proxy-aware subreddit flows. If your primary goal involves setting up recurring keyword alerts across the entire site, or broad user-profile scraping, our newer Reddit All-in-One Scraper is recommended. However, for specialized subreddit extraction where you control the residential proxies and demand a straightforward, list-based collection method, this scraper remains a highly effective and fully maintained choice.

> 📄 **Live sample output**: see [`docs/sample-output.json`](docs/sample-output.json) for a representative dataset captured from a real run of this actor. Use it to validate the schema before subscribing.

### Store Quickstart

- Start with `store-input.example.json` or **Legacy Quickstart (Proxy-aware)**. If running on Apify infrastructure, configure Residential proxy first.
- Then use the legacy ladder from `store-input.templates.json`:
  1. **Legacy Quickstart (Proxy-aware)**
  2. **Legacy Recurring Refresh (Proxy-aware)**
  3. **Legacy Webhook Handoff (Proxy-aware)**
- Buyer-facing proof assets live in `sample-output.example.json` and `live-proof.example.json`.
- New recurring or pack-first users should still move to `reddit-all-in-one-scraper` / `reddit-keyword-monitor-alerts` once the legacy need is proven.

### Legacy Scope

- Subreddit-based post scraping
- Optional comment extraction
- Basic sort/time controls
- No recurring snapshot diff monitoring

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| subreddits | string\[] | (required) | Subreddit names (max 20) |
| sort | string | hot | hot, new, top, rising |
| maxItems | integer | 25 | Max posts per subreddit (1-500) |
| includeComments | boolean | false | Include nested comments |

#### Input Example

```json
{
  "subreddits": ["programming", "technology"],
  "sort": "hot",
  "maxItems": 50,
  "includeComments": true
}
```

### Input Examples

#### Example: Top of all time in a subreddit

```json
{
  "subreddits": [
    "DataIsBeautiful"
  ],
  "sort": "top",
  "time": "all",
  "maxPosts": 25,
  "includeComments": true,
  "commentDepth": 2
}
```

#### Example: Newest posts (multi-subreddit)

```json
{
  "subreddits": [
    "MachineLearning",
    "datascience"
  ],
  "sort": "new",
  "maxPosts": 50,
  "includeComments": false
}
```

#### Example: Specific post + comment tree

```json
{
  "posts": [
    "https://old.reddit.com/r/programming/comments/abc123/"
  ],
  "includeComments": true,
  "commentDepth": 5
}
```

### Output

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Reddit post ID |
| `title` | string | Post title |
| `author` | string | Username of poster |
| `subreddit` | string | Subreddit name |
| `url` | string | Permalink to post |
| `score` | integer | Upvote score |
| `numComments` | integer | Comment count |
| `createdAt` | string | ISO timestamp |
| `selftext` | string | Post body (for text posts) |
| `comments` | object\[] | Top comments (if includeComments enabled) |

#### Output Example

```json
{
  "title": "New JavaScript framework released",
  "author": "dev_user",
  "score": 1250,
  "url": "https://example.com/framework",
  "selftext": "Detailed writeup inside...",
  "subreddit": "programming",
  "createdUtc": 1712345678,
  "numComments": 342,
  "comments": [{"author": "...", "body": "..."}]
}
```

### API Usage

Run this actor programmatically using the Apify API. Replace `YOUR_API_TOKEN` with your token from [Apify Console → Settings → Integrations](https://console.apify.com/account/integrations).

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/taroyamada~reddit-data-scraper/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "subreddits": ["programming", "technology"], "sort": "hot", "maxItems": 50, "includeComments": true }'
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("taroyamada/reddit-data-scraper").call(run_input={
  "subreddits": ["programming", "technology"],
  "sort": "hot",
  "maxItems": 50,
  "includeComments": true
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

#### JavaScript / Node.js

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

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const run = await client.actor('taroyamada/reddit-data-scraper').call({
  "subreddits": ["programming", "technology"],
  "sort": "hot",
  "maxItems": 50,
  "includeComments": true
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

### Tips & Limitations

#### ⚠️ Proxy Required on Apify Datacenter

Reddit blocks many shared datacenter IPs. Without proxy setup on Apify infra, runs can fail with `runStatus: all_blocked` and 0 posts.

**To fix**: enable Apify Residential proxy (`APIFY_USE_APIFY_PROXY=true`, `APIFY_PROXY_GROUPS=RESIDENTIAL`) or provide your own residential `PROXY_URL`.

#### Legacy Positioning

- This actor is not the recommended first choice for new pack users.
- Prefer `reddit-all-in-one-scraper` for research/backfill and `reddit-keyword-monitor-alerts` for recurring alerting.

### FAQ

**Is this the main Reddit Intelligence Pack actor?**

No. This is the legacy fallback actor. New recurring monitor workflows should use `reddit-keyword-monitor-alerts`.

**Does Reddit block this?**

Yes, frequently on datacenter IPs. Residential proxy is typically required on Apify cloud.

**What is `runStatus` in output?**

| Value | Meaning |
|-------|---------|
| `ok` | All subreddits fetched successfully |
| `partial` | Some subreddits succeeded; others were blocked/errored |
| `all_blocked` | Every subreddit was blocked — no posts collected (exit code 1) |

### Related Actors

Reddit Intelligence Pack (recommended path):

- [🚨 Reddit Keyword Monitor Alerts](https://apify.com/taroyamada/reddit-keyword-monitor-alerts) — Hero recurring monitor for net-new alerts.
- [📡 Reddit All-in-One Scraper](https://apify.com/taroyamada/reddit-all-in-one-scraper) — Research/backfill companion.
- [📰 Article Extractor](https://apify.com/taroyamada/article-content-extractor) — Linked URL cleanup add-on.
- [🐘 Mastodon Hashtag & Account Scraper](https://apify.com/taroyamada/mastodon-activitypub-monitor) — Federated social listening (Twitter/X-free), same query/result shape on the Fediverse.

### Cost

**Pay Per Event**:

- `actor-start`: $0.01 (flat fee per run)
- `dataset-item`: $0.003 per output item

**Example**: 1,000 items = $0.01 + (1,000 × $0.003) = **$3.01**

No subscription required — you only pay for what you use.

> 💾 **Save it for later**: click the bookmark icon at the top of the Apify Store page if you'd like to come back to it. Bookmarks help other engineers find this actor via Apify's discovery surfaces.

### ⭐ Was Reddit Posts & Subreddit Comment Scraper useful for your Reddit research?

If this actor saved you time, **[please leave a 5★ rating on Apify Store](https://apify.com/taroyamada/reddit-data-scraper/reviews)** — it takes 10 seconds, helps other engineers and analysts discover it, and keeps updates free.

Have a feature request, bug, or sample workflow you'd like to share? **[Open an issue](https://apify.com/taroyamada/reddit-data-scraper/issues)** — we read every one and use them to prioritise the next release.

# Actor input Schema

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

Legacy fallback input. On Apify cloud, enable Residential proxy before running.

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

Sort order for results

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

Time window filter (hour, day, week, month, year, all)

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

Maximum number of items to return

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

Include comments in output

## `timeoutMs` (type: `integer`):

Request timeout in milliseconds

## `maxChargeUsd` (type: `number`):

Safety cap for this run. Results beyond the cap are kept in output as no-charge limit\_reached rows.

## `delivery` (type: `string`):

Where to send results: dataset or webhook

## `webhookUrl` (type: `string`):

Webhook URL to POST results to (if delivery=webhook)

## `dryRun` (type: `boolean`):

Emit a QA-safe sample without contacting Reddit or billing. Turn off only when running with an allowed proxy setup.

## Actor input object example

```json
{
  "subreddits": [
    "javascript"
  ],
  "sort": "hot",
  "timeFilter": "all",
  "maxItems": 100,
  "includeComments": false,
  "timeoutMs": 15000,
  "maxChargeUsd": 1,
  "delivery": "dataset",
  "dryRun": true
}
```

# 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": [
        "javascript"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("taroyamada/reddit-data-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": ["javascript"] }

# Run the Actor and wait for it to finish
run = client.actor("taroyamada/reddit-data-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": [
    "javascript"
  ]
}' |
apify call taroyamada/reddit-data-scraper --silent --output-dataset

```

## MCP server setup

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