# Reddit Scraper — Posts, Comments, Users, Subreddits (`good-apis/reddit-scraper`) Actor

Fast Reddit scraper. Search posts, get subreddit data, user profiles, and comments. No login, no browser, clean JSON output. Launch pricing: $1.25 / 1,000 results.

- **URL**: https://apify.com/good-apis/reddit-scraper.md
- **Developed by:** [Danny](https://apify.com/good-apis) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 2 total users, 1 monthly users, 40.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

$1.25 / 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.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

Reddit data actor for posts, comments, users, and subreddits.

Use this actor to collect Reddit data in clean JSON format through Apify datasets.

### Pricing

- Pricing: `$1.25 / 1,000 results`

### What It Can Do

- Search Reddit posts by query
- Search subreddits by query
- Fetch posts from a subreddit
- Fetch subreddit metadata
- Fetch comments for a post
- Fetch user profile data
- Fetch posts by a user
- Fetch comments by a user
- Fetch popular posts

### Why Use This Actor

- Faster than browser-based Reddit actors
- Clean dataset output for apps, agents, and workflows
- No Reddit login required
- Good fit for Python scripts, Make, n8n, and Apify workflows
- Cheaper launch pricing than many comparable Reddit actors

### Input

The actor requires an `action` plus action-specific fields.

#### Supported Actions

| Action | Required fields | Optional fields |
| --- | --- | --- |
| `search_posts` | `query` | `subreddit`, `sort`, `time`, `cursor` |
| `search_subreddits` | `query` | `cursor` |
| `subreddit_posts` | `subreddit` | `sort`, `time`, `cursor` |
| `subreddit_about` | `subreddit` | none |
| `post_comments` | `post_id`, `subreddit` | `sort` |
| `user_about` | `username` | none |
| `user_posts` | `username` | `sort`, `cursor` |
| `user_comments` | `username` | `sort`, `cursor` |
| `popular_posts` | none | `sort`, `cursor` |

#### Example Input

```json
{
  "action": "search_posts",
  "query": "python web framework",
  "subreddit": "python",
  "sort": "top",
  "time": "month"
}
````

### Input Examples and Usage

The examples below use a small Python wrapper so each actor action can be called with explicit parameters and sensible defaults.

```python
from apify_client import ApifyClient


APIFY_TOKEN = "YOUR_APIFY_TOKEN"
ACTOR_ID = "good-apis/reddit-scraper"


class RedditScraperActor:
    def __init__(self, token: str, actor_id: str = ACTOR_ID) -> None:
        self.client = ApifyClient(token)
        self.actor_id = actor_id

    def _run(self, **run_input):
        run = self.client.actor(self.actor_id).call(run_input=run_input)
        return list(self.client.dataset(run["defaultDatasetId"]).iterate_items())

    def search_posts(
        self,
        query: str,
        subreddit: str | None = None,
        sort: str | None = None,
        time: str | None = None,
        cursor: str | None = None,
    ):
        return self._run(
            action="search_posts",
            query=query,
            subreddit=subreddit,
            sort=sort,
            time=time,
            cursor=cursor,
        )

    def search_subreddits(self, query: str, cursor: str | None = None):
        return self._run(action="search_subreddits", query=query, cursor=cursor)

    def subreddit_posts(
        self,
        subreddit: str,
        sort: str | None = None,
        time: str | None = None,
        cursor: str | None = None,
    ):
        return self._run(
            action="subreddit_posts",
            subreddit=subreddit,
            sort=sort,
            time=time,
            cursor=cursor,
        )

    def subreddit_about(self, subreddit: str):
        return self._run(action="subreddit_about", subreddit=subreddit)

    def post_comments(
        self,
        post_id: str,
        subreddit: str,
        sort: str | None = None,
    ):
        return self._run(
            action="post_comments",
            post_id=post_id,
            subreddit=subreddit,
            sort=sort,
        )

    def user_about(self, username: str):
        return self._run(action="user_about", username=username)

    def user_posts(
        self,
        username: str,
        sort: str | None = None,
        cursor: str | None = None,
    ):
        return self._run(action="user_posts", username=username, sort=sort, cursor=cursor)

    def user_comments(
        self,
        username: str,
        sort: str | None = None,
        cursor: str | None = None,
    ):
        return self._run(action="user_comments", username=username, sort=sort, cursor=cursor)

    def popular_posts(self, sort: str | None = None, cursor: str | None = None):
        return self._run(action="popular_posts", sort=sort, cursor=cursor)


reddit = RedditScraperActor(APIFY_TOKEN)
```

#### `search_posts`

```python
items = reddit.search_posts(
    query="python web framework",
    subreddit="python",
    sort="top",
    time="month",
    cursor=None,
)
print(items)
```

#### `search_subreddits`

```python
items = reddit.search_subreddits(
    query="machine learning",
    cursor=None,
)
print(items)
```

#### `subreddit_posts`

```python
items = reddit.subreddit_posts(
    subreddit="python",
    sort="hot",
    time="day",
    cursor=None,
)
print(items)
```

#### `subreddit_about`

```python
items = reddit.subreddit_about(subreddit="python")
print(items)
```

#### `post_comments`

```python
items = reddit.post_comments(
    post_id="1r82a0a",
    subreddit="python",
    sort="top",
)
print(items)
```

#### `user_about`

```python
items = reddit.user_about(username="spez")
print(items)
```

#### `user_posts`

```python
items = reddit.user_posts(
    username="spez",
    sort="new",
    cursor=None,
)
print(items)
```

#### `user_comments`

```python
items = reddit.user_comments(
    username="spez",
    sort="top",
    cursor=None,
)
print(items)
```

#### `popular_posts`

```python
items = reddit.popular_posts(
    sort="hot",
    cursor=None,
)
print(items)
```

### Output

Results are written to the default Apify dataset.

- list responses are pushed as one dataset item per result
- object responses are pushed as a single dataset item
- failed runs push an error object before failing

List results include:

- `_action`: the executed action
- `_cursor`: the next-page cursor when available

### Client Examples

#### Python

See [examples/python\_client.py](./examples/python_client.py) for the same helper wrapper in a runnable file.

#### Node.js

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

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

const run = await client.actor('good-apis/reddit-scraper').call({
  action: 'search_posts',
  query: 'python web framework',
  subreddit: 'python',
  sort: 'top',
  time: 'month',
});

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

### Agent-Friendly Notes

This actor is designed to be easy for agents to call reliably.

- Inputs are flat and structured
- actions are explicit and predictable
- pagination state is returned as `_cursor`
- errors fail the run explicitly instead of silently returning partial success
- dataset output is machine-readable JSON without browser rendering artifacts

For agent use, prefer:

- `subreddit_about` for metadata lookup
- `search_posts` for query-driven discovery
- `post_comments` for thread extraction
- `_cursor` chaining for pagination

# Actor input Schema

## `action` (type: `string`):

What to scrape from Reddit

## `query` (type: `string`):

Search keyword(s). Required for search\_posts and search\_subreddits.

## `subreddit` (type: `string`):

Subreddit name without r/ prefix (e.g. 'python', 'startups'). Required for subreddit\_posts, subreddit\_about, post\_comments.

## `username` (type: `string`):

Reddit username (e.g. 'spez'). Required for user\_about, user\_posts, user\_comments.

## `post_id` (type: `string`):

Reddit post ID (e.g. '1r82a0a'). Required for post\_comments.

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

Sort order. Accepted values depend on action: relevance, hot, top, new, rising, comments, best, controversial, old.

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

Time range filter: hour, day, week, month, year, all

## `cursor` (type: `string`):

Cursor from previous response for pagination. Leave empty for first page.

## Actor input object example

```json
{
  "action": "search_posts",
  "time": "all"
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("good-apis/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 = {}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Reddit Scraper — Posts, Comments, Users, Subreddits",
        "description": "Fast Reddit scraper. Search posts, get subreddit data, user profiles, and comments. No login, no browser, clean JSON output. Launch pricing: $1.25 / 1,000 results.",
        "version": "1.0",
        "x-build-id": "H7F5pm2ds04bDGADC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/good-apis~reddit-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-good-apis-reddit-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/good-apis~reddit-scraper/runs": {
            "post": {
                "operationId": "runs-sync-good-apis-reddit-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/good-apis~reddit-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-good-apis-reddit-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "action"
                ],
                "properties": {
                    "action": {
                        "title": "Action",
                        "enum": [
                            "search_posts",
                            "search_subreddits",
                            "subreddit_posts",
                            "subreddit_about",
                            "post_comments",
                            "user_about",
                            "user_posts",
                            "user_comments",
                            "popular_posts"
                        ],
                        "type": "string",
                        "description": "What to scrape from Reddit",
                        "default": "search_posts"
                    },
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Search keyword(s). Required for search_posts and search_subreddits."
                    },
                    "subreddit": {
                        "title": "Subreddit",
                        "type": "string",
                        "description": "Subreddit name without r/ prefix (e.g. 'python', 'startups'). Required for subreddit_posts, subreddit_about, post_comments."
                    },
                    "username": {
                        "title": "Username",
                        "type": "string",
                        "description": "Reddit username (e.g. 'spez'). Required for user_about, user_posts, user_comments."
                    },
                    "post_id": {
                        "title": "Post ID",
                        "type": "string",
                        "description": "Reddit post ID (e.g. '1r82a0a'). Required for post_comments."
                    },
                    "sort": {
                        "title": "Sort",
                        "type": "string",
                        "description": "Sort order. Accepted values depend on action: relevance, hot, top, new, rising, comments, best, controversial, old."
                    },
                    "time": {
                        "title": "Time Filter",
                        "enum": [
                            "hour",
                            "day",
                            "week",
                            "month",
                            "year",
                            "all"
                        ],
                        "type": "string",
                        "description": "Time range filter: hour, day, week, month, year, all",
                        "default": "all"
                    },
                    "cursor": {
                        "title": "Pagination Cursor",
                        "type": "string",
                        "description": "Cursor from previous response for pagination. Leave empty for first page."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
