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

Unlimited Reddit scraper for posts, comments, communities, and users — no login. India Apify residential proxy is always enabled (not configurable). Search or paste URLs, sort, date filters, media links, MCP-ready.

- **URL**: https://apify.com/social\_developer/reddit-scraper.md
- **Developed by:** [Celine](https://apify.com/social_developer) (community)
- **Categories:**
- **Stats:** 4 total users, 3 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

#### What does Reddit Scraper do?

Our unofficial Reddit API will get data from [Reddit](https://www.reddit.com/) with no limitations or authentication. It enables you to extract posts and comments together with some user info without login. It is built on top of [Apify SDK](https://docs.apify.com/sdk/js/), and you can run it both on the [Apify platform](http://console.apify.com).

Reddit Scraper allows you to:

- **scrape subreddits** (communities) with top posts
- **scrape Reddit posts** with title and text, username, number of comments, votes, media elements.
- **get Reddit comments,** timestamps, points, usernames, post and comment URLs.
- **scrape user details**, their most recent posts and comments.
- sort scraped data **by categories** of Relevance, Hot, Top, and New.
- scrape data using a specific URL or by keyword.

#### What data can I extract from Reddit?

| | |
|---|---|
| 📌 Popular subreddits | 🔍 Subreddit details |
| 📋 Subreddit name | 👥 Number of members |
| 🌐 Community URL | 📚 Category |
| 📌 Reddit posts | 💬 Reddit comments |
| 📃 Title and text | ⏱ Timestamps |
| 👤 Username | 🔗 Post and comment URLs |
| 👍 Votes | 📷 Media elements |
| 👤 User details | 📄 Recent posts and comments |

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

Reddit Scraper on the [Apify platform](https://console.apify.com/) will give you **1,000 results for less than $4 in platform usage credits**. That should be covered by the free $5 in monthly credits you get on every Apify Free plan.

But if you need to get more data regularly from Reddit, you should grab an [Apify subscription](https://apify.com/pricing). We recommend our $49/month Starter plan - with that one, you can get well over 10,000 results every month! [Watch this video](https://www.youtube.com/watch?v=-wyz2iscZ30) for a few helpful tips on how to pick a plan.

#### How to scrape Reddit?

Reddit Scraper doesn't require any coding skills to start using it.

1. Create a [free Apify account](https://console.apify.com/) using your email.
2. Open the [Reddit Scraper](https://console.apify.com/actors/zlR20fSbt49gNMNzg).
3. Add one or more full Reddit URLs (for subreddits/communities, users, or posts) to the **Start URLs** field, or enter a keyword in the **Search Term** field.
4. Click "Start" and wait for the scraper to extract the data.
5. Download your data in JSON, XML, CSV, Excel, or HTML format.

If you're unsure where to start, just follow our [step-by-step guide](https://blog.apify.com/how-to-scrape-reddit/) or see our [short video tutorial](https://youtu.be/BmD53kvskS0). The tutorial steps can be also be used for [Reddit Scraper Lite](https://apify.com/trudax/reddit-scraper-lite).

[Watch the video](https://youtu.be/BmD53kvskS0)

##### How to use scraped Reddit data

- Keep track of **discussions about your brand** or product across Reddit communities.
- **Research** the topics that interest you and get a wide range of opinions.
- Keep an eye on debates over **high stakes subjects** such as finance, politics, new technology, and news in general.
- **Watch out for new trends**, attitudes, and PR opportunities.
- **Automatically track mentions** of the business or topic that interests you.
- **Scrape Reddit comments** to kick off and support your sentiment analysis.

#### Input parameters

To run this Actor successfully, you **must provide at least one of the following required fields**:

1. **Start URLs** (`startUrls`): An array of objects containing full Reddit URLs to scrape (e.g., `[{"url": "https://www.reddit.com/r/pasta/"}]`).
2. **Search Term** (`searches`): An array of search query strings to search Reddit's topics (e.g., `["pasta"]`).

If both fields are empty, the actor will fail with an **"Invalid input"** error.

> **IMPORTANT**
>
> - **Ignore Search parameters when using Start URLs**: When **Start URLs** are provided, all **Search** parameters (Search Term, Sort, Filter by date, etc.) are ignored. If you want to use the search functionality, make sure the **Start URLs** field is empty. Alternatively, you can perform a search directly on Reddit, apply the desired filters, and then copy the resulting URL into the **Start URLs** field.

##### How to scrape Reddit by URLs

Almost any URL from Reddit will return a dataset. If the URL is not supported, the scraper will display a message before scraping the page.

##### Input examples

Here are some examples of URLs that can be scraped.

- scraping communities: https://www.reddit.com/r/worldnews/
- scraping channels within communities: https://www.reddit.com/r/worldnews/hot
- scraping popular communities: https://www.reddit.com/subreddits/leaderboard/crypto/
- scraping users: https://www.reddit.com/user/lukaskrivka
- scraping user comments: https://www.reddit.com/user/lukaskrivka/comments/
- scraping posts: https://www.reddit.com/r/learnprogramming/comments/lp1hi4/is\_webscraping\_a\_good\_skill\_to\_learn\_as\_a\_beginner/
- scraping popular posts: https://www.reddit.com/r/popular/
- scraping search results:
  - for users/communities: https://www.reddit.com/search/?q=news\&type=communities,people
  - for posts: https://www.reddit.com/search/?q=news

Note: if you use a `search URL` as a parameter for `startUrls`, it will only scrape for posts. If you want to search for communities and users, use the `search` field or a specific URL instead.

##### How to scrape Reddit by search term

- **Search Term** or `searches` - the keywords you want to search via the Reddit's search engine. You can keep one field or add as many as you want. Don't use this field if you're using the `startUrls` parameter.
- **Community** or `searchCommunityName` - If provided, the search will be performed only inside this community (e.g., 'programming').

##### Advanced parameters

- **Include NSFW content** or `includeNSFW` - Toggle to include or exclude NSFW (Not Safe For Work) content from your search results.

- **Include media links, up votes and comment count** or `includeMediaLinks` - If enabled, the scraper will extract more detailed information for posts, including `upVotes`, `upVoteRatio`, `imageUrls`, `videoUrls`, and `numberOfComments`. This parameter is disabled by default to improve performance, as it uses a more detailed extraction method.

- **Search for posts** or `searchPosts` - If enabled, the scraper will search for posts matching the keyword.

- **Search for comments** or `searchComments` - If enabled, the scraper will search for comments matching the keyword.

- **Search for communities** or `searchCommunities` - If enabled, the scraper will search for communities matching the keyword.

- **Search for users** or `searchUsers` - If enabled, the scraper will search for users matching the keyword.

- **Search for media** or `searchMedia` - If enabled, the scraper will search for media (images/videos) matching the keyword.

- **Skip comments** or `skipComments` - If enabled, the scraper will not extract comments when scraping posts.

- **Skip user posts** or `skipUserPosts` - If enabled, the scraper will not extract user posts when scraping user profiles.

- **Skip community** or `skipCommunity` - If enabled, the scraper will not extract community details when scraping communities.

- **Debug Mode** or `debugMode` - If enabled, the scraper will output detailed logs to help with debugging.

- **Navigation timeout** or `navigationTimeout` - Set the time the actor will wait for the page to be ready for navigation (between 20 and 60 seconds).

- **Page scroll timeout** or `scrollTimeout` - Set the timeout in seconds for how long the page should scroll down to load new items.

- **Ignore start URLs** or `ignoreStartUrls` - If enabled, the scraper will ignore the `startUrls` field. This is mainly used as a fix for integrations like Zapier.

- **Sort search** or `sort` - will sort search results by Relevance, Hot, Top, New or most amount of Comments.

- **Filter by date** or `time` - will filter the search by the last hour, day, week, month or year. Only available if you're scraping Posts.

- **Post date limit** or `postDateLimit` - Use this value to only retrieve posts published after a specific date. When this parameter is used, the 'Sort search' (`sort`) parameter will automatically be set to 'New' to ensure chronological consistency.

- **Comment date limit** or `commentDateLimit` - Use this value to only retrieve comments published after a specific date inside a post.

To see the full list of parameters, their default values, and how to set the values of your own, head over to [Input Schema tab](https://console.apify.com/actors/zlR20fSbt49gNMNzg/information/latest/input).

##### Input example

###### Using Search with Media Links

This is an example of how to scrape posts with detailed media information and votes.

```json
{
  "searches": ["parrots"],
  "includeMediaLinks": true,
  "maxPostCount": 10
}
```

###### Using Search

This is an example of how your input will look like if you decide to scrape all Reddit communities that contain the keyword *parrot*. Results will be sorted by the newest first.

```json
{
  "maxItems": 10,
  "maxPostCount": 10,
  "maxComments": 10,
  "maxCommunitiesCount": 10,
  "maxUserCount": 10,
  "scrollTimeout": 40,
  "navigationTimeout": 30,
  "searches": ["parrots"],
  "searchCommunities": true,
  "searchPosts": false,
  "sort": "new",
  "time": "all"
}
```

###### Using Start URLs

This is an example of how your input will look like if you decide to scrape a specific community and a specific post.

```json
{
  "maxItems": 10,
  "maxPostCount": 10,
  "maxComments": 10,
  "scrollTimeout": 40,
  "navigationTimeout": 30,
  "startUrls": [
    { "url": "https://www.reddit.com/r/pasta/" },
    {
      "url": "https://www.reddit.com/r/pasta/comments/vwi6jx/pasta_peperoni_and_ricotta_cheese_how_to_make/"
    }
  ]
}
```

#### Results

The output from scraping Reddit is stored in the dataset. Each post, comment, user or community is stored as an item inside the dataset. After the run is finished, you can download the scraped data onto your computer or export to any web app in various data formats (JSON, CSV, XML, RSS, HTML Table). Here's a few examples of the outputs you can get for different types of inputs:

> **Note:** Many detailed fields are only extracted when `includeMediaLinks` is set to `true` in the input. If this parameter is `false` (default), the scraper uses fast RSS feeds which omit or limit: `upVotes`, `upVoteRatio`, `numberOfComments`, `imageUrls`, `videoUrls`, `authorFlair`, `flair`, `userId`, `isVideo`, `isAd`, and `over18`.

##### 📝 Example Reddit post

```json
{
  "id": "t3_144w7sn",
  "parsedId": "144w7sn",
  "url": "https://www.reddit.com/r/HonkaiStarRail/comments/144w7sn/my_luckiest_10x_pull_yet/",
  "username": "YourKingLives",
  "userId": "t2_78abc123",
  "title": "My Luckiest 10x Pull Yet",
  "communityName": "r/HonkaiStarRail",
  "parsedCommunityName": "HonkaiStarRail",
  "body": "...",
  "html": "...",
  "numberOfComments": 42,
  "upVotes": 1500,
  "upVoteRatio": 0.98,
  "authorFlair": "Trailblazer",
  "isVideo": false,
  "isAd": false,
  "over18": false,
  "imageUrls": [
    "https://preview.redd.it/yod3okjkgx4b1.jpg?auto=webp&s=be5faf0250e19138b82c7bbe5e7406fa46da4e73"
  ],
  "videoUrls": [],
  "createdAt": "2023-06-09T05:23:15.000Z",
  "scrapedAt": "2023-06-09T05:23:28.409Z",
  "dataType": "post"
}
```

##### 💬 Example Reddit comment

```json
{
  "id": "t1_jnhqrgg",
  "parsedId": "jnhqrgg",
  "url": "https://www.reddit.com/r/NewsWithJingjing/comments/144v5c3/theres_no_flag_large_enough/jnhqrgg/",
  "parentId": "t3_144v5c3",
  "username": "smokecat20",
  "authorFlair": "Patriot",
  "category": "NewsWithJingjing",
  "communityName": "r/NewsWithJingjing",
  "body": "A true patriot.",
  "createdAt": "2023-06-09T05:00:00.000Z",
  "scrapedAt": "2023-06-09T05:23:32.025Z",
  "upVotes": 3,
  "numberOfReplies": 0,
  "html": "&lt;div class=\"md\"><p>A true patriot.</p>\n</div>",
  "dataType": "comment"
}
```

##### 👥 Example Reddit community

```json
{
  "id": "2qlhq",
  "name": "t5_2qlhq",
  "title": "Pizza",
  "headerImage": "https://b.thumbs.redditmedia.com/jq9ytPEOecwd5bmGIvNQzjTPE9hdd0kB9XGa--wq55A.png",
  "description": "The home of pizza on reddit. An educational community devoted to the art of pizza making.",
  "over18": false,
  "createdAt": "2008-08-26T00:03:48.000Z",
  "scrapedAt": "2023-06-09T05:16:55.443Z",
  "numberOfMembers": 569724,
  "url": "https://www.reddit.com/r/Pizza/",
  "dataType": "community"
}
```

##### 👤 Example Reddit user

```json
{
  "id": "c3h2qmv",
  "url": "https://www.reddit.com/user/jancurn/",
  "username": "jancurn",
  "userIcon": "https://www.redditstatic.com/avatars/defaults/v2/avatar_default_7.png",
  "postKarma": 4,
  "commentKarma": 10,
  "description": "",
  "over18": false,
  "createdAt": "2018-09-10T15:13:39.000Z",
  "scrapedAt": "2023-06-09T05:21:14.409Z",
  "dataType": "user"
}
```

#### Only need a few Reddit results?

Use our super fast dedicated **[Reddit Scraper Lite](https://apify.com/trudax/reddit-scraper-lite)** if you want to scrape Reddit data on a smaller scale. Just enter one or more Reddit URLs or keywords and click to scrape.

#### Notes for developers

##### Reddit's 1,000 items limit

When browsing Reddit, you might notice that any list (like a subreddit's "New" posts or a user's comments) usually stops after about 1,000 items. This is not a limitation of the scraper, but a standard way Reddit handles its data across its entire platform.

**Note:** This limit only applies to lists of posts or search results. It does **not** affect the comments inside a specific post; the scraper will still be able to extract all available comments within a single post URL, even if there are thousands of them.

If you need to gather more than 1,000 results from a list, here are some effective ways to get more data:

- **Combine different sorts**: Scrape the "New" category first, then "Top", "Hot", and "Controversial". This often uncovers thousands of unique posts.
- **Use Search**: Searching for specific keywords often brings up older posts that are no longer visible in the main lists.
- **Time Filters**: Use the search parameters to filter by "last year", "last month", etc., to reveal different sets of data.
- **Date Limits**: Use the postDateLimit or commentDateLimit for incremental scraping (e.g., daily runs) to capture all data over time before it falls off the 1,000-item limit.

##### Limiting results with maxItems

If you need to limit the scope of your search, you can do that by setting the max number of posts you want to scrape inside a community or user. You can also set a limit to the number of comments for each post. You can limit the number of communities and users by using the following parameters:

```json
{
  "maxItems": 100,
  "maxPostCount": 50,
  "maxComments": 10,
  "maxCommunitiesCount": 5,
  "maxUserCount": 5
}
```

> **Note:** The maximum value allowed for all numeric limit and timeout parameters is **2,147,483,647** (the 32-bit signed integer limit). Any value exceeding this will be automatically capped to ensure system stability.

You can also set `maxItems` to prevent a very long run of the Actor. This parameter will stop your scraper when it reaches the number of results you've indicated, so you need to be careful not to trim your results.

See the [Input Schema tab](https://console.apify.com/actors/zlR20fSbt49gNMNzg/information/latest/input) for the full list of the ways to restrict Reddit Scraper using these parameters:
`maxItems`, `maxPostCount`, `maxComments`, `maxCommunitiesCount`, `maxUserCount`

##### Improving actor speed

If you want to speed up your Actor runs, consider the following strategies:

- **Adjust `navigationTimeout`**: If you have many requests failing because of navigation timeouts, you can reduce `navigationTimeout` in the input so that requests are retried faster. Note that this has the side effect of potentially increasing the failure rate if a page is not loaded in time, but it can work well in some cases.
- **Increase Run Memory**: If you have multiple `startUrls` or searches, increasing the run memory can increase concurrency and therefore also reduce the time the Actor takes to process all requests.

#### FAQ

##### Is Reddit scraping legal?

While scraping publicly available data from Reddit is generally allowed, it's important to comply with Reddit's terms of service and respect the site's usage policies. It's recommended to use the scraper responsibly, avoid excessive requests, and ensure that the scraped data is used in compliance with applicable laws and regulations. You can read more about compliance with ToS [in our blogpost](https://blog.apify.com/enforceability-of-terms-of-use/).

##### Can I use Reddit API to scrape Reddit?

The Reddit API is currently free. However, Reddit has specific API rules, and free access to the API will be restricted in the future due to concerns over data usage. In addition, Reddit API has been recently announced to become [a paid service](https://techcrunch.com/2023/04/18/reddit-will-begin-charging-for-access-to-its-api). Using a Reddit web scraper such as this one as an API has advantages such over the official one such as not requiring authentication, special authorization for commercial use, or registration for a token.

##### How can I scrape Reddit comments?

Reddit Scraper allows scraping specific parts of Reddit, including comments. You can extract posts and comments along with user information, such as timestamps, number of votes, usernames, post URL, and comment URLs. This enables you to gather comprehensive commment data from subreddits and Reddit users.

##### Is it necessary to use cookies for accessing logged-in content when scraping Reddit?

No, it is not required. As of May 2023, Reddit maintains its data publicly accessible and does not enforce a login barrier.

##### Do you need proxies for scraping Reddit?

It is highly recommended. Subreddits are open for access and do not require a login to retrieve information. Typically, using proxies is necessary to ensure successful Reddit scraping. While some results can be obtained with datacenter proxies, residential proxies are preferred for Reddit scraping. Fortunately, our Free plan offers a trial of [Apify Proxy](https://apify.com/proxy), which get you started.

##### Can I export or import scraped Reddit data using API?

Yes. The Apify API gives you programmatic access to the Apify platform. The API is organized around RESTful HTTP endpoints that enable you to manage, schedule, and run any Apify Actor, including this one. The API also lets you access any datasets, monitor Actor performance, fetch results, create and update versions, and more.

To access the API using Node.js, use the `apify-client` NPM package. To access the API using Python, use the `apify-client` PyPi package.

Check out the [Apify API reference docs](https://docs.apify.com/api/v2) for full details or click on the [API tab](https://console.apify.com/actors/zlR20fSbt49gNMNzg) for code examples.

##### Why can't I get more than 1,000 posts from a subreddit or search?

This is a standard behavior of the Reddit platform. Any list you see on Reddit (like the "New" posts in a community or search results) usually only goes back about 1,000 items. This is not a limitation of the scraper itself, but how Reddit makes its data available.

However, this **does not affect comments**. If you have a link to a specific post, the scraper can still extract all the comments inside it, even if there are thousands. To get more posts, you can try searching for specific keywords or using different sorting options like "Top", "Hot", or filtering by specific time periods.

##### What is the difference between Reddit Scraper and Reddit Scraper Lite?

The functionality of both actor are the same. The difference is that the Lite version charges based on the number of
results it extracts and it has a custom proxy configuration integrated with the actor that is cheaper than then the Residential proxies
used by Apify. The Reddit Scraper version allows you to use either one of Apify\`s proxies or a custom one.

# Actor input Schema

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

If you already have URL(s) of page(s) you wish to scrape, you can set them here. If you want to use the search field below, remove all startUrls here.

## `skipComments` (type: `boolean`):

This will skip scrapping comments when going through posts

## `skipUserPosts` (type: `boolean`):

This will skip scrapping user posts when going through user activity

## `skipCommunity` (type: `boolean`):

This will skip scrapping community info but will still get community posts if they were not skipped.

## `includeMediaLinks` (type: `boolean`):

This will include upVotes, upVoteRatio, imageUrls, videoUrls, and numberOfComments when scraping posts. Enabling this will use a more detailed extraction method, which may affect performance.

## `searches` (type: `array`):

Here you can provide a search query which will be used to search Reddit\`s topics.

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

If provided, the search will be performed only inside this community (e.g., 'programming').

## `ignoreStartUrls` (type: `boolean`):

Mainly used as a fix for ignoring starUrl on Zapier

## `searchPosts` (type: `boolean`):

Will search for posts with the provided search

## `searchComments` (type: `boolean`):

Will search for comments with the provided search

## `searchCommunities` (type: `boolean`):

Will search for communities with the provided search

## `searchUsers` (type: `boolean`):

Will search for users with the provided search

## `searchMedia` (type: `boolean`):

Will search for media with the provided search

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

Sort search by Relevance, Hot, Top, New or Comments

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

Filter posts by last hour, week, day, month or year

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

You can choose to include or exclude NSFW content from your search

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

The maximum number of items that will be saved in the dataset. If you are scrapping for Communities\&Users, remember to consider that each category inside a community is saved as a separated item.

## `maxPostCount` (type: `integer`):

The maximum number of posts that will be scraped for each Posts Page or Communities\&Users URL

## `postDateLimit` (type: `string`):

Use this value to only retrieve posts published after a specific date.

## `commentDateLimit` (type: `string`):

Use this value to only retrieve comments published after a specific date inside a post.

## `maxComments` (type: `integer`):

The maximum number of comments that will be scraped for each Comments Page. If you don't want to scrape comments you can set this to zero.

## `maxCommunitiesCount` (type: `integer`):

The maximum number of `Communities`'s pages that will be scraped if your search or startUrl is a Communities type.

## `maxUserCount` (type: `integer`):

The maximum number of `Users`'s pages that will be scraped.

## `scrollTimeout` (type: `integer`):

Set the timeout in seconds in which the page will stop scrolling down to load new items

## `navigationTimeout` (type: `integer`):

Set the navigation timeout in seconds for page loading

## `maxRequestRetries` (type: `integer`):

The maximum number of times the crawler will retry a failed request.

## `debugMode` (type: `boolean`):

Activate to see detailed logs

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.reddit.com/r/pasta/comments/vwi6jx/pasta_peperoni_and_ricotta_cheese_how_to_make/"
    }
  ],
  "skipComments": false,
  "skipUserPosts": false,
  "skipCommunity": false,
  "includeMediaLinks": false,
  "ignoreStartUrls": false,
  "searchPosts": true,
  "searchComments": false,
  "searchCommunities": false,
  "searchUsers": false,
  "searchMedia": false,
  "sort": "new",
  "includeNSFW": true,
  "maxItems": 10,
  "maxPostCount": 10,
  "maxComments": 10,
  "maxCommunitiesCount": 2,
  "maxUserCount": 2,
  "scrollTimeout": 40,
  "navigationTimeout": 60,
  "maxRequestRetries": 6,
  "debugMode": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

Scraped Reddit data

# 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": [
        {
            "url": "https://www.reddit.com/r/pasta/comments/vwi6jx/pasta_peperoni_and_ricotta_cheese_how_to_make/"
        }
    ],
    "sort": "new",
    "maxItems": 10,
    "maxPostCount": 10,
    "maxComments": 10,
    "maxCommunitiesCount": 2,
    "maxUserCount": 2,
    "scrollTimeout": 40,
    "navigationTimeout": 60,
    "maxRequestRetries": 6
};

// Run the Actor and wait for it to finish
const run = await client.actor("social_developer/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": [{ "url": "https://www.reddit.com/r/pasta/comments/vwi6jx/pasta_peperoni_and_ricotta_cheese_how_to_make/" }],
    "sort": "new",
    "maxItems": 10,
    "maxPostCount": 10,
    "maxComments": 10,
    "maxCommunitiesCount": 2,
    "maxUserCount": 2,
    "scrollTimeout": 40,
    "navigationTimeout": 60,
    "maxRequestRetries": 6,
}

# Run the Actor and wait for it to finish
run = client.actor("social_developer/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": [
    {
      "url": "https://www.reddit.com/r/pasta/comments/vwi6jx/pasta_peperoni_and_ricotta_cheese_how_to_make/"
    }
  ],
  "sort": "new",
  "maxItems": 10,
  "maxPostCount": 10,
  "maxComments": 10,
  "maxCommunitiesCount": 2,
  "maxUserCount": 2,
  "scrollTimeout": 40,
  "navigationTimeout": 60,
  "maxRequestRetries": 6
}' |
apify call social_developer/reddit-scraper --silent --output-dataset

```

## MCP server setup

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