# Reddit UnOfficial API (`hadidiz/reddit-actions-api`) Actor

Reddit API Post and Comment and Scrapers

- **URL**: https://apify.com/hadidiz/reddit-actions-api.md
- **Developed by:** [Ahmed Elhadidi](https://apify.com/hadidiz) (community)
- **Categories:** Automation, Social media, Developer tools
- **Stats:** 11 total users, 0 monthly users, 0.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

Pay per event

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/platform/actors/running/actors-in-store#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

## Reddit UnOfficial API

**Not Just a Scraper.** A powerful Reddit automation tool to interact with Reddit programmatically.

### 🚀 Features

- **📊 Scrape Posts** - Fetch posts from subreddits or user profiles
- **📝 Create Posts** - Create new posts in any subreddit
- **💬 Comment on Posts** - Add comments to Reddit threads
- **↩️ Reply to Comments** - Reply to specific comments
- **🛡️ Anti-Detection** - Advanced techniques to avoid bot detection
- **🔒 Proxy Support** - Residential & Datacenter proxy options

***

### � Examples for Each Mode

#### 📊 Scrape Mode

Fetch posts from a subreddit or user profile.

```json
{
    "mode": "scrape",
    "target": "python",
    "scrape_type": "subreddit",
    "sort": "hot",
    "time_filter": "week",
    "limit": 25
}
```

**Scraping a user's posts:**

```json
{
    "mode": "scrape",
    "target": "spez",
    "scrape_type": "user",
    "sort": "top",
    "time_filter": "all",
    "limit": 50
}
```

***

#### 📝 Create Post Mode

Create a new post in a subreddit. **Requires cookies.**

```json
{
    "mode": "Create_Post",
    "target": "test",
    "title": "My First Automated Post",
    "body": "This post was created using Reddit UnOfficial API!",
    "flair": "Discussion",
    "proxyType": "residential",
    "proxyCountry": "US",
    "cookies": [
        {"name": "token_v2", "value": "your_token_here", "domain": ".reddit.com"},
        {"name": "reddit_session", "value": "your_session_here", "domain": ".reddit.com"}
    ]
}
```

***

#### 💬 Comment on Post Mode

Add a comment to an existing post. **Requires cookies.**

```json
{
    "mode": "Comment_on_Post",
    "target": "https://www.reddit.com/r/test/comments/abc123/some_post_title/",
    "text": "Great post! Thanks for sharing.",
    "proxyType": "residential",
    "proxyCountry": "US",
    "cookies": [
        {"name": "token_v2", "value": "your_token_here", "domain": ".reddit.com"}
    ]
}
```

***

#### ↩️ Reply to Comment Mode

Reply to a specific comment. **Requires cookies.**

```json
{
    "mode": "Reply_to_A_Comment",
    "target": "https://www.reddit.com/r/test/comments/abc123/some_post_title/xyz789/",
    "text": "I agree with your point!",
    "proxyType": "residential",
    "proxyCountry": "AUTO",
    "cookies": [
        {"name": "token_v2", "value": "your_token_here", "domain": ".reddit.com"}
    ]
}
```

> ⚠️ **Note:** Comment URLs include the comment ID at the end (e.g., `/xyz789/`). Post URLs don't have this extra segment.

***

### 🍪 How to Get Cookies

1. Install a browser extension like **"Cookie-Editor"**  Link: https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm?hl=en-US\&utm\_source=ext\_sidebar
2. Log in to Reddit
3. Open the extension and export cookies as JSON
4. Paste the JSON into the **Cookies** input field

**Accepted formats:**

```json
// Browser export format (recommended)
[
    {"name": "token_v2", "value": "...", "domain": ".reddit.com"},
    {"name": "reddit_session", "value": "...", "domain": ".reddit.com"}
]

// Simple format
{
    "token_v2": "...",
    "reddit_session": "..."
}
```

***

### 🔒 Proxy Options

| Type | Best For | Country Support |
|------|----------|-----------------|
| **Residential** | Automation (lower detection) | All countries |
| **Datacenter** | Scraping (budget option) | AUTO only |

***

### 📦 Output

- **Scraping**: Returns list of posts with title, author, score, comments, URL, etc.
- **Automation**: Returns success status, message, post/comment ID, permalink

***

### ⚠️ Disclaimer

This tool is for educational and research purposes. Please respect Reddit's Terms of Service. Use automation responsibly to avoid account bans.

# Actor input Schema

## `mode` (type: `string`):

Choose the operation to perform.

## `target` (type: `string`):

• For Scrape: Subreddit name (e.g., 'python') or Username (e.g., 'spez')
• For Create Post: Subreddit name to post in
• For Comment/Reply: Full Reddit URL of the post or comment

## `proxyType` (type: `string`):

Choose proxy type for automation:\n• Residential: More reliable, less detection (recommended)\n• Datacenter: Cheaper but higher detection risk

## `proxyCountry` (type: `string`):

Proxy location. All countries available for Residential. Datacenter availability may vary by country.

## `cookies` (type: `object,array`):

Reddit cookies in either format:\n• Simple: {"reddit\_session": "...", "token\_v2": "..."}\n• Browser export: \[{"name": "...", "value": "...", "domain": "..."}]\nGet from browser DevTools → Application → Cookies → reddit.com

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

Title of your post (required for Create\_Post mode)

## `body` (type: `string`):

Content of your post

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

Flair to select (we'll search and pick the closest match)

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

Your comment or reply text (required for Comment\_on\_Post and Reply\_to\_A\_Comment modes)

## `scrape_type` (type: `string`):

Are you scraping a subreddit or a user's posts?

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

How to sort the posts

## `time_filter` (type: `string`):

Time range (only applies to 'top' and 'controversial' sorts)

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

How many posts to fetch (1-100)

## Actor input object example

```json
{
  "mode": "scrape",
  "target": "python",
  "proxyType": "residential",
  "proxyCountry": "AUTO",
  "scrape_type": "subreddit",
  "sort": "hot",
  "time_filter": "all",
  "limit": 25
}
```

# 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 = {
    "target": "python"
};

// Run the Actor and wait for it to finish
const run = await client.actor("hadidiz/reddit-actions-api").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 = { "target": "python" }

# Run the Actor and wait for it to finish
run = client.actor("hadidiz/reddit-actions-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "target": "python"
}' |
apify call hadidiz/reddit-actions-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=hadidiz/reddit-actions-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ZiRrISYuPKdlbUchp/builds/loEaNV5AfVFBr1xbE/openapi.json
