# Reddit  Explorer 3.1 (`jupri/reddit`) Actor

💫 All-in-One Reddit.com Scraper 🟪🟦🟩🟨🟧🟥

- **URL**: https://apify.com/jupri/reddit.md
- **Developed by:** [cat](https://apify.com/jupri) (community)
- **Categories:** Social media, Videos, Automation
- **Features:** Full permissions
- **Stats:** 328 total users, 0 monthly users, 93.5% runs succeeded, 15 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## Welcome to Reddit Explorer

<img src="https://static5.depositphotos.com/1001046/514/v/450/depositphotos_5148743-stock-illustration-outline-illustration-of-sitting-cat.jpg" width="240">
<img src="https://upload.wikimedia.org/wikipedia/en/b/bd/Reddit_Logo_Icon.svg" width="64">

### 🤖 About Reddit.com

<img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Reddit_logo.svg" width="240">

**Reddit** ([/ˈrɛdɪt/](https://en.wikipedia.org/wiki/Help:IPA/English "Help:IPA/English")) is an American [social news](https://en.wikipedia.org/wiki/Social_news "Social news")  [aggregation](https://en.wikipedia.org/wiki/News_aggregator "News aggregator"), [content rating](https://en.wikipedia.org/wiki/Review_site#Rating_site "Review site"), and [discussion website](https://en.wikipedia.org/wiki/Internet_forum "Internet forum"). Registered users (commonly referred to as "redditors") submit content to the site such as links, text posts, images, and videos, which are then [voted up or down](https://en.wikipedia.org/wiki/Reddit#AnchorVote) by other members. Posts are organized by subject into user-created boards called "communities" or "subreddits". Submissions with more upvotes appear towards the top of their subreddit and, if they receive enough upvotes, ultimately on the site's front page. Reddit administrators moderate the communities. Moderation is also conducted by community-specific moderators, who are not Reddit employees.[\[8\]](https://en.wikipedia.org/wiki/Reddit#cite_note-Ohlheiser-11) It is operated by **Reddit Inc.**, based in [San Francisco](https://en.wikipedia.org/wiki/San_Francisco "San Francisco").[\[9\]](https://en.wikipedia.org/wiki/Reddit#cite_note-12)

### 🤖 Tutorial

#### 👉 Parameters

| Parameter | Type |  Description |
|-|-|-|
| `query` | ***string array*** | List of `Query`, Search Terms or `URL` |
| `limit` | ***integer*** | Number of results (per-query)|

#### 👉 Basic Usage

Search anything

```yaml
{ "query": ["square pants"], "limit": 20 }
```

`URL` Scrape  subreddit (space) posts

```yaml
{ "query": ["https://www.reddit.com/r/Python/"], "limit": 20 }
```

`URL` Scrape user posts

```yaml
{ "query": ["https://www.reddit.com/user/ElonMusk/"], "limit": 20 }
```

#### 👉 Advanced Usage

##### Reddit Query Language (RDQL) :

```html
[ <COMMAND:> | # | @ ] [ <NAME> | <ID> | <KEYWORD> | <URL> ] [ /<SECTION> ] 
```

#### Possible `QUERY` Values

| Format | Example | Description |
|-|-|-|
| **<*KEYWORD*>** | `search terms` | ***Search Anything*** |
| `text:` | `text:web scraping` | Search text posts |
| `media:` |`media:sponge bob` | Search media |
| `video:` |`video:star trek` | Search video |
| `image:` |`image:nature` | Search image |
| **#<*FLAIR*>** | `#python` | ***Search Flair (`aka. Hashtag`)*** |
| **space:<*SPACE*>** | `space:Python` | ***Scrape Subreddit Data*** |
| `/posts` | `space:Python/posts` | Space/Subreddit/Community posts |
| **<*POST_ID*>** | `t3_xxxxxxx` | ***Scrape Post Data*** |
| `/info` | `t3_xxxxxxx/info` | Post content |
| `/comments` | `t3_xxxxxxx/comments` | Post comments |
| **@<*USER*>** | `@google` | ***Scrape User data*** |
| `/info` | `@google/info` | User info |
| `/posts` | `@google/posts` | User posts |
| `/comments` | `@google/comments` | User comments |
| **https:<*URL*>** | `https://www.reddit.com` | ***Start URL*** |
|| `https://www.reddit.com/user/ ...` ||
|| `https://www.reddit.com/u/ ...` ||
|| `https://www.reddit.com/r/ ...` ||
| **/<*API*>?<*PARAMS*>** | `/search?q=apify&limit=10` | **Directly Access Reddit API**<br> <https://www.reddit.com/dev/api> |
| | `/r/apify/about` | |
| | `/r/apify/about/moderators?limit=5` | |
| | `/best?limit=10` | |
| | `/hot?limit=20` | |
| **👉 `Object-ID`** | | |
| **t2_xxxxxx** | `t2_xxxxxx/info` | **_Scrape User Data_** |
| **t3_xxxxxx** | `t3_xxxxxx/comments`| **_Scrape Post Data_** |
| **t5_xxxxxx** | `t5_xxxxxx/posts` | **_Scrape Subreddit Data_** |

### 🤖 Input Examples

#### 👉 Example #1: Scrape User Data

User info

```yaml
{ "query": ["@google/info"] }
```

Or using its `User-ID`

```yaml
{ "query": ["t2_2yutkjzv/info"] }
```

User posts

```yaml
{ "query": ["@google/posts"], "limit": 20 }
```

#### 👉 Example #2: Flair `(aka. Hashtag)`,  Subreddit `(aka. Space aka. Community)`

Searching Hashtag

```yaml
{ "query": ["#python"], "limit": 10 }
```

### 🤖 Output Examples

`... almost there ...`

### 🤖 Reddit FAQ

***(1) What is Flair?***

A flair is a **tag** that can be added to threads posted on the reddit website within a sub-reddit\*\*. They help users understand the category to which the posts belong to and help readers filter specific kind of posts based on their preferences

***(2) What is Subreddit ?***

Subreddits are subsidiary threads or categories within the Reddit website. They allow users to focus on a specific interest or topic in posting content that gets voted up or down by relevance and user preference.

***(3) What is a Reddit Crosspost?***

Crossposting is an easy way to take a post from one community and share it with another community.

***(4) What is Types of Thing ?***

|Type| Name |
|-|-|
|`t1`|Comment|
|`t2`|Account|
|`t3`|Post/Link|
|`t4`|Message|
|`t5`|Subreddit|
|`t6`|Award|
|`t8`|PromoCampaign|

### 🤖 Support

⚡️ Feel free to [reach out](https://console.apify.com/actors/4YJmyaThjcRuUvQZg/issues) to the developer for any [issues](https://console.apify.com/actors/4YJmyaThjcRuUvQZg/issues) or suggestions for improvement.

<img src="https://apify-uploads-prod.s3.us-east-1.amazonaws.com/5SxZhwYwpknFk8ek9-cat.gif" width="240">

# Actor input Schema

## `query` (type: `array`):

💡 <b> Query, Search Terms or URL

## `example` (type: `string`):

💡 QUERY input examples

## `search_mode` (type: `string`):

💡 Type of Products

## `limit` (type: `integer`):

💡 Number of results (per query)

## `filters.types` (type: `array`):

💡 For <b>posts</b> search <i><code>(mode=posts)</code></i>

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

No description

## `filters.timing` (type: `string`):

No description

## `filters.safe` (type: `boolean`):

💡 Exclude NSFW contents

## `filters.title` (type: `string`):

💡 The submission title

## `filters.text` (type: `string`):

💡 The body of the post

## `filters.author` (type: `string`):

💡 The user(s) who submitted the post, separated by space, without /u prefix<br><b>example:</b> <code>"elonmusk billgates"</code>

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

💡 The submission's subreddit(s) separated by space, without /r prefix<br><b>example:</b> <code>"Python JavaScript"</code>

## `filters.flair` (type: `string`):

💡 The text of the link flair(s) on the post<br><b>example:</b> <code>"webscraping"</code>

## `filters.site` (type: `string`):

💡 The domain(s) of the submitted URL<br><b>example:</b> <code>"youtube.com"</code>

## `filters.url` (type: `string`):

💡 The submission's URL (the website's address)

## `dev_proxy_config` (type: `object`):

💡 <b>Supported protocol:</b><br><br><b>HTTP(S), SOCKS5</b><br><code>{http|socks5}://{user:pass}@{hostname|ip-address}:port</code><br><br><b>Example</b>: <code>socks5://example.com:9000</code>

## `dev_custom_headers` (type: `array`):

💡 Additional HTTP Headers

## `dev_custom_cookies` (type: `array`):

💡 Additional HTTP Cookies

## `dev_transform_fields` (type: `array`):

💡 <b>Transform the resulting output. Select only needed fields.</b><br><br>For nested object use <b>DOT</b>. For example: <pre>address.streetAddress</pre><br>For nested array use <b>NUMBER</b> <i>(index of array element starting from index=0)</i>. For example: <pre>images.0.url</pre>

## `dev_dataset_name` (type: `string`):

💡 <b>Save results into custom named Dataset, use mask to customize dataset name</b><br><br><code>{ACTOR} = actor name<br>{DATE} = date (YYYYMMDD)<br>{TIME} = time (HHMMSS)</code><br><br>This masks can be used to autogenerate Dataset Name.<br><br>example: <i><code>data-{DATE}</code></i><br>Depending on today date the dataset name will be: <code>data-20230603</code><i><br><br>default: <code>data-{ACTOR}-{DATE}-{TIME}</code></i>

## `dev_dataset_clear` (type: `boolean`):

Clear Dataset before insert/update.

## `dev_no_strip` (type: `boolean`):

💡 Keep/Save empty values <i><code>(NULL, FALSE, empty ARRAY, empty OBJECT, empty STRING)</code></i>

## Actor input object example

```json
{
  "query": [
    "square pants"
  ],
  "limit": 5
}
```

# 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 = {
    "query": [
        "square pants"
    ],
    "limit": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("jupri/reddit").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 = {
    "query": ["square pants"],
    "limit": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("jupri/reddit").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 '{
  "query": [
    "square pants"
  ],
  "limit": 5
}' |
apify call jupri/reddit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jupri/reddit"
        }
    }
}
```

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/4YJmyaThjcRuUvQZg/builds/rzM5fKxvoqduwjZmN/openapi.json
