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

Scrape public Reddit posts, comments, subreddits, and user profiles from search queries, Reddit URLs, subreddit feeds, or usernames. Export structured rows with IDs, URLs, authors, timestamps, scores, comment counts, media links, and matched inputs.

- **URL**: https://apify.com/maximedupre/reddit-scraper.md
- **Developed by:** [Maxime Dupré](https://apify.com/maximedupre) (community)
- **Categories:** Developer tools, Social media, Automation
- **Features:** Limited permissions
- **Stats:** 27 total users, 5 monthly users, 99.8% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.05 / 1,000 scraped entries

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/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 for posts, comments, subreddits, and users

Reddit Scraper collects public data from [Reddit](https://www.reddit.com/) search, Reddit URLs, subreddits, and user profiles. It is for marketers, researchers, analysts, and developers who want Reddit data in a clean table. You get posts, comments, community details, user profile facts, scores, comment counts, dates, Reddit links, and media links. You can download the dataset, read it through the Apify API, or send it into your own workflow. You do not need a Reddit account or API key.

- Use the **[Reddit scraper API](https://apify.com/maximedupre/reddit-scraper/examples/reddit-scraper-reddit-scraper-api)** to pull public Reddit posts and comments into your app.
- Export titles, text, scores, and comment counts with a **[Reddit post scraper](https://apify.com/maximedupre/reddit-scraper/examples/reddit-scraper-reddit-post-scraper)** run on search terms or subreddits.
- Search comments or collect the replies under found posts with a **[Reddit comment scraper](https://apify.com/maximedupre/reddit-scraper/examples/reddit-scraper-reddit-comment-scraper)**.
- Collect feed posts and community facts with a **[subreddit scraper](https://apify.com/maximedupre/reddit-scraper/examples/reddit-scraper-subreddit-scraper)** run.
- Get karma, profile text, and public posts and comments for a username with a **[Reddit user profile scraper](https://apify.com/maximedupre/reddit-scraper/examples/reddit-scraper-reddit-user-profile-scraper)**.

#### 📦 Reddit data you can export

Each row has a `rowType`, so you can filter the dataset by Reddit object type.

| Row type | What you get |
| --- | --- |
| `post` | Title, text, author, subreddit, score, upvote ratio, comment count, flair, NSFW, spoiler, locked, and pinned flags, Reddit link, and media or shared links |
| `comment` | Comment text, author, subreddit, score, nesting depth, parent post and parent comment IDs, parent post title, and Reddit link |
| `community` | Subreddit name, title, description, creation date, NSFW flag, and Reddit link |
| `user` | Username, display name, profile description, post karma, comment karma, verified flag, account creation date, and Reddit link |

Every row has `matchedInput`, which shows the search query, URL, subreddit, or username that found it. The `url` field always holds the Reddit page link. When a post shares an outside link, such as a news article or an image, that link is in `media`. Some fields are `null` when Reddit does not show that fact.

The Actor also saves `RUN-SUMMARY.json` in the key-value store. It has total rows, rows by type, rows by input and subreddit, duplicate counts, skip reasons, and the top engagement rows.

#### 🚀 How to run the Reddit scraper

1. Open the Input tab.
2. Fill at least one section:
   - `Search queries`, such as `openai` or `chatgpt`
   - `Reddit URLs`, such as a post, comment, subreddit, user, popular, or search URL
   - `Subreddits`, such as `r/artificial` or `OpenAI`
   - `Users`, such as `u/spez`
3. Pick which row types you want with `Search result type` and `User activity`.
4. Set `Post row limit`, `Comment row limit`, and `Comments per expanded post` to control run size.
5. Start the run, then open the dataset or `RUN-SUMMARY.json`.

The form starts with small row limits, so your first run stays short and cheap.

#### ⚙️ Input

**Input fields**

| Field | Type | What it does |
| --- | --- | --- |
| `searchQueries` | array of strings | Reddit search phrases. Each phrase is a separate search. |
| `searchCommunityName` | string | Search only inside one subreddit, such as `r/artificial`. Leave empty to search all of Reddit. |
| `searchResultType` | string | `postsAndComments` (default), `posts`, or `comments`. Chooses which row types each search returns. |
| `sort` | string | Post search sort: `relevance`, `hot`, `top`, `new` (default), or `comments`. |
| `commentSort` | string | Comment search sort: `relevance`, `top`, or `new` (default). |
| `time` | string | Search time window: `all` (default), `hour`, `day`, `week`, `month`, or `year`. |
| `dateFrom` | string | Keep search rows created on or after this date (`YYYY-MM-DD`). |
| `dateTo` | string | Keep search rows created on or before this date (`YYYY-MM-DD`). |
| `maxDaysOld` | integer | Keep search rows from the last number of days. Default `30`. It is used only when both date fields are empty. `0` turns it off. |
| `includeNSFW` | boolean | Keep search rows that Reddit marks as NSFW. Default `false`. |
| `strictSearch` | boolean | Keep only search rows whose text contains every word of the search phrase. Default `false`. |
| `collectCommentsUnderSearchPosts` | boolean | Also save comments under the posts that a search finds. Default `false`. |
| `startUrls` | array of objects | Reddit URLs to scrape, each as `{ "url": "..." }`. The URL decides what you get: a post with its comments, a subreddit, a user, the popular feed, or a search page. |
| `subredditNames` | array of strings | Subreddit names or `r/name` handles. Each one returns a community row and feed posts. |
| `subredditSort` | string | Subreddit feed: `hot` (default), `new`, `top`, or `rising`. |
| `subredditTime` | string | Time window for the `top` feed: `all` (default), `hour`, `day`, `week`, `month`, or `year`. |
| `collectCommentsUnderSubredditPosts` | boolean | Also save comments under subreddit feed posts. Default `true`. |
| `userNames` | array of strings | Reddit usernames or `u/name` handles. Each one returns a user row and public activity. |
| `userActivity` | string | `postsAndComments` (default), `posts`, or `comments`. Chooses which user activity rows to save. |
| `postRowLimit` | integer | Most post rows to save for each search query, subreddit, user, or listing URL. Empty or `0` saves all available posts. The form prefills `10`. |
| `commentRowLimit` | integer | Most comment rows to save for each search query, user, post URL, comment URL, or search URL. Empty or `0` saves all available comments. The form prefills `10`. |
| `commentsPerExpandedPost` | integer | Most comments to save under each post when comment collection is on. Default `150`. `0` saves all of them. The form prefills `5`. |

The search filters (`dateFrom`, `dateTo`, `maxDaysOld`, `includeNSFW`, and `strictSearch`) apply to search rows only.

**Input example**

```json
{
  "searchQueries": [
    "openai",
    "chatgpt",
    "openai api"
  ],
  "searchCommunityName": "r/artificial",
  "searchResultType": "postsAndComments",
  "sort": "new",
  "commentSort": "new",
  "time": "all",
  "maxDaysOld": 30,
  "includeNSFW": false,
  "strictSearch": false,
  "collectCommentsUnderSearchPosts": false,
  "startUrls": [
    {
      "url": "https://www.reddit.com/r/artificial/"
    },
    {
      "url": "https://www.reddit.com/r/OpenAI/search/?q=gpt-5&restrict_sr=1"
    }
  ],
  "subredditNames": [
    "r/artificial",
    "OpenAI"
  ],
  "subredditSort": "hot",
  "subredditTime": "all",
  "collectCommentsUnderSubredditPosts": true,
  "userNames": [
    "u/spez"
  ],
  "userActivity": "postsAndComments",
  "postRowLimit": 10,
  "commentRowLimit": 10,
  "commentsPerExpandedPost": 5
}
```

#### 🧾 Output

**Output fields**

**Post rows**

| Field | Type | What it does |
| --- | --- | --- |
| `rowType` | string | Always `post`. |
| `redditId` | string | Reddit post ID. |
| `url` | string | Reddit page link for the post. It never holds the outside link that the post shares. |
| `matchedInput` | string | The search query, URL, subreddit, or username that found the post. |
| `createdAt` | string or null | Post date in ISO 8601 format. |
| `authorName` | string or null | Author username. |
| `subredditName` | string or null | Subreddit name without `r/`. |
| `title` | string or null | Post title. |
| `text` | string or null | Post text, when the post has text. |
| `score` | integer or null | Reddit score. |
| `upvoteRatio` | number or null | Upvote ratio, when Reddit shows it. |
| `commentCount` | integer or null | Comment count that Reddit shows. |
| `flairText` | string or null | Post flair. |
| `isNsfw` | boolean or null | Whether Reddit marks the post as NSFW. |
| `isSpoiler` | boolean or null | Whether the post is a spoiler. |
| `isLocked` | boolean or null | Whether the post is locked. |
| `isPinned` | boolean or null | Whether the post is pinned in its subreddit or profile. |
| `media` | array | Images, galleries, videos, thumbnails, and the outside link that the post shares. |
| `media.type` | string | `image`, `video`, `gallery`, `thumbnail`, or `link`. |
| `media.url` | string | Link to the image, video, or gallery item, or the outside link. |
| `media.width` | integer or null | Media width, when Reddit shows it. |
| `media.height` | integer or null | Media height, when Reddit shows it. |
| `media.thumbnailUrl` | string or null | Thumbnail link, when Reddit shows it. |

**Example post row**

```json
{
  "rowType": "post",
  "redditId": "1xjiczy",
  "url": "https://www.reddit.com/r/artificial/comments/1xjiczy/tech_stocks_set_to_wipe_out_more_than_1_trillion/",
  "matchedInput": "https://www.reddit.com/r/artificial/",
  "createdAt": "2026-10-30T15:25:41.031Z",
  "authorName": "return2ozma",
  "subredditName": "artificial",
  "title": "Tech stocks set to wipe out more than $1 trillion as concerns deepen about the AI boom",
  "text": null,
  "score": 245,
  "upvoteRatio": 0.9487179487179487,
  "commentCount": 44,
  "flairText": "News",
  "isNsfw": false,
  "isSpoiler": false,
  "isLocked": false,
  "isPinned": false,
  "media": [
    {
      "type": "link",
      "url": "https://www.nbcnews.com/business/markets/tech-stocks-nasdaq-ai-boom-fears-deepen-rcna606512",
      "width": null,
      "height": null,
      "thumbnailUrl": "https://external-preview.redd.it/YHsujDfmZu1wNca6BlLWzj0HsHt32IQZ8arFpMo4mxo.jpeg?width=140&height=73&auto=webp&s=6cc8e707776cff73c0d02eb35586015b386704e9"
    }
  ]
}
```

**Comment rows**

| Field | Type | What it does |
| --- | --- | --- |
| `rowType` | string | Always `comment`. |
| `redditId` | string | Reddit comment ID. |
| `url` | string | Reddit page link for the comment. |
| `matchedInput` | string | The search query, URL, subreddit, or username that found the comment. |
| `createdAt` | string or null | Comment date in ISO 8601 format. |
| `authorName` | string or null | Author username. |
| `subredditName` | string or null | Subreddit name without `r/`. |
| `commentText` | string or null | Comment text. |
| `score` | integer or null | Reddit score. |
| `parentPostId` | string or null | ID of the post the comment belongs to. |
| `parentCommentId` | string or null | ID of the comment it replies to. `null` for top-level comments. |
| `parentPostTitle` | string or null | Title of the parent post, when known. |
| `depth` | integer or null | Reply depth. `0` is a top-level comment. |
| `isSubmitter` | boolean or null | Whether the comment author also wrote the post. |
| `isNsfw` | boolean or null | Whether Reddit marks the comment as NSFW. |
| `isLocked` | boolean or null | Whether the comment thread is locked. |

**Example comment row**

```json
{
  "rowType": "comment",
  "redditId": "19rx6pu13dkjo",
  "url": "https://www.reddit.com/r/artificial/comments/1xjqc40/comment/19rx6pu13dkjo/",
  "matchedInput": "https://www.reddit.com/r/artificial/",
  "createdAt": "2026-10-31T08:34:04.790Z",
  "authorName": "Many_Consideration86",
  "subredditName": "artificial",
  "score": 1,
  "isNsfw": null,
  "isLocked": false,
  "commentText": "Not with a large enough astronomical constant.",
  "parentPostId": "1xjqc40",
  "parentCommentId": "19rx2lordgzeq",
  "parentPostTitle": "AI cracks a 27-year-old pillar of computer science, OpenAI and Anthropic claim",
  "depth": 1,
  "isSubmitter": false
}
```

**Community rows**

| Field | Type | What it does |
| --- | --- | --- |
| `rowType` | string | Always `community`. |
| `redditId` | string | Reddit subreddit ID. |
| `url` | string | Reddit page link for the subreddit. |
| `matchedInput` | string | The subreddit or URL that found the community. |
| `createdAt` | string or null | Subreddit creation date in ISO 8601 format. |
| `communityName` | string or null | Subreddit name without `r/`. |
| `communityTitle` | string or null | Subreddit title. |
| `communityDescription` | string or null | Subreddit description. |
| `isNsfw` | boolean or null | Whether Reddit marks the subreddit as NSFW. |

**Example community row**

```json
{
  "rowType": "community",
  "redditId": "artificial",
  "url": "https://www.reddit.com/r/artificial/",
  "matchedInput": "https://www.reddit.com/r/artificial/",
  "createdAt": "2008-03-13T20:50:49.418Z",
  "communityName": "artificial",
  "communityTitle": "Artificial Intelligence (AI)",
  "communityDescription": "Reddit’s home for Artificial Intelligence (AI)",
  "isNsfw": false
}
```

**User rows**

| Field | Type | What it does |
| --- | --- | --- |
| `rowType` | string | Always `user`. |
| `redditId` | string | Reddit user ID. |
| `url` | string | Reddit page link for the user profile. |
| `matchedInput` | string | The username or URL that found the profile. |
| `createdAt` | string or null | Account creation date in ISO 8601 format. |
| `username` | string or null | Reddit username. |
| `displayName` | string or null | Display name on the profile. |
| `profileDescription` | string or null | Profile description. |
| `postKarma` | integer or null | Post karma. |
| `commentKarma` | integer or null | Comment karma. |
| `isVerified` | boolean or null | Whether Reddit marks the user as verified. |
| `isNsfw` | boolean or null | Whether Reddit marks the profile as NSFW. |

**Example user row**

```json
{
  "rowType": "user",
  "redditId": "spez",
  "url": "https://www.reddit.com/user/spez/",
  "matchedInput": "u/spez",
  "createdAt": "2005-06-06T00:00:00.000Z",
  "username": "spez",
  "displayName": "spez",
  "profileDescription": "Reddit CEO",
  "postKarma": 184758,
  "commentKarma": 756619,
  "isVerified": true,
  "isNsfw": false
}
```

#### 💳 Pricing

You pay one event for each post, comment, community, or user profile row saved to the dataset. The price is $0.0013 per row on the free plan, which is $1.30 per 1,000 rows. Paid plans pay less per row: $0.00125 on Bronze, $0.00115 on Silver, and $0.00105 on Gold and higher.

Skipped inputs, pages that are not found, duplicate rows, and failed comment loads are not saved as rows, so they are not charged. They show in the logs and in `RUN-SUMMARY.json`. If you set a maximum cost for the run, the Actor stops when it reaches that limit.

#### 🔌 Integrations

https://www.youtube.com/watch?v=bNACk1_S_6w\&list=PLObrtcm1Kw6MUrlLNDbK9QRg8VDJg0gOW\&index=4

- Start runs from your app with the Apify API, or from Python or JavaScript with the Apify client.
- Schedule repeat runs to watch search terms, subreddits, or users.
- Export datasets as JSON, CSV, Excel, XML, RSS, or HTML.
- Send finished runs to webhooks, Make, Zapier, Google Sheets, or other tools.

#### ❓ FAQ

##### Why does a post's url point to Reddit and not to the shared article?

The `url` field is always the Reddit page link for the row. When a post shares an outside link, such as a news article or an image, you find it in `media` with the type `link`, `image`, `video`, or `gallery`.

##### Can I use this Reddit scraper from Python?

Yes. Use the Apify Python client or the Apify API to start a run with your input. Then read the dataset items as JSON or CSV.

##### Do I need a Reddit API key or a Reddit account?

No. The Actor reads public Reddit data. It does not ask for Reddit cookies, login details, OAuth, or a Reddit API key.

##### How is this different from the Reddit API limits?

The Reddit API needs app approval and has its own rate limits and rules. With this Actor, you do not manage Reddit credentials or rate limits. You set row limits and pay per saved row.

##### Is this Reddit scraper free?

No. Each saved row is a paid event. Apify gives free plan users monthly credit, which you can use for small runs.

##### Can I scrape Reddit images?

The Actor returns image, gallery, video, and thumbnail links in the `media` field. It does not download or store the media files.

##### Can I scrape comments under posts?

Yes. Turn on `collectCommentsUnderSearchPosts` for search posts or `collectCommentsUnderSubredditPosts` for subreddit posts. A post URL in `startUrls` also returns its comments. Use `commentsPerExpandedPost` to cap comments under each post.

##### Can I search inside one subreddit?

Yes. Put the subreddit in `searchCommunityName`, or add a subreddit search URL, such as `https://www.reddit.com/r/OpenAI/search/?q=gpt-5`, to `startUrls`.

##### Are duplicate rows saved twice?

No. When two inputs find the same post, comment, community, or user, the Actor saves it once and counts the duplicate in `RUN-SUMMARY.json`.

##### Are skipped or failed items saved as rows?

No. The dataset holds only scraped rows. Skips, duplicates, and pages that are not found go to the logs and `RUN-SUMMARY.json`.

### 📝 Changelog

**v1.0** (31-10-2026)

- Fixed `url` on post rows. It now always holds the Reddit page link for the post. Before, a post that shared an outside link, such as an article or an image, put that outside link in `url`. You now find the shared link in `media`.
- Renamed `matchedInputs` to `matchedInput`. It is now one text value, not a list. It shows the search query, URL, subreddit, or username that found the row. Update any code that reads `matchedInputs`.
- Removed `redditFullname` from all rows. There is no replacement field. `redditId` still holds the short Reddit ID.
- Removed `memberCount` and `onlineCount` from community rows. There is no replacement.
- Removed `subredditName` from community rows. Use `communityName`, which holds the same subreddit name.
- Added `isPinned` to post rows. It shows if a post is pinned in its subreddit or profile.
- `postRowLimit` and `commentRowLimit` now save all rows when you leave them empty or set them to `0`. Before, empty meant 150 rows and `0` saved no rows. Set a number to keep a limit.
- `commentsPerExpandedPost` set to `0` now saves all comments under each post. Before, `0` saved no comments. To skip comments, turn off comment collection in that section instead.
- Reliability improvements.

**v0.1**

- Added search query, URL, subreddit, and user targets with post, comment, community, and user/profile rows.

**v0.0**

- Initial release.

### 🆘 Support

For issues, questions, or feature requests, [file a ticket](https://console.apify.com/actors/maximedupre~reddit-scraper/issues) and I'll fix or implement it in less than 24h 🫡

### 🔗 Related Actors

- [Reddit Comments Search Scraper](https://apify.com/maximedupre/reddit-comments-search-scraper): search public Reddit comments by keyword, with an optional subreddit filter.
- [Reddit Historical Archive Scraper for Posts and Comments](https://apify.com/maximedupre/reddit-historical-archive-scraper): collect Reddit posts and comments from past date ranges for long-range research.
- [Reddit Media Downloader](https://apify.com/maximedupre/reddit-media-downloader): get video, image, GIF, and gallery links from Reddit post URLs.
- [Reddit User Scraper - Profiles, Karma & Post History ($1.5/1k)](https://apify.com/harshmaur/reddit-user-scraper): build profile, karma, and post history datasets for Reddit users.
- [Reddit Comment Scraper - Export Comments & Replies ($1.5/1k)](https://apify.com/harshmaur/reddit-comments-scraper): export comment and reply threads from Reddit posts.

**Made with ❤️ by Maxime Dupré**

# Actor input Schema

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

Add one or more Reddit search phrases.

## `searchCommunityName` (type: `string`):

Focus keyword search inside one subreddit, such as r/artificial. Leave empty to search all of Reddit.

## `searchResultType` (type: `string`):

Choose which result types to return for each search query.

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

Choose how Reddit ranks post search results.

## `commentSort` (type: `string`):

Choose how Reddit ranks comment search results.

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

Limit search results to a Reddit time window.

## `dateFrom` (type: `string`):

Keep search results created on or after this date.

## `dateTo` (type: `string`):

Keep search results created on or before this date.

## `maxDaysOld` (type: `integer`):

Keep search results from the last number of days. Set 0 to turn this off. Date fields take priority when filled.

## `includeNSFW` (type: `boolean`):

Include Reddit search results marked as NSFW or over 18.

## `strictSearch` (type: `boolean`):

Filter saved search rows toward records that clearly match the search phrase.

## `collectCommentsUnderSearchPosts` (type: `boolean`):

Also collect comment threads under post results found by search queries.

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

Add Reddit post, comment, subreddit, user, popular, or search URLs.

## `subredditNames` (type: `array`):

Add subreddit names or r/name handles.

## `subredditSort` (type: `string`):

Choose which subreddit feed to collect.

## `subredditTime` (type: `string`):

Choose the time window when subreddit feed sort is Top.

## `collectCommentsUnderSubredditPosts` (type: `boolean`):

Also collect comment threads under posts from subreddit feeds.

## `userNames` (type: `array`):

Add Reddit usernames or u/name handles.

## `userActivity` (type: `string`):

Choose which public activity rows to collect from user profiles.

## `postRowLimit` (type: `integer`):

Maximum post rows to save for each search query, subreddit, user, or listing URL. Leave empty or set 0 to save all available post rows.

## `commentRowLimit` (type: `integer`):

Maximum comment rows to save for each search query, user, comment URL, or search URL. Leave empty or set 0 to save all available comment rows.

## `commentsPerExpandedPost` (type: `integer`):

Maximum comments to save under each post when comment collection is turned on in a section. Set 0 to save all comments under each post.

## Actor input object example

```json
{
  "searchQueries": [
    "openai",
    "chatgpt",
    "openai api"
  ],
  "searchCommunityName": "r/artificial",
  "searchResultType": "postsAndComments",
  "sort": "new",
  "commentSort": "new",
  "time": "all",
  "maxDaysOld": 30,
  "includeNSFW": false,
  "strictSearch": false,
  "collectCommentsUnderSearchPosts": false,
  "startUrls": [
    {
      "url": "https://www.reddit.com/r/artificial/"
    },
    {
      "url": "https://www.reddit.com/r/OpenAI/search/?q=gpt-5&restrict_sr=1"
    }
  ],
  "subredditNames": [
    "r/artificial",
    "OpenAI"
  ],
  "subredditSort": "hot",
  "subredditTime": "all",
  "collectCommentsUnderSubredditPosts": true,
  "userNames": [
    "u/spez"
  ],
  "userActivity": "postsAndComments",
  "postRowLimit": 10,
  "commentRowLimit": 10,
  "commentsPerExpandedPost": 5
}
```

# Actor output Schema

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

Scraped Reddit posts, comments, communities, and user profiles.

# 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 = {
    "searchQueries": [
        "openai",
        "chatgpt",
        "openai api"
    ],
    "searchCommunityName": "r/artificial",
    "startUrls": [
        {
            "url": "https://www.reddit.com/r/artificial/"
        },
        {
            "url": "https://www.reddit.com/r/OpenAI/search/?q=gpt-5&restrict_sr=1"
        }
    ],
    "subredditNames": [
        "r/artificial",
        "OpenAI"
    ],
    "userNames": [
        "u/spez"
    ],
    "postRowLimit": 10,
    "commentRowLimit": 10,
    "commentsPerExpandedPost": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("maximedupre/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 = {
    "searchQueries": [
        "openai",
        "chatgpt",
        "openai api",
    ],
    "searchCommunityName": "r/artificial",
    "startUrls": [
        { "url": "https://www.reddit.com/r/artificial/" },
        { "url": "https://www.reddit.com/r/OpenAI/search/?q=gpt-5&restrict_sr=1" },
    ],
    "subredditNames": [
        "r/artificial",
        "OpenAI",
    ],
    "userNames": ["u/spez"],
    "postRowLimit": 10,
    "commentRowLimit": 10,
    "commentsPerExpandedPost": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("maximedupre/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 '{
  "searchQueries": [
    "openai",
    "chatgpt",
    "openai api"
  ],
  "searchCommunityName": "r/artificial",
  "startUrls": [
    {
      "url": "https://www.reddit.com/r/artificial/"
    },
    {
      "url": "https://www.reddit.com/r/OpenAI/search/?q=gpt-5&restrict_sr=1"
    }
  ],
  "subredditNames": [
    "r/artificial",
    "OpenAI"
  ],
  "userNames": [
    "u/spez"
  ],
  "postRowLimit": 10,
  "commentRowLimit": 10,
  "commentsPerExpandedPost": 5
}' |
apify call maximedupre/reddit-scraper --silent --output-dataset

```

## MCP server setup

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