# Reddit Scraper (`epctex/reddit-scraper`) Actor

Tap into the wealth of Reddit's data with our Reddit Scraper. Extract valuable insights from posts, subreddits, comments, and user data effortlessly. Simplify analysis and gain valuable insights from the diverse Reddit community with our user-friendly and efficient tool.

- **URL**: https://apify.com/epctex/reddit-scraper.md
- **Developed by:** [epctex](https://apify.com/epctex) (community)
- **Categories:** Social media, News
- **Features:** Limited permissions
- **Stats:** 2,070 total users, 83 monthly users, 99.9% runs succeeded, 47 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 dataset items

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/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 Scraper

Reddit Scraper is a commercial-grade Reddit API built for teams that require dependable, structured Reddit data without maintaining scraping infrastructure in-house. The actor allows you to scrape Reddit posts, Reddit comments, subreddits, Reddit users, and Reddit communities within a single job — either by running a Reddit search against any keyword, or by supplying the Reddit URLs your workflow already depends on.

This Reddit scraping solution is designed around two operating modes that can be executed independently or in combination. Keyword mode performs a Reddit search across posts, communities, or people. URL mode performs direct Reddit data extraction from landing feeds, subreddit pages, individual post pages, user profiles, and community pages. Because both modes accept input in the same run, a single execution can cover exploratory keyword research and targeted URL collection simultaneously.

### Reddit Scraper Capabilities

The Reddit API supports the following features:

- **Search by keyword** — Search Reddit for posts, communities, or people.
- **Scrape by URL** — Provide direct links to landing feeds, subreddits, posts, user profiles, or communities.
- **Combine search and URLs** — Run keyword search and direct URL scraping together in a single job.
- **Include comments** — Pull full nested comment threads under any scraped post.
- **Sort and filter results** — Sort by relevance, hot, top, new, or comments, and filter by time range.

### Supported Reddit Data Sources

| Reddit Source | How to Target It | What It Covers |
|---|---|---|
| Reddit posts | search with `searchMode: link`, or direct post URLs in `startUrls` | Individual Reddit posts returned by keyword search or direct link |
| Subreddits | Subreddit URLs in `startUrls`, or `/r/{subreddit}/about` | Subreddit post listings and subreddit information pages |
| Reddit communities | search with `searchMode: sr` | Community results matching your keyword |
| Reddit users | search with `searchMode: user`, or user profile URLs in `startUrls` | People search results and user profile content |
| Reddit comments | `includeComments: true` | Full nested comment threads attached to each scraped post |
| Landing feeds | Feed URLs in `startUrls` | Reddit landing feed listings |

### Who Can Use This Reddit Scraper

The Reddit Scraper is applicable wherever public Reddit discussion carries commercial or analytical value. Typical adopters include:

**Market research and consumer insight teams.** Run keyword-driven Reddit search across relevant time ranges to observe how a category, product, or need state is discussed in the user's own language, rather than through survey instruments.

**Brand monitoring and communications functions.** Track brand, competitor, and executive mentions across Reddit posts and comment threads, using the time filter to isolate a specific day, week, or month around a campaign or incident.

**Product and UX organizations.** Scrape subreddits where your product category is discussed and pull nested comment threads to surface recurring complaints, feature requests, and workaround behavior.

**Academic and social science researchers.** Collect reproducible Reddit datasets defined by subreddit, keyword, sort order, and time window, with explicit item caps for controlled sample sizes.

**AI and machine learning teams.** Assemble conversational corpora from Reddit posts and threaded comments for model training, evaluation, retrieval augmentation, and benchmarking.

**SEO and content strategy teams.** Identify the questions, terminology, and long-tail phrasing real users apply to a topic, and locate the communities where a topic holds sustained attention.

**Investment research and financial analysis.** Monitor sentiment-bearing discussion in finance-oriented subreddits with `sort: new` for time-sensitive coverage or `sort: top` for consensus positions.

**Community and moderation teams.** Retrieve subreddit information and post listings for reporting on community activity and growth.

**Recruitment and talent research.** Use `searchMode: user` to locate people discussing specific technologies, domains, or professional topics.

**Journalists and OSINT analysts.** Combine direct URL collection with keyword search to document how a story propagated across Reddit communities.

### Pricing: Transparent Event-Based Costs

Pay only for what you scrape. No subscriptions, no hidden fees.

| Event Type | Price | What's Included |
|---|---|---|
| List Query | $0.025 per search/list | One landing feed, subreddit, user posts list, or search |
| Comments Query | $0.1 per post/user thread | Full comment thread for one post or user, replies included, flat price regardless of size |
| Detail Query | $0.003 per item | Each direct post URL or `/r/{subreddit}/about` |
| Dataset Items | $0.001 per item stored | First page (up to ~100 items) of each query included FREE on paid plans |

#### Cost Examples

| Scenario | Charges | Calculation | Total Cost |
|---|---|---|---|
| 1 search, 20 results | 1 list query | $0.025 × 1 | $0.025 |
| 1 direct post URL | 1 detail query + 1 dataset item | $0.003 + $0.001 | $0.004 |
| 1 direct post URL, with comments | 1 detail query + 1 comments query + 1 dataset item | $0.003 + $0.1 + $0.001 | $0.104 |
| 1 user's comment history | 1 comments query | $0.1 × 1 | $0.100 |
| Community search, 25 results | 1 list query | $0.025 × 1 | $0.025 |

### Controlling Reddit Scraping Costs

The event-based model rewards precise job design. Four principles follow directly from the rate card:

- **Enable comments deliberately.** A comments query is billed at $0.1 per post or user thread, which is the largest single line item in the model. Set `includeComments: false` when post-level data is sufficient.
- **Target high-value threads when comments are needed.** The comments query price is flat regardless of thread size, so a thread with thousands of replies costs the same as one with a handful. Prioritise dense discussions.
- **Stay within the free first page where possible.** On paid plans, the first page of each query — up to roughly 100 items — is included at no dataset-item cost. Jobs scoped to that range avoid per-item storage charges entirely.
- **Use direct URLs when you already have them.** A detail query is $0.003 per item against $0.025 for a list query, so known post URLs and `/r/{subreddit}/about` endpoints are the economical path when discovery is not required.

Use `maxItems` and `endPage` to enforce hard ceilings on any run before scaling it. On the Free plan, `maxItems` is not user-adjustable — every demo run is capped at 10 items regardless of what you set (see [Demo Mode](#demo-mode)). On paid plans, `maxItems` is respected up to your plan's own per-run ceiling, whichever is lower.

### Demo Mode

Free-plan users can try this actor without a subscription. The limit is 5 runs per month and 10 items per run, and this cap overrides any `maxItems` value you provide — the Free plan does not let you scrape past 10 items per run. The API is not available on the Free plan. For unrestricted use, subscribe to a paid plan.

### How to Use the Reddit Scraper

1. **Define your targets.** Supply `startUrls`, `search`, or both. At least one is required.
2. **Select a search mode.** Set `searchMode` to `link` for Reddit posts, `sr` for communities, or `user` for people.
3. **Apply sorting and time filters.** Set `sort` to `relevance`, `hot`, `top`, `new`, or `comments`, and `time` to `all`, `year`, `month`, `week`, `day`, or `hour`.
4. **Decide on comments.** Set `includeComments: true` only if nested comment threads are required, and account for the associated cost.
5. **Set volume limits.** Apply `maxItems` and, where relevant, `endPage`. On the Free plan these are capped regardless of the value you set — see [Demo Mode](#demo-mode).
6. **Run a small test first.** Execute a low-volume run to review the returned structure before committing to a large job.
7. **Scale.** Increase limits once the output matches your requirements.

### Input Parameters

| Field | Type | Description | Default |
|---|---|---|---|
| `startUrls` | array | Reddit URLs to scrape (feeds, subreddits, posts, users, or communities). | `[]` |
| `search` | string | Keyword to search for on Reddit. Used together with `searchMode`, can be combined with `startUrls`. | — |
| `searchMode` | string | What the search returns: `link` (posts), `sr` (communities), or `user` (people). | `link` |
| `sort` | string | Sort order for results: `relevance`, `hot`, `top`, `new`, or `comments`. Not every value applies everywhere. | `relevance` |
| `time` | string | Time range for post search: `all`, `year`, `month`, `week`, `day`, or `hour`. | `all` |
| `includeComments` | boolean | Fetch comments for every scraped post and nest them under it. | `false` |
| `maxItems` | number | Maximum number of items to return. Respected on paid plans up to your plan's own cap; on the Free plan every run is capped at 10 items regardless of this value. | unlimited |
| `endPage` | number | Maximum number of pages to fetch per start URL or search. | unlimited |
| `customMapFunction` | string | Function that takes each object as an argument and returns a mapped object. Must be a single synchronous function; it runs in a sandbox with plain JavaScript only (no network requests, `require` or `console`) and about 1 second per item. An unusable function is ignored and the original items are saved. | `null` |
| `outputConnector` | string | MCP connector to deliver the results to — pick one (see [Send Results to Notion, Todoist and More (MCP Connectors)](#send-results-to-notion-todoist-and-more-mcp-connectors)). | — |
| `deliverTarget` | string | Where the connector writes — paste the URL or ID (Notion example: `https://www.notion.so/My-Posts-24f8a1b2c3d44e5f8a9b0c1d2e3f4a5b`); some services need none. | — |
| `deliverMode` | string | `perPost` (one record per item) or `summary` (one roll-up per run). | `perPost` |
| `deliverMaxItems` | number | Optional cap on how many records `perPost` delivers (ignored in `summary`). | — |

### Input Examples

**Search Reddit communities by keyword**

```json
{
  "search": "apify",
  "searchMode": "sr",
  "maxItems": 20
}
```

**Scrape recent Reddit posts on a topic**

```json
{
  "search": "web scraping",
  "searchMode": "link",
  "sort": "new",
  "time": "week",
  "maxItems": 100
}
```

**Scrape Reddit posts with full comment threads**

```json
{
  "search": "data engineering",
  "searchMode": "link",
  "sort": "top",
  "time": "month",
  "includeComments": true,
  "maxItems": 50
}
```

**Combine direct Reddit URLs with a keyword search**

```json
{
  "startUrls": ["https://www.reddit.com/r/datasets/"],
  "search": "open dataset",
  "searchMode": "link",
  "sort": "relevance",
  "endPage": 3
}
```

**Find Reddit users discussing a topic**

```json
{
  "search": "machine learning",
  "searchMode": "user",
  "maxItems": 25
}
```

### Output Examples

Every scraped item is stored as a JSON object. The exact shape depends on what was scraped: posts, comments, communities, or users.

**Post**

```json
{
  "type": "post",
  "inputSource": "https://www.reddit.com/r/webscraping/",
  "id": "t3_1abcdef",
  "url": "https://www.reddit.com/r/webscraping/comments/1abcdef/best_practices_for_scraping_reddit_in_2026/",
  "title": "Best practices for scraping Reddit in 2026",
  "flair": "Discussion",
  "flairs": [
    { "type": "text", "text": "Discussion" }
  ],
  "subreddit": "webscraping",
  "subredditId": "t5_2r2gk",
  "author": "data_nomad42",
  "authorId": "t2_9f8g7h",
  "authorFlair": null,
  "text": "I've been scraping Reddit for a market research project and wanted to share a few lessons learned around rate limiting and pagination.",
  "textHTML": "<div class=\"md\"><p>I've been scraping Reddit for a market research project and wanted to share a few lessons learned around rate limiting and pagination.</p></div>",
  "gallery": [],
  "score": 214,
  "upvoteRatio": 0.94,
  "isOriginal": true,
  "createdAt": 1767283200,
  "editedAt": false,
  "isOver18": false,
  "removedByCategory": null,
  "commentCount": 37,
  "awards": []
}
```

**Comment**

```json
{
  "type": "comment",
  "id": "t1_kx9f2a1",
  "url": "https://www.reddit.com/r/webscraping/comments/1abcdef/best_practices_for_scraping_reddit_in_2026/kx9f2a1/",
  "author": "proxy_wizard",
  "authorId": "t2_4k2j9x",
  "authorFlair": null,
  "isSubmitter": false,
  "body": "Rotating residential proxies made the biggest difference for us, especially for the search endpoints.",
  "bodyHTML": "<div class=\"md\"><p>Rotating residential proxies made the biggest difference for us, especially for the search endpoints.</p></div>",
  "createdAt": 1767286800,
  "editedAt": false,
  "score": 42,
  "parentId": "t3_1abcdef",
  "postUrl": "https://www.reddit.com/r/webscraping/comments/1abcdef/best_practices_for_scraping_reddit_in_2026/",
  "postTitle": "Best practices for scraping Reddit in 2026",
  "postId": "t3_1abcdef",
  "subreddit": "webscraping",
  "subredditId": "t5_2r2gk",
  "awards": [],
  "replies": [
    {
      "id": "t1_kx9g8b3",
      "author": "data_nomad42",
      "isSubmitter": true,
      "body": "Good call, we saw the same thing once we hit a few hundred requests.",
      "bodyHTML": "<div class=\"md\"><p>Good call, we saw the same thing once we hit a few hundred requests.</p></div>",
      "createdAt": 1767290400,
      "editedAt": false,
      "score": 15,
      "parentId": "t1_kx9f2a1",
      "postId": "t3_1abcdef",
      "subreddit": "webscraping"
    }
  ]
}
```

**Community**

```json
{
  "type": "community",
  "inputSource": "https://www.reddit.com/r/webscraping/about",
  "id": "t5_2r2gk",
  "url": "https://www.reddit.com/r/webscraping/",
  "name": "webscraping",
  "title": "Web Scraping",
  "icon": "https://styles.redditmedia.com/t5_2r2gk/styles/communityIcon_abc123.png",
  "subscribers": 128430,
  "bannerImage": "https://styles.redditmedia.com/t5_2r2gk/styles/bannerBackgroundImage_def456.jpg",
  "subredditType": "public",
  "headerTitle": "Web Scraping",
  "publicDescription": "A community for discussing web scraping techniques, tools, and best practices.",
  "publicDescriptionHTML": "<div class=\"md\"><p>A community for discussing web scraping techniques, tools, and best practices.</p></div>",
  "description": "Rules:\n1. Be respectful\n2. No piracy requests\n3. Search before posting",
  "submitText": null,
  "createdAt": 1451606400,
  "submissionType": "any",
  "allowedMediaInComments": ["giphy", "image"],
  "hideCommentScoreForMins": 0
}
```

**User**

```json
{
  "type": "user",
  "inputSource": "https://www.reddit.com/user/data_nomad42/",
  "id": "t2_9f8g7h",
  "url": "https://www.reddit.com/user/data_nomad42/",
  "name": "data_nomad42",
  "title": "data_nomad42",
  "publicDescription": "Market researcher turned data hoarder.",
  "icon": "https://styles.redditmedia.com/t2_9f8g7h/styles/profileIcon_ghi789.png",
  "commentKarma": 18452,
  "linkKarma": 6210,
  "description": "Market researcher turned data hoarder.",
  "createdAt": 1420070400,
  "isGold": false,
  "isMod": false,
  "isOver18": false,
  "isVerified": true,
  "hasVerifiedEmail": true,
  "isEmployee": false,
  "acceptsFollowers": true
}
```

### Send Results to Notion, Todoist and More (MCP Connectors)

Skip the manual exports — the Reddit Scraper can deliver its results directly into the tools you already work in, through [Apify MCP Connectors](https://apify.com/store/collections/mcp-connectors):

1. Authorize a connector (Notion, Todoist, or any service whose MCP server offers non-destructive write tools) once in [Console → Settings → API & Integrations → MCP connectors](https://console.apify.com/settings/integrations).
2. Pick it from the **Send results to Notion, Todoist, …** dropdown.
3. Fill in where and how to write:
   - **Destination target** — paste the URL or ID (Notion example: `https://www.notion.so/My-Posts-24f8a1b2c3d44e5f8a9b0c1d2e3f4a5b`); share it with your connector first via Notion's **•••  → Connections** menu. For structured columns use a **page** URL (the Actor builds the database for you) or a database that **already has columns** — an empty database only receives titles. (Some services need no target.)
   - **Write mode** — `perPost` writes one record per scraped item; `summary` writes a single roll-up for the run.
   - **Max records to deliver** *(optional)* — cap on how many records `perPost` delivers.

**Notion, structured like a spreadsheet:** for a table of typed columns, point the target at a Notion **page** — the Actor auto-creates a database from the data, one matching, correctly-typed column per field (URL, number, date, text). Pointing at an **existing database** fills the columns it already has (matched by name); an **empty database** receives only the title, and the rest of each record goes to the row body — the connector can't add columns to an existing database without destructive access it never requests. Nested fields are flattened into columns too — a `video` object becomes `video.url`, `video.hasAudio`, … — so everything is sortable and filterable in the grid. Fields that don't fit a column go to the row's page body, so nothing is lost.

Your credentials stay yours: the Actor talks to your services exclusively through your own authorized connector and only ever uses non-destructive write tools — it cannot delete or overwrite anything you already have. Delivery is best-effort and runs after the scrape: if a connector is misconfigured or a delivery fails, your run still finishes normally with all results intact — the failure is reported in the run log, never by failing the run. If the run is about to hit its timeout, delivery stops early so the run still succeeds, and the log tells you how many records were delivered.

### During the Run

The actor outputs messages as it progresses through each page, URL, or search. If you provide incorrect input, such as leaving both `startUrls` and `search` empty, the actor will stop immediately with an explanation of what went wrong.

### Frequently Asked Questions

**What can the Reddit Scraper collect?** The actor collects Reddit posts, Reddit communities, Reddit users, and nested Reddit comment threads, sourced through keyword search, direct URLs, or both in the same run.

**Can I scrape Reddit comments?** Yes. Set `includeComments: true` and full nested comment threads are pulled and nested under each scraped post. Comment retrieval is billed as a comments query at $0.1 per post or user thread.

**Can I run a keyword search and direct URLs in one job?** Yes. `search` and `startUrls` can be supplied together in a single run. At least one of the two must be provided.

**How do I search for subreddits rather than posts?** Set `searchMode` to `sr`. The search then returns communities matching your keyword instead of posts.

**How do I find Reddit users?** Set `searchMode` to `user`. The search returns people rather than posts or communities.

**How do I restrict results to a recent time period?** Use the `time` parameter, which accepts `all`, `year`, `month`, `week`, `day`, or `hour` for post search.

**Which sort orders are available?** Relevance, hot, top, new, and comments. Not every value applies everywhere, so the effective sort depends on what you are targeting.

**How do I cap the volume of a run?** `maxItems` sets the maximum number of items returned and is unlimited by default. `endPage` sets the maximum number of pages fetched per start URL or search. On the Free plan, `maxItems` is fixed at 10 regardless of what you set — see [Demo Mode](#demo-mode).

**Can I customise the output?** Yes. `customMapFunction` takes each object as an argument and returns a mapped object. If it is not a usable function, or it throws, returns a non-object or runs longer than about 1 second, it is ignored for the rest of the run and the original items are saved. The legacy `extendOutputFunction` is no longer supported and is ignored with a warning.

**Is there a free way to test the Reddit Scraper?** Yes. Demo Mode allows free-plan users to run the actor without a subscription, limited to 5 runs per month and 10 items per run.

**Is API access included on the Free plan?** No. The API is not available on the Free plan. A paid plan is required for API access and unrestricted use.

**Does a large comment thread cost more than a small one?** No. The comments query is a flat $0.1 per post or user thread, replies included, regardless of thread size.

**Are dataset items always charged?** Dataset items are $0.001 per item stored, and on paid plans the first page of each query — up to approximately 100 items — is included free.

**What happens if my input is invalid?** The actor stops immediately and returns an explanation of the problem. Leaving both `startUrls` and `search` empty is one such case.

### Support and Custom Integrations

Please visit us through epctex.com to see all available products. For custom integrations, reach out via the chat box on epctex.com. For support: business@epctex.com.

# Actor input Schema

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

URLs to start with. Supports the Reddit landing feeds (/, /hot, /best, /new, /top), subreddits, single posts, user profiles and user comment pages. Can be combined with a search query - each entry is scraped as its own query.

## `search` (type: `string`):

The keyword to search on Reddit. Runs as a separate query from Start URLs - you can provide both.

## `searchMode` (type: `string`):

What type of results the search should return. Only applies to the Search keyword.

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

How to sort results. Applies to search and to subreddit/user listings. Not every sort is valid everywhere - the landing feeds are sorted by the feed itself, community and people searches are always relevance-sorted, and subreddit/user listings only support Hot, Top and New. Unsupported values fall back to the Reddit default.

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

Time range for results. Only applies to post search - Reddit ignores it for Communities and People searches.

## `includeComments` (type: `boolean`):

Fetch comments for every scraped post and nest them under the post. Applies to single posts, listings and user posts. Each comment is billed as a dataset item, so this can meaningfully increase the cost of a run.

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

Maximum number of items that you want as output. Default is all.

## `endPage` (type: `integer`):

The page number to stop at. Applies to each Start URL and to the search query independently. Default is no end page.

## `customMapFunction` (type: `string`):

Function that takes each of the objects as argument and returns data that will be mapped by the function itself. This function is not intended for filtering. Must be a single synchronous function, e.g. (object) => { return {...object} }. It runs in a sandbox with plain JavaScript only (no network or require) and about 1 second per item. Leave empty if you do not need to transform the output - an unusable function is ignored and the original items are saved instead.

## `outputConnector` (type: `string`):

Pick an MCP connector you authorized in Console → Settings → API & Integrations → MCP connectors (e.g. Notion, Todoist — any service whose MCP server offers non-destructive write tools works best-effort). The scraped results are written through your own connector — the Actor never sees your third-party credentials. Only non-destructive write tools are used; it can never delete or overwrite your existing data.

## `deliverTarget` (type: `string`):

Where to write into the connector — paste the URL or ID. Notion example: https://www.notion.so/My-Posts-24f8a1b2c3d44e5f8a9b0c1d2e3f4a5b. Leave empty for services that need no target (e.g. Todoist Inbox, Slack). For Notion, share the page or database with your connector first (Notion's ••• → Connections menu), and point at a PAGE for structured columns (the Actor builds the database for you) — an empty database receives only the title (the rest of each record goes to the row's body).

## `deliverMode` (type: `string`):

perPost writes one record per scraped item; summary writes a single roll-up for the run.

## `deliverMaxItems` (type: `integer`):

Cap on how many records perPost mode writes to the connector; ignored in summary mode. Leave empty to deliver everything scraped.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.reddit.com/best",
    "https://www.reddit.com/user/nationalgeographic/submitted",
    "https://www.reddit.com/r/redditisfun/comments/13wxepd/rif_dev_here_reddits_api_changes_will_likely_kill"
  ],
  "search": "apify",
  "searchMode": "link",
  "sort": "relevance",
  "time": "all",
  "includeComments": false,
  "maxItems": 1000,
  "customMapFunction": "(object) => { return {...object} }",
  "deliverMode": "perPost"
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# 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": [
        "https://www.reddit.com/best",
        "https://www.reddit.com/user/nationalgeographic/submitted",
        "https://www.reddit.com/r/redditisfun/comments/13wxepd/rif_dev_here_reddits_api_changes_will_likely_kill"
    ],
    "search": "apify",
    "maxItems": 1000,
    "customMapFunction": (object) => { return {...object} }
};

// Run the Actor and wait for it to finish
const run = await client.actor("epctex/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": [
        "https://www.reddit.com/best",
        "https://www.reddit.com/user/nationalgeographic/submitted",
        "https://www.reddit.com/r/redditisfun/comments/13wxepd/rif_dev_here_reddits_api_changes_will_likely_kill",
    ],
    "search": "apify",
    "maxItems": 1000,
    "customMapFunction": "(object) => { return {...object} }",
}

# Run the Actor and wait for it to finish
run = client.actor("epctex/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": [
    "https://www.reddit.com/best",
    "https://www.reddit.com/user/nationalgeographic/submitted",
    "https://www.reddit.com/r/redditisfun/comments/13wxepd/rif_dev_here_reddits_api_changes_will_likely_kill"
  ],
  "search": "apify",
  "maxItems": 1000,
  "customMapFunction": "(object) => { return {...object} }"
}' |
apify call epctex/reddit-scraper --silent --output-dataset

```

## MCP server setup

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