# Reddit Scraper & Keyword Tracker: Posts, Comments, Mentions (`ownscraper/reddit-scraper`) Actor

Scrape Reddit posts by keyword search, list posts from subreddits, or fetch posts by URL, with their comments if you want them. Pay only for saved rows: $0.99 per 1,000 posts or comments.

- **URL**: https://apify.com/ownscraper/reddit-scraper.md
- **Developed by:** [Ownscraper](https://apify.com/ownscraper) (community)
- **Categories:** Social media, AI, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.99 / 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/actors/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: Search, Subreddits, Posts by URL & Comments

![Reddit Scraper: search, subreddits, post URLs and comments. $0.99 per 1,000 results.](https://api.apify.com/v2/key-value-stores/5FuPNoZh2gynlBZMd/records/reddit-scraper-header-v1.gif)

Scrape Reddit by keyword search, list the posts of any subreddit, fetch posts by URL, and collect comments and replies. Export clean JSON, CSV or Excel for **$0.99 per 1,000 results**. A post and a comment cost the same. No login, API key or cookies are needed.

### What you get

| | |
|---|---|
| Four ways to collect | Keyword search, subreddit posts, posts by URL, and comments with replies. Mix them in one run. |
| One row per item | Each post is one row. Each comment is one row, placed right after its post. |
| Price | **$0.99 per 1,000 results**, for posts and comments alike. |
| Access | No Reddit login, API key or cookies. |
| Output formats | JSON, CSV, Excel, XML and HTML, or read the dataset through the Apify API. |

### What does this Reddit scraper do?

Pick any mix of four ways to collect data in one run:

- **Keyword search**: search Reddit, or search inside chosen subreddits, for one or more keywords or exact phrases (up to 50 searches per run).
- **Subreddit posts**: list the posts of one or more subreddits, sorted by hot, new or top.
- **Posts by URL**: paste links to Reddit posts and get each post as one row.
- **Comments and replies**: turn on comments to get the comments of every post, including replies, as separate rows right after the post.

Other things you can do:

- Filter by time frame (hour, day, week, month, year or all time).
- Remove duplicates, so a post or comment found by several searches is saved once.
- Set a limit per search and per post, or set it to 0 for no limit.
- Download the data as JSON, CSV, Excel, XML or HTML, or read it through the Apify API.

The actor works on public Reddit pages only. It does not post, vote or message anyone.

### Quick start

1. Open the Actor in Apify Console and go to the **Input** tab.
2. Enter at least one search term, subreddit or post URL. The default input searches for `mechanical keyboard`.
3. Set `maxResultsPerQuery` to the number of posts you want per search. Turn on `includeComments` if you also want comments.
4. Click **Start**. The status message shows how many posts and comments were saved.
5. Open the **Output** tab to see the table, then use **Export** to download it as JSON, CSV, Excel, XML or HTML.

### What is it used for?

#### Brand and product mentions

Search for your brand or product name, sorted by `new`, and run it on a schedule. You see who talks about you, in which subreddit, and how many people reacted. Quote a phrase to get only posts that contain it.

```json
{
  "queries": ["\"Acme Notes\"", "acme notes app"],
  "sort": "new",
  "timeframe": "week",
  "maxResultsPerQuery": 100
}
```

#### Customer problems and requests

People ask for recommendations and describe problems in plain words. Search for phrases like "looking for an alternative to" inside the subreddits where your customers are, and turn on comments to read the answers.

```json
{
  "queries": ["looking for an alternative to", "any recommendations for"],
  "subreddits": ["SaaS", "smallbusiness"],
  "sort": "new",
  "timeframe": "month",
  "maxResultsPerQuery": 50,
  "includeComments": true,
  "maxCommentsPerPost": 20
}
```

#### Competitor comparison threads

Threads that compare two products show how people choose. Search for "X vs Y" phrases, sort by `top` to see the most discussed threads first, and collect the comments, where most of the reasons are.

```json
{
  "queries": ["\"notion vs obsidian\"", "\"obsidian or notion\""],
  "sort": "top",
  "timeframe": "year",
  "maxResultsPerQuery": 30,
  "includeComments": true,
  "maxCommentsPerPost": 100
}
```

#### Content ideas

List what is doing well in a community. The top posts of a subreddit over a month show the questions and topics people care about. Use the titles and the `score` and `numComments` fields to rank ideas.

```json
{
  "subreddits": ["personalfinance", "r/Frugal"],
  "sort": "top",
  "timeframe": "month",
  "maxResultsPerQuery": 100
}
```

#### Data for LLMs and analysis

The input is plain JSON and the output is a flat list of rows with stable field names. That makes it easy to load into a notebook, a database, a vector store or an AI agent. Collect whole threads for a set of posts, and group them by `postId`.

```json
{
  "postUrls": [
    "https://www.reddit.com/r/AskReddit/comments/abc123/example_title/",
    "https://www.reddit.com/r/AskReddit/comments/def456/another_example/"
  ],
  "includeComments": true,
  "maxCommentsPerPost": 0
}
```

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `queries` | array of strings | prefilled with `mechanical keyboard` | Search terms. A phrase in quotes returns only posts whose title or text contains it. Several words without quotes follow Reddit's search relevance and may not all appear in every post. Leave empty to list the posts of the subreddits instead. Up to 50. |
| `subreddits` | array of strings | empty | Subreddit names, `r/names` or subreddit URLs. With queries, each query is searched inside each subreddit. Without queries, the posts of each subreddit are listed. Leave empty to search all of Reddit. Up to 20. |
| `postUrls` | array of strings | empty | Links to Reddit posts, such as `https://www.reddit.com/r/AskReddit/comments/abc123/title/`. Each post is saved as one row, followed by its comments when `includeComments` is on. Time frame and phrase filters are not applied to post URLs. Links that are not Reddit post links are skipped and not charged. |
| `sort` | string | empty | `relevance`, `hot`, `top`, `new` or `comments`. Left empty, it uses `relevance` for search queries and `new` for subreddit listings. Subreddit listings support `hot`, `new` and `top`; other values use `hot`. |
| `timeframe` | string | empty | `hour`, `day`, `week`, `month`, `year` or `all`. Left empty, it uses `week` for search queries and `all` for subreddit listings. Post URLs are always returned, whatever their date. |
| `maxResultsPerQuery` | integer | `100` (prefilled with `10`) | Upper limit of posts saved for each search or subreddit. `0` means no limit. |
| `includeComments` | boolean | `false` | Also save the comments of each post, including replies, as separate rows right after the post. |
| `maxCommentsPerPost` | integer | `50` (prefilled with `10`) | Upper limit of comments saved for each post. `0` means no limit. |
| `dedupe` | boolean | `true` | Return each post and comment only once, even if several searches find it. |

You need at least one search query, subreddit or post URL. Each query combined with each subreddit, each subreddit listed without a query, and each post URL counts as one search, up to 50 searches per run.

#### Example 1: keyword search

```json
{
  "queries": ["mechanical keyboard", "\"quiet keyboard\""],
  "sort": "new",
  "timeframe": "week",
  "maxResultsPerQuery": 100
}
```

#### Example 2: posts of a subreddit

```json
{
  "subreddits": ["SaaS", "r/startups"],
  "sort": "top",
  "timeframe": "month",
  "maxResultsPerQuery": 200
}
```

#### Example 3: posts by URL, with comments

```json
{
  "postUrls": ["https://www.reddit.com/r/AskReddit/comments/abc123/example_title/"],
  "includeComments": true,
  "maxCommentsPerPost": 100
}
```

#### Example 4: search with comments

```json
{
  "queries": ["looking for an alternative to"],
  "subreddits": ["SaaS"],
  "sort": "new",
  "maxResultsPerQuery": 50,
  "includeComments": true,
  "maxCommentsPerPost": 20
}
```

### Output

The dataset has one row per post or comment. The `type` field tells them apart: `post` or `comment`. A comment row follows the row of its post. The values below are made up for illustration.

Post row:

```json
{
  "type": "post",
  "id": "abc123",
  "url": "https://www.reddit.com/r/example/comments/abc123/looking_for_a_quiet_keyboard/",
  "title": "Looking for a quiet mechanical keyboard",
  "text": "Share an office, any recommendations?",
  "subreddit": "example",
  "author": "example_user",
  "authorId": "t2_example",
  "createdAt": "2026-11-20T09:15:00.000Z",
  "score": 42,
  "numComments": 17,
  "upvoteRatio": 0.96,
  "isNsfw": false,
  "isLocked": false,
  "isArchived": false,
  "linkUrl": null,
  "matchedQuery": "mechanical keyboard",
  "parentId": null,
  "postId": null,
  "postUrl": null,
  "scrapedAt": "2026-11-28T12:00:00.000Z"
}
```

Comment row:

```json
{
  "type": "comment",
  "id": "k9x8y7z",
  "url": "https://www.reddit.com/r/example/comments/abc123/looking_for_a_quiet_keyboard/k9x8y7z/",
  "title": null,
  "text": "Try a board with linear switches and some foam inside.",
  "subreddit": null,
  "author": "another_user",
  "authorId": null,
  "createdAt": "2026-11-20T10:02:00.000Z",
  "score": 8,
  "numComments": null,
  "upvoteRatio": null,
  "isNsfw": null,
  "isLocked": null,
  "isArchived": null,
  "linkUrl": null,
  "matchedQuery": null,
  "parentId": null,
  "postId": "abc123",
  "postUrl": "https://www.reddit.com/r/example/comments/abc123/looking_for_a_quiet_keyboard/",
  "scrapedAt": "2026-11-28T12:00:00.000Z"
}
```

| Field | Description |
|---|---|
| `type` | Row type: `post` or `comment`. |
| `id` | Reddit post or comment ID. |
| `url` | URL of the post or comment on Reddit. |
| `title` | Post title. Null for comments. |
| `text` | Post body or comment text. Empty for link posts without text. |
| `subreddit` | Subreddit name. Null for posts on a user profile and for comments. |
| `author` | Author username. |
| `authorId` | Author account ID. Null for comments. |
| `createdAt` | When the post or comment was created (ISO 8601). |
| `score` | Score. |
| `numComments` | Number of comments on the post. Null for comments. |
| `upvoteRatio` | Share of upvotes on the post, when available. Null for comments. |
| `isNsfw` | Whether the post is marked NSFW. Null for comments. |
| `isLocked` | Whether the post is locked. Null for comments. |
| `isArchived` | Whether the post is archived. Null for comments. |
| `linkUrl` | External URL the post links to. Null for text posts and comments. |
| `matchedQuery` | The search query that found this post. Null for subreddit listings, post URLs and comments. |
| `parentId` | ID of the comment this comment replies to. Null for top-level comments and posts. |
| `postId` | ID of the post this comment belongs to. Null for posts. |
| `postUrl` | URL of the post this comment belongs to. Null for posts. |
| `scrapedAt` | When the row was collected (ISO 8601). |

#### How to read the reply structure

Every comment row carries `postId`, `postUrl` and `parentId`. `postId` tells you which post the comment belongs to, so you can group all rows of one thread with a single key. `parentId` is null for a top-level comment. For a reply, it holds the `id` of the comment it answers. Replies are not nested inside their parents: they are separate flat rows, so join `parentId` to `id` to rebuild the tree.

A comment row follows the row of its post, so a simple sort by `postId` keeps each thread together. Post rows have `postId` and `parentId` set to null.

### How much does it cost to scrape Reddit?

You pay **$0.99 per 1,000 results**, which is $0.00099 per row. One saved row is one result, whether it is a post or a comment. Each run also has a small Actor start fee of $0.00005, which Apify applies to every run of a pay-per-event Actor.

- You do not pay for posts that your filters drop (for example, a quoted phrase that is not in the post, or a post outside the time frame).
- You do not pay for posts that could not be fetched, or for links that are not Reddit post links.
- For a post URL, you pay for the post row, plus one result for each comment row when `includeComments` is on.

Examples:

| Run | Rows | Cost |
|---|---|---|
| 100 posts from a keyword search, no comments | 100 | about $0.10 |
| 1,000 posts from a subreddit, no comments | 1,000 | about $0.99 |
| 10,000 posts or comments, in one or several runs | 10,000 | about $9.90 |
| 100 posts with up to 50 comments each | up to 5,100 | up to about $5.05 |

The amounts are rows times $0.00099, plus the small Actor start fee. The last row is a ceiling: posts with fewer comments cost less.

Because you pay for every saved row, set **Max cost per run** in the run options. The run stops when the limit is reached and keeps everything saved so far.

### Use it from the API

You can start the Actor from your own code with the Apify API. The Actor ID is `ownscraper/reddit-scraper`. Replace `<YOUR_APIFY_TOKEN>` with your own API token from Apify Console.

#### JavaScript

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

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });

const run = await client.actor('ownscraper/reddit-scraper').call({
    queries: ['mechanical keyboard'],
    sort: 'new',
    timeframe: 'week',
    maxResultsPerQuery: 100,
});

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

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")

run = client.actor("ownscraper/reddit-scraper").call(run_input={
    "queries": ["mechanical keyboard"],
    "sort": "new",
    "timeframe": "week",
    "maxResultsPerQuery": 100,
})

items = client.dataset(run["defaultDatasetId"]).list_items().items
print(len(items))
```

#### cURL

This call waits for the run to finish and returns the rows directly. Use it for small runs.

```bash
curl -X POST "https://api.apify.com/v2/acts/ownscraper~reddit-scraper/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"queries": ["mechanical keyboard"], "sort": "new", "timeframe": "week", "maxResultsPerQuery": 100}'
```

For larger runs, start the run without waiting and read the dataset when it finishes. Apify Schedules start the Actor at times you choose, for example every morning. Apify webhooks call a URL of your choice when a run succeeds or fails. Both are general Apify platform features and work with this Actor like any other.

### Tips for getting more results

A keyword search usually runs out at around 200 to 250 posts, so one search term rarely gives you thousands of rows. To collect more, split the work into several searches. Each search counts toward the limit of 50 per run, and duplicates are removed when `dedupe` is on.

- **Split the search terms.** Instead of `keyboard`, use `mechanical keyboard`, `keyboard switches`, `keycaps` and `custom keyboard` as separate queries.
- **Add subreddits.** Each query is searched inside each subreddit you list. `mechanicalkeyboards`, `keyboards` and `MechanicalKeyboardsUK` give three searches from one query.
- **Split the period.** Run the same search with `day`, `week`, `month` and `year` in separate runs, or one run per time frame.
- **Change the sort order.** Run the same query with `new`, `top` and `relevance`. Each order surfaces different posts. Keep `dedupe` on, so a post found by two orders is saved and charged once.

For comments, a post with a very large thread returns only part of its comments (around 1,000). Set `maxCommentsPerPost` to the number you need, and lower it if you only want the top of each thread.

### Limits

- A limit of `0` means no limit, but it does not guarantee every post or comment. You get as many as Reddit returns.
- A keyword search usually runs out at around 200 to 250 posts. If you need more, split it into more queries, subreddits or time frames.
- For posts with very many comments, only part of the comments may be returned (around 1,000).
- We recommend keeping duplicate removal (`dedupe`) on.
- A run can have up to 50 searches, and up to 20 subreddits.
- Comments are saved in the order they are returned. Replies are not nested; follow `parentId` to rebuild the thread.
- Promoted posts that Reddit mixes into a subreddit listing (posts placed on an author's profile) are not returned and are not charged. The number skipped is shown in the run's final status message.

### Free plan limits

Free plan runs are limited so that you can try the actor: 3 searches per run, 25 posts per search, and comments for the first 3 posts only (up to 25 comments each). A limit of `0` or a larger number is capped to these values, and the run still finishes successfully with a message that explains it. Upgrade to a paid Apify plan to remove these limits.

### FAQ

#### Do I need to log in or have a Reddit API key?

No. You do not need a Reddit account, API key or cookies. Enter your search terms, subreddits or post URLs and start the run.

#### How do I follow the replies in a comment thread?

Each comment row has a `parentId`. For a top-level comment it is null; for a reply it is the `id` of the comment it answers. `postId` and `postUrl` point to the post the comment belongs to.

#### Does it remove duplicates?

Yes, when `dedupe` is on (the default). A post or comment is saved only once per run, even if several searches find it.

#### How does the time frame work?

Posts are checked against their creation date before they are saved, for searches and subreddit listings. Posts outside the period are dropped and not charged. If you leave it empty, searches use `week` and subreddit listings use `all`. Posts you pass as URLs are always returned, whatever their date.

#### Does every result contain all my keywords?

Not always. Several words without quotes follow Reddit's search relevance. Put a phrase in quotes to get only posts whose title or text contains it.

#### Why did I get fewer results than I expected?

You get the posts that Reddit returns for your search. A keyword search usually runs out at around 200 to 250 posts, and filters such as quotes or the time frame can drop more. Try a shorter phrase, a longer time frame, or more subreddits.

#### Can I run it on a schedule or use it through the API?

Yes. Use Apify Schedules to run it daily, and the Apify API or webhooks to send the results elsewhere. See "Use it from the API" above for code.

#### Can I get only the comments of a post?

Yes, with a post URL and `includeComments` turned on. The output also contains the row of the post, followed by its comments. Filter on `type` equal to `comment` to keep only the comments. Both kinds of rows are charged.

#### How many levels of replies are included?

Replies are included as separate rows, as many as Reddit returns for the post. The rows are flat, not nested, so read `parentId` to see which comment each reply answers. Very large threads return only part of their comments (around 1,000).

#### Are NSFW posts included?

The actor has no NSFW filter. Post rows have an `isNsfw` field that shows whether the post is marked NSFW, so you can filter on it after the run. The value is null for comments.

#### Am I charged when a run returns no results?

You are charged for saved rows. A run that saves no rows has no result charges. The small Actor start fee for starting the run still applies. When nothing matches, the status message says "No posts matched your search."

#### Can the same post appear twice?

Not with `dedupe` on, which is the default. A post or comment is saved once per run, even if several searches find it. With `dedupe` off, the same post can appear once for each search that finds it. Duplicates are not removed across separate runs.

#### What happens if a run stops in the middle?

Rows already saved stay in the dataset. If the run stops because it reached your Max cost per run, the status message says so. If the data source becomes unavailable after some rows were saved, the run still finishes with those rows and the status message says it stopped early. When a run is restarted by the platform, for example after a migration, it continues from where it stopped.

#### What does the status message tell me?

It shows how many posts and comments were saved. It also reports problems, such as searches that could not be fetched, skipped post URLs, posts removed by your filters, and free plan limits.

#### Why did my run succeed with 0 rows?

A run ends as a success with 0 rows when nothing matched your search, and also when the input had nothing usable. That means no search query, no subreddit and no post URL, or a list of post URLs in which none is a Reddit post link. In that case the status message starts with "Input error:" and says what to fix. Through the API you can read it as `statusMessage` in the run's details. No result charges apply to these runs.

#### Is it legal to scrape Reddit?

The actor collects publicly available posts and comments. Be careful with personal data, and make sure your use follows the law and Reddit's terms where you live. If you are unsure, ask a lawyer.

This actor is not affiliated with, endorsed by, or sponsored by Reddit.

# Actor input Schema

## `queries` (type: `array`):

Search terms. A phrase in quotes returns only posts whose title or text contains it. Several words without quotes follow Reddit's search relevance and may not all appear in every post; use quotes to be sure. Leave empty to list the posts of the subreddits below instead.

## `subreddits` (type: `array`):

Subreddit names, r/names or subreddit URLs. With search queries, each query is searched inside each subreddit. Without search queries, the posts of each subreddit are listed. Leave empty to search all of Reddit.

## `postUrls` (type: `array`):

Links to Reddit posts, such as https://www.reddit.com/r/AskReddit/comments/abc123/title/. Each post is saved as one row, followed by its comments when comments are turned on. Links that are not Reddit post links are skipped and not charged.

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

Order of the results. Left empty, keyword searches use relevance and subreddit listings use new. Subreddit listings support hot, new and top; other values use hot.

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

Only return posts from this period. Leave empty to use week for search queries and all for subreddit listings. Post URLs are always returned, whatever their date.

## `maxResultsPerQuery` (type: `integer`):

Upper limit of posts saved for each search or subreddit. 0 means no limit. You get only as many posts as Reddit returns, so a complete set is not guaranteed: a keyword search usually runs out at around 200 to 250 posts, so split it into more queries, subreddits or time frames if you need more. You pay for every saved row, so we recommend setting a maximum cost per run. Free plan users get up to 25.

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

Also save the comments of each post, including replies, as separate rows right after the post. Each comment row is charged like a post row. Posts without comments are skipped.

## `maxCommentsPerPost` (type: `integer`):

Upper limit of comments saved for each post. 0 means no limit. You get only as many comments as Reddit returns, so a complete set is not guaranteed: for posts with very many comments, only part of them (around 1,000) may be returned. You pay for every saved row, so we recommend setting a maximum cost per run: for example, 100 posts with 50 comments each can save up to 5,100 rows (about $5). Free plan users get up to 25 comments for the first 3 posts.

## `dedupe` (type: `boolean`):

Return each post and comment only once, even if several searches find it.

## Actor input object example

```json
{
  "queries": [
    "mechanical keyboard"
  ],
  "subreddits": [],
  "postUrls": [],
  "maxResultsPerQuery": 10,
  "includeComments": false,
  "maxCommentsPerPost": 10,
  "dedupe": true
}
```

# Actor output Schema

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

Dataset of post and comment rows.

# 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 = {
    "queries": [
        "mechanical keyboard"
    ],
    "maxResultsPerQuery": 10,
    "includeComments": false,
    "maxCommentsPerPost": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("ownscraper/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 = {
    "queries": ["mechanical keyboard"],
    "maxResultsPerQuery": 10,
    "includeComments": False,
    "maxCommentsPerPost": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("ownscraper/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 '{
  "queries": [
    "mechanical keyboard"
  ],
  "maxResultsPerQuery": 10,
  "includeComments": false,
  "maxCommentsPerPost": 10
}' |
apify call ownscraper/reddit-scraper --silent --output-dataset

```

## MCP server setup

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