# Reddit Community Scraper (`datascrapers/reddit-scraper`) Actor

Scrape posts from any public Reddit community (subreddit) by URL or subreddit name. Extract titles, authors, scores, comment counts, flairs, timestamps, and media metadata for each post.

- **URL**: https://apify.com/datascrapers/reddit-scraper.md
- **Developed by:** [Farhan Ali](https://apify.com/datascrapers) (community)
- **Categories:** Social media, Integrations, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.70 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Community Scraper** creates a structured dataset of posts collected from public [Reddit](https://www.reddit.com) communities (subreddits). Each dataset item represents one post and can include the title, self-text, author, score, upvote ratio, comment count, flair, timestamps, and media flags. Query the source by community URL or subreddit name, control sort order and time filter, limit results with `maxItems`, and retrieve records through the Apify Dataset API or export them as JSON, CSV, Excel, or XML.

### Dataset at a glance

| Property | Value |
|---|---|
| Source | reddit.com (public subreddits) |
| Record unit | One post |
| Input methods | Community URLs (`startUrls`) or subreddit names (`searchQueries`) |
| Main identifiers | `id` (post ID), `url` |
| Delivery | Apify Dataset and API |
| Export formats | JSON, CSV, Excel, XML |
| Update model | Fresh records per Actor run |
| Pricing | $2 per 1,000 posts |

### Coverage and available records

The Actor collects posts from one or more public Reddit communities.

- **URL-based entry**: Pass full community URLs in `startUrls` (for example `https://www.reddit.com/r/AI_Agents/` or `https://old.reddit.com/r/python/`).
- **Name-based entry**: Pass subreddit names in `searchQueries` (for example `AI_Agents`, `python`); URLs are built automatically. Both inputs can be combined.
- **Sort order**: `sortBy` selects `hot`, `new`, `top`, `rising`, or `controversial`.
- **Time filter**: `timeFilter` applies to `top` and `controversial` and limits results to `hour`, `day`, `week`, `month`, `year`, or `all`.
- **Result limit**: `maxItems` caps the number of posts collected (`0` = unlimited).

Known exclusions: private, quarantined, and age-restricted communities that require login are not accessible; each run captures community state at run time (no historical snapshots); the Actor does not fetch full comment threads (only the `numComments` count is returned).

### Data dictionary

Field names below match dataset record JSON properties exactly.

| Field | Type | Nullable | Description | Example |
|---|---:|---|---|---|
| `id` | string | No | Reddit post identifier; best stable deduplication key | `1vhilqp` |
| `title` | string | No | Post title | `Which AI agent platform is best?` |
| `sourceQuery` | string | Yes | The community source that produced the record | `r/AI_Agents` |
| `selftext` | string | Yes | Post body text (empty for link posts) | `We're looking at AI agent platforms...` |
| `author` | string | Yes | Author username | `elementary_constable` |
| `subreddit` | string | Yes | Subreddit name without the `r/` prefix | `AI_Agents` |
| `subredditNamePrefixed` | string | Yes | Subreddit name with the `r/` prefix | `r/AI_Agents` |
| `score` | number | Yes | Post score | `34` |
| `ups` | number | Yes | Upvote count | `34` |
| `upvoteRatio` | number | Yes | Upvote ratio (0–1) | `0.97` |
| `numComments` | number | Yes | Number of comments | `16` |
| `totalAwardsReceived` | number | Yes | Total awards received | `0` |
| `createdAt` | string | Yes | Post creation time (ISO 8601) | `2026-08-06T22:20:48+00:00` |
| `url` | string | Yes | Post URL | `https://www.reddit.com/r/AI_Agents/comments/1vhilqp/...` |
| `permalink` | string | Yes | Post permalink path | `/r/AI_Agents/comments/1vhilqp/...` |
| `fullUrl` | string | Yes | Full post URL | `https://www.reddit.com/r/AI_Agents/comments/1vhilqp/...` |
| `domain` | string | Yes | Link domain (e.g. `self.AI_Agents`) | `self.AI_Agents` |
| `linkFlairText` | string | Yes | Post flair text | `Resource Request` |
| `over18` | boolean | Yes | Whether the post is marked NSFW | `false` |
| `spoiler` | boolean | Yes | Whether the post is marked a spoiler | `false` |
| `stickied` | boolean | Yes | Whether the post is stickied | `false` |
| `isSelf` | boolean | Yes | Whether the post is a text (self) post | `true` |
| `isVideo` | boolean | Yes | Whether the post contains video | `false` |
| `isGallery` | boolean | Yes | Whether the post is an image gallery | `false` |
| `thumbnailUrl` | string | Yes | Thumbnail URL (empty when absent) | `""` |
| `postHint` | string | Yes | Reddit post type hint | `self` |
| `galleryUrls` | array | Yes | Gallery image URLs | `[]` |
| `gilded` | number | Yes | Gilding count | `0` |
| `distinguished` | string | Yes | Distinguished author flag (mod/admin) | `""` |
| `pinned` | boolean | Yes | Whether the post is pinned | `false` |
| `locked` | boolean | Yes | Whether the post is locked | `false` |
| `archived` | boolean | Yes | Whether the post is archived | `false` |

### Example dataset record

A representative record produced from `searchQueries: ["AI_Agents"]`:

```json
{
  "id": "1vhilqp",
  "title": "Which AI agent platform is best for enterprise voice support?",
  "sourceQuery": "r/AI_Agents",
  "selftext": "We're looking at AI agent platforms for enterprise voice support...",
  "author": "elementary_constable",
  "subreddit": "AI_Agents",
  "subredditNamePrefixed": "r/AI_Agents",
  "score": 34,
  "ups": 34,
  "upvoteRatio": 0.97,
  "numComments": 16,
  "totalAwardsReceived": 0,
  "createdAt": "2026-08-06T22:20:48+00:00",
  "url": "https://www.reddit.com/r/AI_Agents/comments/1vhilqp/...",
  "permalink": "/r/AI_Agents/comments/1vhilqp/...",
  "fullUrl": "https://www.reddit.com/r/AI_Agents/comments/1vhilqp/...",
  "domain": "self.AI_Agents",
  "linkFlairText": "Resource Request",
  "over18": false,
  "spoiler": false,
  "stickied": false,
  "isSelf": true,
  "isVideo": false,
  "isGallery": false,
  "thumbnailUrl": "",
  "postHint": "",
  "galleryUrls": [],
  "gilded": 0,
  "distinguished": "",
  "pinned": false,
  "locked": false,
  "archived": false
}
```

### Query and input reference

| Input | Type | Required | Default | Accepted values | Description |
|---|---|---|---|---|---|
| `startUrls` | array | No | — | Reddit community URLs | URL-based entry point |
| `searchQueries` | array | No | — | Subreddit names (`AI_Agents`, `python`) | Name-based entry point; URLs built automatically |
| `sortBy` | string | No | `hot` | `hot`, `new`, `top`, `rising`, `controversial` | Post sort order |
| `timeFilter` | string | No | `all` | `hour`, `day`, `week`, `month`, `year`, `all` | Time filter for `top`/`controversial` |
| `maxItems` | integer | No | `0` | `0` or a positive integer | Maximum posts; `0` = unlimited |
| `proxyConfiguration` | object | No | Apify residential proxy | Apify proxy groups or custom proxies | Residential proxies are recommended |

Minimal request:

```json
{ "searchQueries": ["AI_Agents"], "sortBy": "hot" }
```

Advanced request:

```json
{
  "searchQueries": ["AI_Agents", "python"],
  "sortBy": "top",
  "timeFilter": "month",
  "maxItems": 100,
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

### Retrieve the data through the API

1. Start the Actor with a JSON input (console or API).
2. Wait for the run to finish, or use a synchronous endpoint for an inline response.
3. Retrieve items from the run's default dataset.
4. Paginate or export the dataset.

Python example:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR-APIFY-TOKEN")

run = client.actor("datascrapers/reddit-scraper").call(run_input={
    "searchQueries": ["AI_Agents", "python"],
    "sortBy": "hot",
    "maxItems": 100,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["id"], item["title"], item["score"])
```

Apify generates ready-to-run Python, JavaScript, and cURL examples on the Actor's API tab. Do not put a real API token in shared code or URLs.

### Data quality and record handling

- **Conditional fields**: Link posts have empty `selftext`; text posts have `isSelf: true`. Fields Reddit does not expose for a post are returned as null or empty.
- **Source changes**: Reddit page structure and values can change; unreadable fields are returned as null rather than fabricated.
- **Deduplication**: Each run appends fresh records; the Actor does not deduplicate across runs. Use `id` as the stable key and filter repeated runs against previously stored IDs.
- **Rate limits**: Reddit blocks datacenter IPs. Residential proxies (enabled by default) are required for consistent coverage.
- **Normalization**: `createdAt` is normalized to ISO 8601; scores and counts are read as numbers.

### Export and pipeline examples

| Destination | Recommended method | Typical use |
|---|---|---|
| PostgreSQL / Supabase | Dataset API poll or webhook consumer | Store posts for trend and sentiment pipelines |
| Google Sheets | Apify Google Sheets integration | Share community snapshots with teams |
| S3 / cloud storage | Scheduled export via Apify scheduler | Archival of community snapshots |
| BI tools | CSV / JSON export | Content and engagement analysis |

### Pricing and cost examples

The Actor uses pay-per-event pricing, billed per post record:

| Event | Trigger | Rate |
|---|---|---|
| Result | Every post pushed to the dataset | $2 per 1,000 posts |

A one-time Actor start event of $0.00005 applies to each run (effectively $0).

| Posts | Estimated base cost |
|---:|---:|
| 1,000 | $2.00 |
| 10,000 | $20.00 |
| 100,000 | $200.00 |

Compute units consumed by the run are billed by your Apify plan. Estimates depend on the verified pricing model and the options selected for the run.

### Limitations and responsible data use

- The Actor collects publicly accessible post data from public Reddit communities only.
- Field availability depends on what Reddit renders at run time; some values can be null or missing, and site changes can alter fields.
- The Actor does not provide historical snapshots unless you store them yourself.
- Reddit requires residential proxies for reliable access; without them, coverage may degrade due to blocking.
- You are responsible for compliance with Reddit's terms of service, applicable privacy law, and any contractual obligations before using the data.

### Dataset questions

#### What does one dataset item represent?

One Reddit post. Comment counts are included as `numComments`, but full comment threads are not collected.

#### Which field should I use as a unique identifier?

`id` is the stable Reddit post identifier and the recommended deduplication key. `url` is a reasonable secondary key.

#### Are fields nullable or conditional?

Yes. Link posts have empty `selftext`, and media fields (`thumbnailUrl`, `postHint`, `galleryUrls`) are empty when the post has no media.

#### Can I retrieve the records as CSV or JSON?

Yes. The dataset can be exported as JSON, CSV, Excel, or XML from the Apify Console, and queried through the Dataset API.

#### Does the Actor return historical data?

No. Each run captures the state of the community at run time. To track changes, schedule repeated runs and store the outputs yourself.

#### What counts as a billable result?

Each post pushed to the dataset is one billable result, charged at $2 per 1,000 posts. Use `maxItems` to control cost per run.

### Related datasets from Data Scrapers

- **[Twitter X Profile Scraper](https://apify.com/datascrapers/twitter-x-profile-scraper)** — Public post data from X for cross-platform discussion monitoring.
- **[Instagram Post Scraper](https://apify.com/datascrapers/instagram-post-scraper)** — Public Instagram posts for social content research.
- **[YouTube Comment Scraper](https://apify.com/datascrapers/youtube-comment-scraper)** — Video comment text for sentiment and audience research.
- **[LinkedIn Profile Scraper](https://apify.com/datascrapers/linkedin-profile-scraper)** — Professional profile data for audience and community analysis.

### Data Scrapers support

Need an additional field, record type, or export workflow? Contact Data Scrapers at stardustspotlight@gmail.com. Include a sample source URL, required fields, expected record volume, and preferred delivery format.

# Actor input Schema

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

Reddit community URLs to scrape, e.g. https://www.reddit.com/r/AI\_Agents/ or https://old.reddit.com/r/python/. Leave empty if using searchQueries instead.

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

Reddit community names to scrape (e.g. AI\_Agents, python, MachineLearning). Alternative to startUrls — URLs are built automatically.

## `sortBy` (type: `string`):

How to sort posts in the community

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

Time filter for top/controversial sorting

## `maxItems` (type: `integer`):

Maximum number of posts to scrape (0 = unlimited)

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

Apify proxy for the browser session. Residential proxies are strongly recommended — datacenter IPs are often blocked by Reddit.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.reddit.com/r/AI_Agents/"
    }
  ],
  "searchQueries": [
    "AI_Agents"
  ],
  "sortBy": "hot",
  "timeFilter": "all",
  "maxItems": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Dataset containing scraped Reddit posts

## `kvsRecords` (type: `string`):

Key-value store records produced by the Actor

# 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 = {
    "startUrls": [
        {
            "url": "https://www.reddit.com/r/AI_Agents/"
        }
    ],
    "searchQueries": [
        "AI_Agents"
    ],
    "maxItems": 20,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("datascrapers/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 = {
    "startUrls": [{ "url": "https://www.reddit.com/r/AI_Agents/" }],
    "searchQueries": ["AI_Agents"],
    "maxItems": 20,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("datascrapers/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 '{
  "startUrls": [
    {
      "url": "https://www.reddit.com/r/AI_Agents/"
    }
  ],
  "searchQueries": [
    "AI_Agents"
  ],
  "maxItems": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call datascrapers/reddit-scraper --silent --output-dataset

```

## MCP server setup

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