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

- **URL**: https://apify.com/alex\_claw/reddit-scraper.md
- **Developed by:** [Alex Claw](https://apify.com/alex_claw) (community)
- **Categories:** Automation, Social media
- **Stats:** 29 total users, 3 monthly users, 100.0% runs succeeded, 0 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?

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

Scrape Reddit subreddits for posts, comments, scores, awards, and engagement metrics. No API key or Reddit account required.

### Features

- **No API key needed** -- uses Reddit's public JSON API
- **Multiple sort options** -- hot, new, top (with time filters), rising
- **Post metadata** -- title, author, score, upvote ratio, flair, awards, NSFW/spoiler flags
- **Comments** -- optionally fetch comment trees with depth, scores, and reply counts
- **Pagination** -- automatically pages through results up to your specified limit
- **Multi-subreddit** -- scrape multiple subreddits in a single run
- **Rate-limit handling** -- built-in delays and exponential backoff on 429 responses
- **Proxy support** -- optional proxy configuration for large-scale scraping

### Input

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `subreddits` | array | *required* | Subreddit names (e.g., `["python", "programming"]`). No `r/` prefix needed. |
| `maxPostsPerSubreddit` | integer | 100 | Max posts to scrape per subreddit (1-5000) |
| `sort` | string | `"hot"` | Sort order: `hot`, `new`, `top`, `rising` |
| `topTimeFilter` | string | `"day"` | Time filter for `top` sort: `hour`, `day`, `week`, `month`, `year`, `all` |
| `includeComments` | boolean | false | Fetch comments for each post (increases run time) |
| `maxCommentsPerPost` | integer | 50 | Max comments per post (1-500, only used when `includeComments` is true) |
| `proxyConfiguration` | object | none | Proxy settings for requests |

#### Example Input

```json
{
    "subreddits": ["python", "programming", "learnpython"],
    "maxPostsPerSubreddit": 50,
    "sort": "top",
    "topTimeFilter": "week",
    "includeComments": true,
    "maxCommentsPerPost": 20
}
```

### Output

Each post is saved as a dataset item:

```json
{
    "subreddit": "python",
    "postId": "abc123",
    "title": "What's the best Python web framework in 2026?",
    "author": "pythonista42",
    "score": 1234,
    "upvoteRatio": 0.95,
    "numComments": 45,
    "createdUtc": "2026-02-24T10:00:00+00:00",
    "selfText": "I've been comparing Django, FastAPI, and...",
    "url": "https://www.reddit.com/r/python/comments/abc123/...",
    "permalink": "https://www.reddit.com/r/python/comments/abc123/...",
    "isVideo": false,
    "thumbnail": "self",
    "flair": "Discussion",
    "awards": 3,
    "postUrl": "https://www.reddit.com/r/python/comments/abc123/...",
    "domain": "self.python",
    "isNsfw": false,
    "isSpoiler": false,
    "isStickied": false,
    "comments": [
        {
            "commentId": "xyz789",
            "author": "webdev99",
            "body": "FastAPI for APIs, Django for full-stack...",
            "score": 567,
            "createdUtc": "2026-02-24T10:30:00+00:00",
            "depth": 0,
            "repliesCount": 12,
            "isStickied": false,
            "awards": 1
        }
    ]
}
```

When `includeComments` is false, the `comments` field is omitted.

### How It Works

This actor uses Reddit's public JSON API, which is available by appending `.json` to any Reddit URL:

- Subreddit listings: `https://www.reddit.com/r/{subreddit}/{sort}.json`
- Post comments: `https://www.reddit.com/r/{subreddit}/comments/{post_id}.json`

No authentication is required. The actor uses a descriptive User-Agent header as recommended by Reddit's API guidelines.

### Use Cases

- **Market research** -- monitor discussions about your product, competitors, or industry
- **Content analysis** -- find trending topics, popular content formats, engagement patterns
- **Sentiment analysis** -- collect posts and comments for NLP/sentiment pipelines
- **Lead generation** -- find users asking questions your product solves
- **Academic research** -- collect public discourse data for analysis
- **SEO research** -- discover what topics generate high engagement in your niche

### Pricing

Pay per result: $2.00 per 1,000 posts scraped (comments included at no extra cost).

### Important: Proxy Required

Reddit aggressively blocks datacenter IPs. **Residential proxy is recommended** for reliable scraping. Configure proxy in the input:

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

### Limitations

- **Proxy recommended** — Reddit blocks most datacenter IPs with 403 errors
- Only works with **public** subreddits (private/quarantined subreddits are not accessible)
- Reddit's pagination caps at approximately 1,000 posts per listing
- Rate limiting: the actor respects Reddit's rate limits with built-in delays
- Some posts/comments from deleted or suspended users may show `[deleted]`

# Actor input Schema

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

List of subreddit names to scrape (e.g., 'python', 'programming'). Do not include the r/ prefix.

## `maxPostsPerSubreddit` (type: `integer`):

Maximum number of posts to scrape per subreddit.

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

How to sort posts in the subreddit.

## `topTimeFilter` (type: `string`):

Time filter when sort is set to 'top'. Ignored for other sort options.

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

Fetch top-level comments for each post. This will significantly increase run time.

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

Maximum number of comments to fetch per post (only used when includeComments is true).

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

Proxy settings for requests. Recommended for large scrapes to avoid rate limiting.

## Actor input object example

```json
{
  "subreddits": [
    "python"
  ],
  "maxPostsPerSubreddit": 100,
  "sort": "hot",
  "topTimeFilter": "day",
  "includeComments": false,
  "maxCommentsPerPost": 50
}
```

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

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

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

```

## MCP server setup

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