# Reddit Scraper - Posts & Comments, No Login (`lanternlab318/reddit-scraper`) Actor

- **URL**: https://apify.com/lanternlab318/reddit-scraper.md
- **Developed by:** [Lantern Lab](https://apify.com/lanternlab318) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 95.2% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.49 / 1,000 posts

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 — Posts & Comments from Subreddits, Search and URLs

A Lantern Lab Actor. Collect public Reddit posts from subreddits (Hot, New, Top, Rising or Controversial, with a time range), from keyword search across Reddit, or from post URLs — and optionally their comments. Every post comes with Reddit's own ID, URL, title, text, subreddit, publish time, score, comment count, author and outbound link; every comment with its ID, parent ID, depth, text, score, publish time and author. No Reddit login, no account, no API key of your own.

**Price:** pay per result, one price for everyone:

| Event | Price | When it is charged |
|---|---|---|
| `post` | **USD 1.49 per 1,000 posts** | One per post row. |
| `comment` | **USD 0.49 per 1,000 comments** | One per comment row. |
| `run-start` | **USD 0.005 per run** | Once per run, and only when the run writes at least one charged row. |

Empty results, missing or private subreddits, NSFW posts that were skipped, blocked or failed inputs, duplicates, the per-input status rows and the run summary are free. A run that collects nothing costs nothing.

### What you get

```json
{
  "recordType": "post",
  "postId": "1xjjr9z",
  "fullname": "t3_1xjjr9z",
  "url": "https://www.reddit.com/r/programming/comments/1xjjr9z/i_miss_the_part_of_programming_where_i_figure_it/",
  "title": "I miss the part of programming where I figure it out myself",
  "text": "Getting working code quickly is useful. It doesn’t always give me the satisfaction of solving the problem. …",
  "subreddit": "programming",
  "subredditId": "t5_2fwo",
  "publishedAt": "2026-10-30T16:17:18.000Z",
  "score": 1125,
  "upvoteRatio": 0.95,
  "commentCount": 289,
  "authorUsername": "Overall-Beach-9801",
  "externalUrl": "https://medium.com/@behind-the-stack/ai-has-made-coding-boring-adb1826134b0?sk=2bba5636bf991e6b22f62ddbfa164ae8",
  "domain": "medium.com",
  "isSelf": false,
  "isNsfw": false,
  "flair": null,
  "commentsCollected": 15,
  "commentsComplete": true,
  "inputKind": "subreddit",
  "inputValue": "programming",
  "rank": 1,
  "partial": false,
  "collectedAt": "2026-10-31T06:39:18.989Z"
}
```

```json
{
  "recordType": "comment",
  "commentId": "19rvzefqqgcrk",
  "fullname": "t1_19rvzefqqgcrk",
  "postId": "1xjjr9z",
  "parentId": "t1_19rvzaz51amqp",
  "depth": 1,
  "url": "https://www.reddit.com/r/programming/comments/1xjjr9z/comment/19rvzefqqgcrk/",
  "text": "I totally get your point but the article is more of a rant because I love cod …",
  "score": 29,
  "publishedAt": "2026-10-30T16:22:54.893Z",
  "authorUsername": "Overall-Beach-9801",
  "subreddit": "programming",
  "collectedAt": "2026-10-31T06:53:13.707Z"
}
```

`publishedAt` is Reddit's publish time; `collectedAt` is when this run read the row. `parentId` is the comment (`t1_…`) or the post (`t3_…`) a comment replies to, so the thread can be rebuilt exactly. A field Reddit does not show is `null` — never guessed: a deleted author is `null`, a deleted comment's text is `null`, a score Reddit hides is `null`.

### Input

Give it subreddits, search queries, post URLs, or any mix.

| Field | Default | Meaning |
|---|---|---|
| `subreddits` | — | `programming`, `r/programming` or a subreddit URL, one per line. |
| `sort` | `hot` | `hot`, `new`, `top`, `rising` or `controversial`. |
| `timeRange` | `week` | For `top` and `controversial`: `hour`, `day`, `week`, `month`, `year`, `all`. |
| `searchQueries` | — | Keywords to search all of Reddit for, one per line. |
| `searchSort` / `searchTimeRange` | `relevance` / `all` | Search order (`relevance`, `hot`, `top`, `new`, `comments`) and period. |
| `postUrls` | — | `https://www.reddit.com/r/…/comments/<id>/…`, `https://redd.it/<id>` or `t3_<id>`. |
| `maxPosts` | 25 | Hard limit per subreddit and per search query. Never exceeded and never over-charged. |
| `maxCommentsPerPost` | 0 (off) | Hard limit on comment rows per post. |
| `commentSort` | `top` | `top`, `new`, `old`, `controversial` or `confidence` (Reddit's "Best"). |
| `includeNsfw` | false | NSFW posts are skipped (and free) unless this is on. |
| `maxUpstreamRequests` | derived | Hard ceiling on requests to Reddit. |

```json
{
  "subreddits": ["programming"],
  "sort": "top",
  "timeRange": "week",
  "maxPosts": 25,
  "maxCommentsPerPost": 20
}
```

### Output

Three row types share the dataset; the **Posts**, **Comments** and **Input status** views split them.

- `post` — one per post, deduplicated across the whole run by Reddit's post ID. `commentsCollected` and `commentsComplete` say how many comment rows the post got and whether that is everything that was asked for.
- `comment` — one per comment, deduplicated by comment ID, in Reddit's thread order (a reply follows its parent).
- `input_status` — one per subreddit, query and post URL, never charged: posts and comments returned, duplicates and NSFW posts skipped, and either `emptyReason` (nothing to collect) or `partial: true` with a `partialReason` (incomplete).
- `RUN_SUMMARY` — the last row, also saved in the key-value store.

#### Empty is not the same as incomplete

These are final answers from Reddit and are **not** partial: `emptyReason` `not_found` (no such subreddit or post), `not_public` (private, quarantined or banned community), `nsfw_filtered` (every post was NSFW) and `no_results`.

These mean the result is **incomplete** and are `partial: true`: `blocked` (Reddit refused the requests, retries included), `upstream_error`, `unexpected_response` (Reddit changed its pages), `comments_incomplete` (comments of a post could not all be read), `upstream_request_cap`, `charge_limit_reached` and `not_collected` (the run stopped before this input). A run where every input was refused fails instead of finishing with zero rows.

### Limits

- Only what a signed-out visitor sees on Reddit. Private and quarantined communities, user profile histories and anything behind a login are not collected. Media files are not downloaded; links to them are in `externalUrl`.
- Reddit lists up to about 1,000 posts per listing or search, and some listings hold fewer.
- Comments are read the way the page loads them, including threads Reddit folds behind "more replies", up to your `maxCommentsPerPost`. A post where Reddit still offered more than the run read is marked `commentsComplete: false`.
- Personal data is kept to the public username. No profile pictures, karma or other profile fields.
- Reddit refuses most data-center IPs, so runs use Apify residential proxy by default.

### Development

```bash
npm install
npm test
```

Tests run offline against recorded Reddit responses in `test/fixtures/`.

# Actor input Schema

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

Subreddits to read, one per line: a name ("programming"), "r/programming" or a subreddit URL. Each one is read in the sort order below. Private, quarantined and banned communities are not visible signed out; they are reported as such and cost nothing.

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

Which listing of each subreddit to read.

## `timeRange` (type: `string`):

Period the Top and Controversial listings cover. Ignored for the other sorts.

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

Keywords to search all of Reddit for, one per line. Each query is searched separately and its posts are labelled with it. A post that several of your inputs return is written and charged once.

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

Order of search results.

## `searchTimeRange` (type: `string`):

Period the search covers.

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

Specific posts to collect, one per line: https://www.reddit.com/r/<sub>/comments/<id>/..., https://redd.it/<id> or t3\_<id>. Turn on comments below to get their comments too.

## `maxPosts` (type: `integer`):

Upper bound on the posts one subreddit or one search query may produce. Never exceeded: with 25 you get at most 25 post rows per input and pay for at most 25 posts. Reddit lists up to about 1,000 posts per listing.

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

Also collect up to this many comments of every post, as separate rows with their parent ID and depth. 0 turns comments off. Never exceeded. Each post row says how many comments were collected and whether that is everything that was asked for.

## `commentSort` (type: `string`):

Which comments come first when a post has more than you ask for.

## `includeNsfw` (type: `boolean`):

Off by default: posts Reddit marks as NSFW are skipped, counted on the input's status row and not charged.

## `maxUpstreamRequests` (type: `integer`):

Hard ceiling on the HTTP requests this run sends to Reddit, retries included. At the ceiling collection stops and the inputs not reached are marked partial with reason "upstream_request_cap". Leave empty and the Actor works a ceiling out from your inputs, so a run is never unbounded.

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

The proxy requests go through. Reddit refuses most data-center IPs, so the default is Apify residential proxy. A refused request is retried from a new IP up to four times; an input refused anyway is reported as blocked, never as zero results.

## Actor input object example

```json
{
  "subreddits": [
    "programming"
  ],
  "sort": "hot",
  "timeRange": "week",
  "searchSort": "relevance",
  "searchTimeRange": "all",
  "maxPosts": 25,
  "maxCommentsPerPost": 0,
  "commentSort": "top",
  "includeNsfw": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `posts` (type: `string`):

No description

## `comments` (type: `string`):

No description

## `runSummary` (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 = {
    "subreddits": [
        "programming"
    ]
};

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

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

```

## MCP server setup

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