# Reddit Subreddit Posts Scraper (`axery/reddit-subreddit-posts-scraper`) Actor

Get posts from any public subreddit by sort (hot/new/top/rising/controversial) and time filter. Bulk-paginated.

- **URL**: https://apify.com/axery/reddit-subreddit-posts-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 $2.00 / 1,000 result items

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 Subreddit Posts Scraper

Bulk-fetch posts from any public subreddit by sort order — `hot`, `new`, `top`, `rising`, `controversial` — with time-window filtering and full pagination.

Useful for community monitoring, trend tracking within a niche subreddit, and building a training/research corpus from a specific community.

### Current access status — read before running

Reddit's own anonymous JSON endpoints (`www.reddit.com/r/{sub}/.json`, `old.reddit.com/r/{sub}/.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

**All five sort modes in one Actor**, including `rising` — a signal for posts gaining traction right now, not just what's already hot or newest.

**Multiple subreddits, one dataset, in one run.** Each row carries the subreddit it came from, so a multi-community monitoring run doesn't need one Actor call per subreddit.

**A clean, documented schema**, not a raw API dump. Reddit's post objects carry several dozen fields, many internal or UI-only; this Actor keeps only the ones with real research value, consistently named.

### Input

| Field | Type | Notes |
|---|---|---|
| `subreddits` | array | Subreddit names, without `r/`. |
| `sort` | enum | `hot`, `new`, `top`, `rising`, `controversial`. |
| `timeFilter` | enum | `hour`, `day`, `week`, `month`, `year`, `all`. Meaningful with `top`/`controversial`. |
| `maxPosts` | integer | Per subreddit. |
| `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,
  "created_at": "2026-05-13T10:22:00Z",
  "is_self": true,
  "link_flair_text": "Show and Tell",
  "permalink": "https://www.reddit.com/r/programming/comments/1a2b3c/..."
}
```

A private, banned, or nonexistent subreddit surfaces as an explicit failure row rather than a silent empty result.

### Local development

```bash
pip install -r requirements.txt
python test_local.py python --client-id YOUR_CLIENT_ID
python test_local.py python MachineLearning --sort top --time-filter week --max 50
```

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.

# Actor input Schema

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

Subreddit names to scrape. Accepts plain names (e.g. `python`), `r/`-prefixed (`r/python`), or full URLs.

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

How to sort the subreddit feed. `hot` = front-page algorithm, `new` = chronological, `top` / `controversial` = ranked within the time window, `rising` = trending now.

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

Time window applied when `sort` is `top` or `controversial`. Ignored for other sorts.

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

Maximum posts returned per subreddit. Set to `0` to fetch all available posts (Reddit caps listings at roughly 1,000).

## `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
{
  "subreddits": [
    "python",
    "MachineLearning"
  ],
  "sort": "hot",
  "timeFilter": "all",
  "maxPosts": 25,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

One row per post: title, author, score, comment count, flair.

# 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",
        "MachineLearning"
    ],
    "sort": "hot",
    "timeFilter": "all",
    "maxPosts": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/reddit-subreddit-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",
        "MachineLearning",
    ],
    "sort": "hot",
    "timeFilter": "all",
    "maxPosts": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("axery/reddit-subreddit-posts-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",
    "MachineLearning"
  ],
  "sort": "hot",
  "timeFilter": "all",
  "maxPosts": 25
}' |
apify call axery/reddit-subreddit-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,axery/reddit-subreddit-posts-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/fJuY7NOopk31JjcTA/builds/8Xy9U2zfRsBlGmABm/openapi.json
