# Reddit Posts Scraper (`dbott23/reddit-posts-scraper`) Actor

Scrape Reddit posts, comments, and user histories without a Reddit account. Browse any subreddit, fetch post comments, or pull user submissions — no API keys required for subreddit and user scraping.

- **URL**: https://apify.com/dbott23/reddit-posts-scraper.md
- **Developed by:** [Darren S](https://apify.com/dbott23) (community)
- **Categories:** Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 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/platform/actors/running/actors-in-store#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 Posts Scraper

Scrape Reddit posts, comments, and user histories without needing a Reddit account. Browse any subreddit, fetch comments on specific posts, or pull all submissions from a user — no API keys required for basic use.

### What you can scrape

- **Subreddits** — Get the latest posts from any subreddit (e.g. `python`, `MachineLearning`, `investing`)
- **Post comments** — Fetch all top-level comments from any Reddit post URL
- **User posts** — Get recent submissions from any Reddit user
- **Keyword search** — Search posts within a subreddit by keyword (requires Reddit API credentials for global search)

### How to use

1. Set one or more inputs: **Subreddits**, **Post URLs**, **Usernames**, or **Search queries** (with a subreddit filter)
2. Optionally set **Max posts per source** (default 25, up to 500)
3. Optionally enable comments by setting **Max comments per post** > 0
4. Click **Start** and export the results as JSON, CSV, or Excel

### Output fields

Each scraped post includes:

| Field | Description |
|---|---|
| `id` | Reddit post ID |
| `url` | Full URL to the post |
| `title` | Post title |
| `text` | Post body text (for self posts) |
| `author` | Username of the poster |
| `subreddit` | Subreddit name |
| `score` | Upvote score |
| `numComments` | Number of comments |
| `createdAt` | Timestamp (ISO 8601) |
| `isVideo` | Whether the post is a video |
| `isSelf` | Whether it's a text post |
| `linkUrl` | External link URL (for link posts) |
| `thumbnail` | Thumbnail image URL |
| `flair` | Post flair text |
| `source` | Data source (`subreddit`, `search`, `user`, `comment`) |

### Global keyword search

To search Reddit globally by keyword (not restricted to a single subreddit), provide Reddit API credentials:

1. Go to [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps)
2. Create a **script** app (any name, redirect URI: `http://localhost`)
3. Enter the **Client ID**, **Client Secret**, your **Reddit username**, and **password** in the actor input

### Limitations

- Results are sourced from [Arctic Shift](https://arctic-shift.photon-reddit.com), a public Reddit archive — data may be up to a few hours old
- Without credentials, keyword search requires a specific subreddit filter
- Maximum 100 posts per subreddit/user per run (Reddit API limit)

### Cost

Pay-per-result pricing: **$1.00 per 1,000 posts** scraped.

# Actor input Schema

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

Subreddits to scrape posts from (e.g. 'python', 'r/MachineLearning'). The 'r/' prefix is optional.

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

Keywords or phrases to search Reddit posts for. Requires a 'Restrict search to subreddit' value, or Reddit API credentials for global search.

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

Direct links to Reddit posts. The scraper will fetch the comments for each post.

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

Reddit usernames to scrape recent posts from (e.g. 'spez' or 'u/spez').

## `maxPostsPerSource` (type: `integer`):

Maximum number of posts to fetch for each search query, subreddit, or username.

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

If greater than 0, fetch this many comments for each post. Set to 0 to skip comments.

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

How to sort posts when scraping subreddits.

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

How to sort keyword search results.

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

Time range for top/search results.

## `subredditFilter` (type: `string`):

Optional. Limit keyword search results to a specific subreddit (e.g. 'MachineLearning').

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

Client ID of your Reddit script app (https://www.reddit.com/prefs/apps). Required to run on Apify — Reddit blocks unauthenticated requests from cloud IPs. Create a free 'script' app at reddit.com/prefs/apps.

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

Client secret from your Reddit script app.

## `redditUsername` (type: `string`):

Your Reddit account username (without the u/ prefix).

## `redditPassword` (type: `string`):

Your Reddit account password.

## Actor input object example

```json
{
  "subreddits": [
    "python"
  ],
  "maxPostsPerSource": 25,
  "maxCommentsPerPost": 0,
  "sort": "hot",
  "searchSort": "relevance",
  "timeFilter": "all"
}
```

# 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("dbott23/reddit-posts-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("dbott23/reddit-posts-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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 dbott23/reddit-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=dbott23/reddit-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/iczT3SV1cAWxaKiDs/builds/CEqsNM78lSI4BLnui/openapi.json
