# Reddit Subreddit Scraper (`datara/reddit-subreddit-scraper`) Actor

Scrape posts from any subreddit — titles, scores, comments, flairs, body text, and more. Sort by hot, new, top, or rising. No browser, no blocks, high reliability.

- **URL**: https://apify.com/datara/reddit-subreddit-scraper.md
- **Developed by:** [Datara](https://apify.com/datara) (community)
- **Categories:** Social media, Lead generation, SEO tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.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/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 Subreddit Scraper

Scrape posts from any subreddit with full engagement metrics — upvotes, comment counts, flairs, body text, and more. No setup required beyond choosing your subreddit.

---

### Features

- Fetch posts from any public subreddit
- Sort by **hot**, **new**, **top**, or **rising**
- Returns up to 500 posts per run
- Captures full engagement metrics: score, upvote ratio, comment count
- Includes post body text, flair, thumbnail URL, and permalink
- Timestamps converted to ISO 8601 for easy downstream use
- Clean error handling — dataset always receives at least one record

---

### Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `subreddit` | string | ✅ Yes | `startups` | Subreddit name (no `r/` prefix) |
| `sort` | string | No | `hot` | Sort order: `hot`, `new`, `top`, `rising` |
| `maxResults` | integer | No | `10` | Max posts to return (1–500) |
| `includeBodyText` | boolean | No | `true` | Include post body/selftext in output |

#### Example Input JSON

```json
{
  "subreddit": "startups",
  "sort": "hot",
  "maxResults": 25,
  "includeBodyText": true
}
````

***

### Output

Each record in the dataset represents one Reddit post.

| Field | Type | Description |
|---|---|---|
| `id` | string | Reddit post ID |
| `title` | string | Post title |
| `author` | string | Username of the poster |
| `subreddit` | string | Subreddit name |
| `url` | string | Full URL to the post or linked content |
| `score` | number | Net upvote score |
| `upvoteRatio` | number | Upvote ratio (e.g. `0.95`) |
| `numComments` | number | Number of comments |
| `createdAt` | string | ISO 8601 post creation timestamp |
| `bodyText` | string | null | Post body text (null for link posts or if disabled) |
| `isTextPost` | boolean | `true` if self/text post, `false` if link post |
| `flair` | string | null | Post flair if present |
| `thumbnail` | string | null | Thumbnail URL if present |
| `permalink` | string | Reddit permalink path |
| `scrapedAt` | string | ISO 8601 timestamp of when this record was scraped |

#### Example Output (2 sample records)

```json
[
  {
    "id": "1abc123",
    "title": "We launched our SaaS and got 500 signups in 48 hours — here's what worked",
    "author": "founder_mode",
    "subreddit": "startups",
    "url": "https://www.reddit.com/r/startups/comments/1abc123/we_launched/",
    "score": 1842,
    "upvoteRatio": 0.97,
    "numComments": 214,
    "createdAt": "2025-03-15T09:22:11.000Z",
    "bodyText": "We've been building in stealth for 8 months...",
    "isTextPost": true,
    "flair": "Launch",
    "thumbnail": null,
    "permalink": "/r/startups/comments/1abc123/we_launched/",
    "scrapedAt": "2025-04-01T14:05:33.221Z"
  },
  {
    "id": "2xyz789",
    "title": "How do you validate a B2B idea before building anything?",
    "author": "pre_revenue_pete",
    "subreddit": "startups",
    "url": "https://www.reddit.com/r/startups/comments/2xyz789/how_do_you_validate/",
    "score": 423,
    "upvoteRatio": 0.92,
    "numComments": 87,
    "createdAt": "2025-03-14T17:44:55.000Z",
    "bodyText": "I have an idea for automating procurement workflows for SMBs...",
    "isTextPost": true,
    "flair": "Question",
    "thumbnail": null,
    "permalink": "/r/startups/comments/2xyz789/how_do_you_validate/",
    "scrapedAt": "2025-04-01T14:05:33.221Z"
  }
]
```

***

### Pricing

This actor uses a **Pay Per Event (PPE)** model:

**$0.50 per 100 posts** returned. Minimum charge per run: one unit (up to 100 posts).

***

### Support

For issues or feature requests, contact us via the Apify console.

# Actor input Schema

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

Subreddit name without the r/ prefix. Example: startups

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

How to sort posts from the subreddit.

## `timeframe` (type: `string`):

Filter posts by time period. Most relevant when Sort Order is 'Top'. Leave unset to use Reddit's default for the chosen sort.

## `maxResults` (type: `integer`):

Maximum number of posts to return. The API returns 25 posts per page and supports pagination.

## `includeBodyText` (type: `boolean`):

If enabled, the post body (selftext) will be included in the output. Disable to reduce dataset size for link-heavy subreddits.

## Actor input object example

```json
{
  "subreddit": "startups",
  "sort": "hot",
  "timeframe": "",
  "maxResults": 25,
  "includeBodyText": true
}
```

# Actor output Schema

# 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 = {
    "subreddit": "startups",
    "sort": "hot",
    "timeframe": "",
    "maxResults": 25,
    "includeBodyText": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("datara/reddit-subreddit-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 = {
    "subreddit": "startups",
    "sort": "hot",
    "timeframe": "",
    "maxResults": 25,
    "includeBodyText": True,
}

# Run the Actor and wait for it to finish
run = client.actor("datara/reddit-subreddit-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 '{
  "subreddit": "startups",
  "sort": "hot",
  "timeframe": "",
  "maxResults": 25,
  "includeBodyText": true
}' |
apify call datara/reddit-subreddit-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Reddit Subreddit Scraper",
        "description": "Scrape posts from any subreddit — titles, scores, comments, flairs, body text, and more. Sort by hot, new, top, or rising. No browser, no blocks, high reliability.",
        "version": "0.0",
        "x-build-id": "okigO7YfgMoYrsfh1"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/datara~reddit-subreddit-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-datara-reddit-subreddit-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/datara~reddit-subreddit-scraper/runs": {
            "post": {
                "operationId": "runs-sync-datara-reddit-subreddit-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/datara~reddit-subreddit-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-datara-reddit-subreddit-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": [
                    "subreddit"
                ],
                "properties": {
                    "subreddit": {
                        "title": "Subreddit",
                        "type": "string",
                        "description": "Subreddit name without the r/ prefix. Example: startups",
                        "default": "startups"
                    },
                    "sort": {
                        "title": "Sort Order",
                        "enum": [
                            "best",
                            "hot",
                            "new",
                            "top",
                            "rising"
                        ],
                        "type": "string",
                        "description": "How to sort posts from the subreddit.",
                        "default": "hot"
                    },
                    "timeframe": {
                        "title": "Timeframe",
                        "enum": [
                            "",
                            "hour",
                            "day",
                            "week",
                            "month",
                            "year",
                            "all"
                        ],
                        "type": "string",
                        "description": "Filter posts by time period. Most relevant when Sort Order is 'Top'. Leave unset to use Reddit's default for the chosen sort.",
                        "default": ""
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum number of posts to return. The API returns 25 posts per page and supports pagination.",
                        "default": 25
                    },
                    "includeBodyText": {
                        "title": "Include Body Text",
                        "type": "boolean",
                        "description": "If enabled, the post body (selftext) will be included in the output. Disable to reduce dataset size for link-heavy subreddits.",
                        "default": true
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
