# Reddit Scraper (`daddyapi/reddit-scraper`) Actor

Cheap, fast and reliable . Bring your own proxies

- **URL**: https://apify.com/daddyapi/reddit-scraper.md
- **Developed by:** [DaddyAPI](https://apify.com/daddyapi) (community)
- **Categories:** Automation, Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 14 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

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?

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, Robust, and Cost-Effective.** Scrape Reddit posts from any subreddit with advanced sorting, smart pagination, and proxy flexibility.

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-blue?style=for-the-badge\&logo=apify)](https://apify.com/store)
[![Node.js](https://img.shields.io/badge/Node.js-v22-green?style=for-the-badge\&logo=node.js)](https://nodejs.org/)

### 🚀 Why this scraper?

Many Reddit scrapers are slow, heavy, or get blocked easily. This actor is designed for **performance** and **stability**.

1. **Lightweight:** Uses Cheerio (raw HTTP) instead of heavy browsers, making it 10x cheaper to run.
2. **Smart Pagination:** Automatically reverse-engineers Reddit's internal pagination to fetch "more posts" efficiently.
3. **Proxy Freedom:** Works with Datacenter proxies (cheap) and Residential proxies (reliable).
4. **Rich Data:** Extracts detailed post metrics (upvotes, comments), media links, and text content.

**Perfect for:**

- 📈 **Trend Analysis:** Monitor trending topics.
- 📢 **Sentiment Analysis:** Analyze user discussions and opinions.
- 🤖 **AI Training:** Gather diverse text datasets for LLMs.
- 📢 **Brand Monitoring:** Track mentions of your brand across communities.

***

### 📖 How to Use

#### Option 1: Apify Console (No Coding)

1. Go to the **Input** tab.
2. Enter the **Subreddit Name** (e.g., `technology`, `funny`, `dataisbeautiful`).
3. (Optional) Select **Sort By** (`Hot`, `New`, `Top`, `Rising`).
4. **Proxy Selection:**
   - Use **Datacenter** (Default) for speed/cost.
   - Switch to **Residential** if you see "403 Forbidden" errors.
5. Click **Start**.
6. Download your data in JSON, CSV, or Excel.

#### Option 2: API (Developers)

You can trigger this actor programmatically via REST API, Python, or Node.js.

##### Input Payload (JSON)

```json
{
    "subreddit": "technology",
    "sort": "hot", 
    // Options: "hot", "new", "top", "rising"
    
    "maxRequestsPerCrawl": 1,
    // 1 Request ≈ 1 Page (or batch of ~25 posts). 
    // Set to 2 for ~28 posts. Set to 10 for ~200+ posts.

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

##### 🐍 Python Example (Simple & Clean)

This script runs the scraper and saves the results to a local file.

```python
import json
from apify_client import ApifyClient

## 1. Configuration
APIFY_TOKEN = 'YOUR_APIFY_TOKEN'
ACTOR_ID = 'daddyapi/reddit-scraper'

client = ApifyClient(APIFY_TOKEN)

## 2. Define Input
run_input = {
    "subreddit": "artificial",
    "sort": "top",
    "maxRequestsPerCrawl": 1, # Fetches approx 50-75 posts
    "proxyConfiguration": {
        "useApifyProxy": True,
        # Uncomment below to use Residential proxies if Datacenter gets blocked
        # "apifyProxyGroups": ["RESIDENTIAL"] 
    }
}

print(f"🚀 Starting scraper for r/{run_input['subreddit']}...")

## 3. Run Actor
run = client.actor(ACTOR_ID).call(run_input=run_input)

if not run:
    print("❌ Failed to start run.")
    exit(1)

print(f"✅ Run finished! Status: {run['status']}")

## 4. Fetch & Save Results
dataset_client = client.dataset(run["defaultDatasetId"])
items = dataset_client.list_items().items

filename = "reddit_data.json"
with open(filename, "w", encoding="utf-8") as f:
    json.dump(items, f, indent=2, ensure_ascii=False)

print(f"💾 Saved {len(items)} posts to {filename}")
```

***

### 🔒 Proxy Configuration (Bring Your Own Proxies)

This actor is fully compatible with **Apify Proxy** (Datacenter & Residential) and **Custom Proxies**.

#### 1. Datacenter Proxies (Cost-Effective)

Great for high-volume users who want to control costs. Note that Reddit sometimes blocks these.

```json
{
    "proxyConfiguration": {
        "useApifyProxy": true
    }
}
```

#### 2. Residential Proxies (Best Reliability)

**Recommended.** Residential proxies are harder to block and provide the highest success rate. Use this if you are getting empty results or 403 errors.

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

#### 3. Bring Your Own Proxies (Custom URLs)

If you have proxies from an external provider (Webshare, BrightData, Smartproxy, etc.), you can pass the connection strings directly.

```json
{
    "proxyConfiguration": {
        "useApifyProxy": false,
        "proxyUrls": [
            "http://username:password@my-proxy.example.com:8000",
            "http://username:password@my-proxy-2.example.com:8000"
        ]
    }
}
```

***

### 📊 Data Output

The scraper returns structured data for every post:

```json
{
  "post_kind": "t3",
  "author": "TechEnthusiast",
  "author_id": "t2_8a7b3c",
  "time_posted": "2023-10-27T10:00:00.000Z",
  "title": "The Future of AI in 2026",
  "body_text": "Here is a deep dive into what we can expect...",
  "permalink": "/r/technology/comments/18x9z/the_future_of_ai/",
  "comment_count": "452",
  "score": "1500",
  "content_href": "https://i.redd.it/example_image.jpg",
  "external_links": ["https://openai.com/blog", "https://wired.com/ai-news"]
}
```

***

### 🛡️ Troubleshooting

- **Why am I only getting 3 posts?**
  - Reddit's initial page load is small. The scraper simulates scrolling by fetching subsequent batches.

- **"Request blocked (403)" Error?**
  - Reddit aggressively blocks Datacenter IPs.
  - **Fix:** Switch to **Residential Proxies** in the input configuration.

- **Scraper stops early?**
  - Ensure you have enough memory allocated (256MB is usually enough, but 512MB is safer for very long crawls).

***

#### ⚖️ Legal & Ethics

This scraper is for educational and analytical purposes. Please respect Reddit's Terms of Service and `robots.txt`. Do not use this tool to spam communities or overload their servers. Use responsible rate limits.

# Actor input Schema

## `subreddit` (type: `string`):

Name of the subreddit to scrape (e.g., 'technology', 'funny').

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

Sorting order for the posts.

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

Specific Reddit URLs to scrape. If provided, 'Subreddit' input is ignored.

## `maxRequestsPerCrawl` (type: `integer`):

Maximum number of 'scrolls' or batches to fetch. 2 requests ≈ 28 posts (Initial + 1 Scroll).

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

Select proxies. Datacenter proxies are default (cheaper) but OFTEN BLOCKED by Reddit (403 errors). Use RESIDENTIAL proxies for reliable results.

## Actor input object example

```json
{
  "subreddit": "technology",
  "sort": "hot",
  "maxRequestsPerCrawl": 2,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `overview` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("daddyapi/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 = {}

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

```

## MCP server setup

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