# Reddit Posts Scraper — Comments, Replies & Subreddits (`khadinakbar/reddit-posts-scraper`) Actor

Extract Reddit posts, comments & subreddit data with no login required. Returns title, score, author, flair, body text, and dates MCP-ready. $2.00/1K.

- **URL**: https://apify.com/khadinakbar/reddit-posts-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, Automation, MCP servers
- **Stats:** 7 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 post scrapeds

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 Scraper – Posts, Comments & Subreddits

Reddit Scraper - Posts, Comments & Subreddits is an Apify Actor for extracting Reddit posts, comments, and subreddit data from a subreddit name, search query, or direct Reddit URL. It accepts one or more input sources, and each saved record represents a single post or comment in the dataset. The output includes fields such as title, author, subreddit, score, comment count, flair, body text, URLs, timestamps, and metadata flags, so you can use the result for analysis, automation, or AI workflows through Apify or Apify MCP.

### Best fit and connected workflows

This Actor fits workflows that start with Reddit communities, Reddit search results, or a specific Reddit page URL and end with structured records for downstream processing. It works well when you want to:

- collect posts from one or more subreddits with sort and time controls,
- search Reddit across communities by keyword or phrase,
- pull data from a Reddit post page, subreddit page, search page, or user profile page,
- include top comments for each scraped post,
- filter records by score, comments, flair, author, date, or NSFW status,
- connect Reddit content to analysis pipelines, dashboards, or AI agent tools.

### Practical scenario

A community researcher starts with the subreddit `learnpython`, wants recent high-engagement posts, and needs the author, flair, score, comment count, and created date for each result. They set `sort` to `top`, `time` to `week`, and `minScore` to focus on posts with stronger engagement. After the run, they review the dataset fields and use the `url` and `permalink` values to open the original Reddit discussion for follow-up reading and note-taking.

### Input fields

| Field | Type | Purpose |
|---|---:|---|
| `subreddits` | array | Subreddit names, with or without `r/`, used as the input source for subreddit-based scraping. |
| `searchQueries` | array | Search terms for Reddit-wide search across communities. |
| `startUrls` | array | Direct Reddit URLs, including subreddit, post, search, or user profile pages. |
| `redditClientId` | string | Reddit app client\_id for cloud runs. |
| `sort` | string | Sorting mode: hot, new, top, rising, controversial, or relevance. |
| `time` | string | Time filter for top, controversial, and search results. |
| `maxResults` | integer | Total maximum number of posts saved across all sources. |
| `includeComments` | boolean | Saves top comments for each scraped post as separate dataset records. |
| `maxCommentsPerPost` | integer | Maximum comments to scrape per post when comments are enabled. |
| `includeNSFW` | boolean | Includes records marked as NSFW. |
| `minScore` | integer | Keeps only posts with at least this score. |
| `maxScore` | integer | Keeps only posts with at most this score. |
| `minComments` | integer | Keeps only posts with at least this many comments. |
| `flairFilter` | string | Keeps only posts with an exact flair text. |
| `authorFilter` | string | Keeps only posts from one Reddit username. |
| `postDateLimit` | string | Keeps only posts created after the given date. |
| `proxyConfiguration` | object | Proxy settings for Reddit scraping. |

#### Focused JSON input example

```json
{
  "subreddits": ["programming", "learnpython"],
  "sort": "top",
  "time": "week",
  "maxResults": 50,
  "includeComments": true,
  "maxCommentsPerPost": 20,
  "minScore": 100,
  "includeNSFW": false
}
```

### Output fields

| Field | Type | Meaning |
|---|---:|---|
| `post_id` | string | Reddit post identifier. |
| `title` | string | Post title. |
| `author` | string | Reddit username associated with the record. |
| `subreddit` | string | Subreddit name. |
| `url` | string | Canonical post URL. |
| `permalink` | string | Reddit permalink path. |
| `body_text` | string | Post body text. |
| `score` | integer | Net score. |
| `upvote_ratio` | number | Upvote ratio. |
| `num_comments` | integer | Comment count. |
| `flair` | string | Flair text. |
| `domain` | string | Domain associated with the post. |
| `external_url` | string | Outbound URL for link posts. |
| `thumbnail_url` | string | Thumbnail URL. |
| `is_nsfw` | boolean | NSFW flag. |
| `is_video` | boolean | Video flag. |
| `is_self` | boolean | Self-post flag. |
| `created_at` | string | Original creation timestamp. |
| `scraped_at` | string | Time the record was saved. |
| `source_url` | string | Input URL that led to the record. |
| `data_type` | string | Record type, such as `post` or `comment`. |

#### Illustrative dataset record

```json
{
  "post_id": "t3_1abc23",
  "title": "What's the practical way to learn Python in 2025?",
  "author": "curious_dev",
  "subreddit": "learnprogramming",
  "url": "https://www.reddit.com/r/learnprogramming/comments/abc123/",
  "permalink": "/r/learnprogramming/comments/abc123/whats_the_best_way/",
  "body_text": "I've been coding JavaScript for 2 years and want to branch out...",
  "score": 482,
  "upvote_ratio": 0.97,
  "num_comments": 84,
  "flair": "Question",
  "domain": "self.learnprogramming",
  "external_url": null,
  "thumbnail_url": null,
  "is_nsfw": false,
  "is_video": false,
  "is_self": true,
  "created_at": "2025-11-15T14:32:00.000Z",
  "scraped_at": "2026-04-09T10:00:00.000Z",
  "source_url": "https://www.reddit.com/r/learnprogramming/comments/abc123/",
  "data_type": "post"
}
```

### How it works

This Actor accepts subreddit names, search queries, or direct Reddit URLs as input. It supports sorting and time filtering for posts, and it can save top comments as separate dataset records when comment scraping is enabled. The input schema also includes score, comment count, flair, author, date, NSFW, and proxy controls. The dataset schema exposes a table view with title, author, subreddit, score, comments, flair, created date, URL, and record type.

### Pricing

This Actor uses pay per event pricing on Apify. The pricing model includes an Actor start event and a primary event for each successfully scraped post saved to the dataset. Apify platform usage is billed separately according to your account and execution settings, so the full cost depends on both event volume and platform usage. For current details, see the live Pricing tab in the Apify Console.

For an example, a run that saves one hundred posts charges one hundred Post scraped events, plus the Actor start event and the Apify platform usage for the run.

### Use with AI agents (MCP)

This Actor is an Apify Actor that can be used through Apify MCP. It is suited for agent workflows that need structured Reddit posts and comments from a subreddit, query, or URL.

The exact Actor identity is `khadinakbar/reddit-posts-scraper`.

> Scrape recent posts from `learnpython`, include comments, and return the title, author, score, flair, comment count, created date, and source URL for each record.

When you review the output, use `data_type` to separate posts from comments, `source_url` to trace each record back to the input, and `scraped_at` to understand when the dataset was collected. Comment records are saved as separate dataset items when `includeComments` is enabled. Pagination can expand the dataset across multiple pages, and `maxResults` controls the total number of saved posts across all sources. Event-based pricing means each successfully scraped post contributes to the billable event count, while filtered-out posts are excluded from Post scraped charges.

### Apify API example

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

const client = new ApifyClient({
  token: process.env.APIFY_TOKEN,
});

const run = await client.actor('khadinakbar/reddit-posts-scraper').call({
  subreddits: ['programming', 'learnpython'],
  sort: 'top',
  time: 'week',
  maxResults: 20,
  includeComments: true,
  maxCommentsPerPost: 10,
});

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

### Best results and outcome guidance

Use a single source type per run when possible: subreddit names for community monitoring, search queries for topic discovery, and direct URLs for targeted page extraction. Pair `sort: top` with `time: week` or `month` when you want high-engagement posts, and use `sort: new` with `postDateLimit` for recency-based collection. If you need comment context, enable `includeComments` and set `maxCommentsPerPost` to a focused number that matches the depth you need. For cloud runs, provide `redditClientId` when Reddit access through Apify cloud IPs is part of your setup, and use the proxy configuration that fits your workload.

### Focused standalone workflow

Reddit Scraper – Posts, Comments & Subreddits is designed as a focused standalone workflow for the public input and structured output contract described above.

### Design note

I found that the dataset schema includes a clear `data_type` field, which makes it straightforward to distinguish posts from comments in downstream processing.

### FAQ

**Which input should I use if I already have a subreddit name?**\
Use `subreddits`. That source is designed for subreddit-based scraping and uses the selected sort and time settings.

**Which input should I use if I have a Reddit search phrase?**\
Use `searchQueries`. Each query runs a Reddit-wide search and can be combined with sorting and time filtering.

**Which input should I use if I have a full Reddit link?**\
Use `startUrls`. It accepts subreddit pages, post pages, search pages, and user profile pages.

**How do I get comments alongside posts?**\
Set `includeComments` to `true`, then set `maxCommentsPerPost` to the number of comments you want per post.

**How can I focus on higher-engagement posts?**\
Use `minScore`, `minComments`, or both. You can also combine `sort: top` with a time filter.

**How can I route this Actor into an MCP workflow?**\
Use the Actor through Apify MCP and refer to `khadinakbar/reddit-posts-scraper` as the tool identity when configuring your agent.

### Responsible use

This Actor is intended for publicly available Reddit content and structured analysis workflows. Keep usage aligned with Reddit's terms, applicable privacy rules, and the policies of the environment where you process the data. Review the fields you collect, especially when combining usernames, timestamps, comments, and external URLs in downstream systems.

# Actor input Schema

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

Use this field when the user provides subreddit names (with or without r/ prefix). Each subreddit fetches posts using the Sort and Time Filter settings. Leave empty if using Search Queries or Start URLs instead. Examples: 'programming', 'r/learnpython', 'MachineLearning'.

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

Use this field when the user describes a topic or keyword to search across all of Reddit. Each query runs a full Reddit search. Do NOT use this when the user provides a subreddit name — use Subreddits instead. Examples: 'best laptop 2025', 'AI news', 'side hustle ideas'.

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

Use this field when the user provides a specific Reddit URL. Supports any Reddit URL: subreddit pages, post pages, search pages, or user profile pages. Examples: https://www.reddit.com/r/datascience/, https://www.reddit.com/r/programming/top/.

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

Optional Reddit app client\_id for OAuth. Needed when running on cloud servers (Apify cloud IPs are blocked by Reddit). Get one free in 2 min: go to reddit.com/prefs/apps → create app → choose "installed app" → copy the ID shown under the app name. No user login or secret required.

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

How to sort posts. 'hot' = currently popular. 'new' = most recent. 'top' = highest score (use with Time Filter). 'rising' = gaining momentum. 'controversial' = most debated. 'relevance' = best match for search queries only.

## `time` (type: `string`):

Time range for 'top', 'controversial', and search results. Ignored for 'hot', 'new', and 'rising'. Options: hour, day, week, month, year, all.

## `maxResults` (type: `integer`):

Maximum number of posts to save in total across all sources. Each page returns up to 100 posts. Set to 0 for unlimited (up to Reddit's per-source caps). Default: 50.

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

If enabled, scrapes the top comments for each post scraped. Significantly increases run time and data output. Each comment is saved as a separate record with data\_type: 'comment'.

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

Maximum number of comments to scrape per post (only when Include Comments is enabled). Comments are flattened from nested threads. Default: 20.

## `includeNSFW` (type: `boolean`):

Include posts marked as NSFW (Not Safe For Work / 18+). Disabled by default.

## `minScore` (type: `integer`):

Only include posts with at least this many upvotes. Leave empty for no minimum. Useful for filtering to only high-quality posts.

## `maxScore` (type: `integer`):

Only include posts with at most this many upvotes. Leave empty for no maximum.

## `minComments` (type: `integer`):

Only include posts with at least this many comments. Leave empty for no minimum.

## `flairFilter` (type: `string`):

Only include posts with this exact flair text. Case-sensitive. Example: 'Question', 'Discussion', 'Tutorial'. Leave empty to include all flairs.

## `authorFilter` (type: `string`):

Only include posts from this specific Reddit username (without u/). Leave empty to include all authors.

## `postDateLimit` (type: `string`):

Only include posts created after this date. Format: YYYY-MM-DD or ISO 8601 (e.g., 2025-01-01). Pagination stops automatically when posts older than this date are encountered.

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

Proxy settings for Reddit scraping. Reddit blocks some datacenter IPs. Using Apify Residential proxies improves reliability significantly. Highly recommended for large-scale runs.

## Actor input object example

```json
{
  "subreddits": [
    "programming",
    "learnpython"
  ],
  "searchQueries": [],
  "startUrls": [],
  "sort": "hot",
  "time": "all",
  "maxResults": 50,
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "includeNSFW": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Dataset containing all scraped Reddit posts and comments. Each item includes title, author, subreddit, score, comment count, flair, body text, URLs, timestamps, and metadata flags.

# 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": [
        "programming",
        "learnpython"
    ],
    "searchQueries": [],
    "startUrls": [],
    "sort": "hot",
    "time": "all",
    "maxResults": 50,
    "includeComments": false,
    "maxCommentsPerPost": 20,
    "includeNSFW": false,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/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": [
        "programming",
        "learnpython",
    ],
    "searchQueries": [],
    "startUrls": [],
    "sort": "hot",
    "time": "all",
    "maxResults": 50,
    "includeComments": False,
    "maxCommentsPerPost": 20,
    "includeNSFW": False,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/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": [
    "programming",
    "learnpython"
  ],
  "searchQueries": [],
  "startUrls": [],
  "sort": "hot",
  "time": "all",
  "maxResults": 50,
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "includeNSFW": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call khadinakbar/reddit-posts-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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