# Reddit Post Detail Scraper (`axery/reddit-post-detail-scraper`) Actor

Fetch a Reddit post by URL or '<sub>/\<post_id>' shorthand, with full comments tree.

- **URL**: https://apify.com/axery/reddit-post-detail-scraper.md
- **Developed by:** [Axery](https://apify.com/axery) (community)
- **Categories:** Social media, Marketing
- **Features:** Limited permissions
- **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 and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Post Detail Scraper

Fetch a Reddit post by URL or `<subreddit>/<post_id>` shorthand, with its full post body and top-level comments.

Useful for discussion mining, citation enrichment, and building author-attributed dialog datasets.

### Current access status — read before running

Reddit's own anonymous JSON endpoints (`www.reddit.com/*.json`, `old.reddit.com/*.json`) are currently answering every request with a hard login wall, verified directly and consistently across TLS fingerprints as of this Actor's last build — not a rate limit, a login requirement. The one path that still works is Reddit's own official OAuth **installed-app** grant, which needs a free `client_id` (no client secret, no personal login) registered once at [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps) — choose "installed app" when creating it. Supply that value in the `redditClientId` input field.

Without a `client_id`, this Actor will currently fail on every request — that's Reddit's access wall, not a bug here, and it's stated plainly rather than left to be discovered as a silent failure.

### What makes this different

**One request, full thread.** Post body and its top-level comment tree arrive together — no separate call needed to attach comments to the post they belong to.

**A clean, documented schema**, not a raw API dump. Reddit's own post/comment objects carry several dozen fields, many internal or UI-only. This Actor keeps the ones with real research value and gives them consistent names, rather than passing Reddit's raw dict straight through.

**"More comments" stubs are filtered out**, not left in as hollow rows. Reddit's own comment listing includes placeholder objects for collapsed reply threads that carry no author or body — indistinguishable from a genuine empty comment unless checked for explicitly.

### Input

| Field | Type | Notes |
|---|---|---|
| `posts` | array | Full Reddit post URLs, or `subreddit/post_id` shorthand. |
| `maxComments` | integer | Cap on comments returned per post. |
| `redditClientId` | string | Currently effectively required — see above. |
| `proxyConfiguration` | object | Defaults to Residential. |

### Output

```json
{
  "post_id": "reddit.com:1a2b3c",
  "subreddit": "programming",
  "title": "Show HN: I built a blazingly fast Rust web server",
  "author": "rustacean42",
  "score": 1842,
  "num_comments": 234,
  "selftext": "Here's how I approached the problem...",
  "comments": [
    {"author": "commenter1", "body": "Great work! How does it compare to actix-web?", "score": 412}
  ],
  "comments_returned": 1
}
```

`comments_returned` reflects only real comments — "more comments" placeholders are excluded, so it may be lower than `num_comments` (the post's own reported total) for a heavily-discussed thread. Reply-chain expansion beyond what Reddit returns in one call is out of scope.

### Local development

```bash
pip install -r requirements.txt
python test_local.py "https://www.reddit.com/r/programming/comments/1a2b3c/example/" --client-id YOUR_CLIENT_ID
```

No `sample_output.json` ships with this Actor — Reddit's current access wall means a live run cannot be produced without a registered `client_id`, and this project doesn't publish fabricated sample data. The JSON above shows the real output shape from before the wall went up.

# Actor input Schema

## `posts` (type: `array`):

List of post URLs or shortcodes.

## `maxComments` (type: `integer`):

Maximum number of items per entity (maxComments).

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

Currently effectively required - Reddit blocks anonymous access with a hard login wall (confirmed directly). Register a free installed-app client ID at reddit.com/prefs/apps (choose "installed app" - no client secret, no personal login) and paste it here.

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

Apify Proxy settings. Defaults to Residential - Reddit currently blocks anonymous access from Apify's own container IP range with a hard login wall (confirmed directly), so a residential-looking IP is the only realistic chance of success without an installed-app client ID.

## Actor input object example

```json
{
  "posts": [
    "https://www.reddit.com/r/python/comments/1abc123/example/"
  ],
  "maxComments": 200,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

One row per post: post fields plus a nested comments array.

# 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 = {
    "posts": [
        "https://www.reddit.com/r/python/comments/1abc123/example/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/reddit-post-detail-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 = { "posts": ["https://www.reddit.com/r/python/comments/1abc123/example/"] }

# Run the Actor and wait for it to finish
run = client.actor("axery/reddit-post-detail-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 '{
  "posts": [
    "https://www.reddit.com/r/python/comments/1abc123/example/"
  ]
}' |
apify call axery/reddit-post-detail-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,axery/reddit-post-detail-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/hfpNNasFDpgb6RReo/builds/50Wmzf34LEiQYgToM/openapi.json
