> ## Agent Instructions
>
> Base URL: https://api.anysite.io
> Authentication: send the `access-token` header. Do NOT use `Authorization: Bearer`.
> Full endpoint catalog: https://app.anysite.io/docs
# Reddit Node

Extract Reddit data with the Anysite Reddit node for n8n workflows

## Overview

The Anysite Reddit node allows you to extract valuable data from Reddit within your n8n workflows. Search posts, monitor subreddits, analyze discussions, and track community sentiment.

## Node Configuration

### Authentication

  Select your Anysite API credentials from the dropdown or create new ones.

### Available Operations

#### Search Posts

Search for Reddit posts across all subreddits or within specific communities.

**Parameters:**
- **Query** (required): Search terms for finding posts
- **Subreddit**: Specific subreddit to search (optional)
- **Sort**: "relevance", "hot", "new", "top"
- **Time Range**: "hour", "day", "week", "month", "year", "all"
- **Limit**: Maximum results to return (1-100)

**Example Output:**
```json
{
  "posts": [
    {
      "id": "post123",
      "title": "How to build scalable web applications",
      "text": "Here's what I learned after building 10+ web apps...",
      "subreddit": "webdev",
      "author": "experienced_dev",
      "score": 245,
      "upvoteRatio": 0.92,
      "comments": 67,
      "created": "2024-08-26T10:30:00Z",
      "url": "https://reddit.com/r/webdev/comments/abc123/"
    }
  ]
}
```

#### Get Post Comments

Extract comments and discussion threads from a specific Reddit post.

**Parameters:**
- **Post URL** (required): Reddit post URL
- **Comment Depth**: How deep to fetch comment threads (1-10)
- **Sort Comments**: "best", "top", "new", "controversial", "old"
- **Limit**: Maximum comments to return

**Example Output:**
```json
{
  "comments": [
    {
      "id": "comment456",
      "text": "Great points! I'd also add that caching is crucial...",
      "author": "cache_expert",
      "score": 89,
      "created": "2024-08-26T11:15:00Z",
      "replies": [
        {
          "id": "reply789",
          "text": "Absolutely! Redis has been a game changer for us.",
          "author": "redis_fan",
          "score": 34
        }
      ]
    }
  ]
}
```

#### Get Subreddit Info

Get information and statistics about a specific subreddit.

**Parameters:**
- **Subreddit Name** (required): Subreddit name (without r/)
- **Include Rules**: Whether to include subreddit rules
- **Include Moderators**: Whether to include moderator list

**Example Output:**
```json
{
  "subreddit": {
    "name": "MachineLearning",
    "title": "Machine Learning",
    "description": "This subreddit is dedicated to the discussion of machine learning...",
    "subscribers": 2500000,
    "activeUsers": 5420,
    "created": "2008-01-25T12:00:00Z",
    "isNsfw": false,
    "rules": [
      {
        "title": "Stay on topic",
        "description": "Posts must be related to machine learning"
      }
    ]
  }
}
```

#### Monitor Hot Posts

Get currently trending/hot posts from specified subreddits.

**Parameters:**
- **Subreddits** (required): Comma-separated list of subreddit names
- **Post Limit**: Number of hot posts per subreddit
- **Min Score**: Minimum upvote score filter

**Example Output:**
```json
{
  "hotPosts": [
    {
      "subreddit": "technology",
      "title": "New AI breakthrough announced by researchers",
      "score": 8750,
      "comments": 432,
      "trending": true,
      "hotnessRank": 1
    }
  ]
}
```

## Workflow Examples

### Brand Monitoring

#### Monitor Mentions

Search for posts mentioning your brand, product, or competitors across relevant subreddits.

#### Analyze Sentiment

Use AI nodes to analyze sentiment and identify positive/negative discussions.

#### Track Engagement

Monitor upvotes, comments, and discussion activity around your brand.

#### Alert Team

Send notifications for high-impact mentions or negative sentiment.

**Example Workflow:**
```json
{
  "nodes": [
    {
      "name": "Monitor Brand Mentions",
      "type": "@horizondatawave/n8n-nodes-anysite.Reddit",
      "operation": "searchPosts",
      "parameters": {
        "query": "YourBrand OR YourProduct",
        "subreddit": "technology,startups,entrepreneur",
        "sort": "new",
        "limit": 50
      }
    },
    {
      "name": "Filter High Engagement",
      "type": "n8n-nodes-base.filter",
      "parameters": {
        "conditions": [
          {
            "field": "score",
            "operation": "greaterThan",
            "value": 10
          },
          {
            "field": "comments",
            "operation": "greaterThan", 
            "value": 5
          }
        ]
      }
    },
    {
      "name": "Get Comments",
      "type": "@horizondatawave/n8n-nodes-anysite.Reddit",
      "operation": "getPostComments",
      "parameters": {
        "postUrl": "={{ $json.url }}",
        "commentDepth": 2,
        "limit": 25
      }
    },
    {
      "name": "Analyze Sentiment",
      "type": "n8n-nodes-base.openAi",
      "parameters": {
        "prompt": "Analyze sentiment of this Reddit discussion: {{ $json.title }} - {{ $json.text }}"
      }
    }
  ]
}
```

### Market Research

Research customer opinions and market trends:

1. **Industry Monitoring** - Track discussions in industry-specific subreddits
2. **Product Feedback** - Find mentions of your product or competitors
3. **Feature Requests** - Identify commonly requested features or pain points
4. **Trend Analysis** - Analyze trending topics and emerging technologies
5. **Report Generation** - Create weekly market research reports

### Community Management

Monitor and engage with your community:

1. **Support Questions** - Find users asking for help with your product
2. **Bug Reports** - Identify and track bug reports from users
3. **Feature Discussions** - Monitor discussions about new features
4. **Community Health** - Track sentiment and engagement in your subreddit
5. **Moderation Alerts** - Get notified about posts needing attention

## Advanced Search

### Search Operators

Use Reddit's search syntax for precise queries:

```javascript
// Exact title match
{
  "query": "title:\"How to learn machine learning\""
}

// Author search
{
  "query": "author:specific_username"
}

// Multiple subreddits
{
  "query": "subreddit:MachineLearning OR subreddit:programming"
}

// URL search
{
  "query": "url:github.com"
}

// Flair search
{
  "query": "flair:Discussion"
}

// Self posts only
{
  "query": "self:yes machine learning tutorial"
}

// Score filter
{
  "query": "score:>100 artificial intelligence"
}
```

### Time-based Analysis

Track discussions over time:

```json
{
  "name": "Weekly Trend Analysis",
  "type": "@horizondatawave/n8n-nodes-anysite.Reddit", 
  "operation": "searchPosts",
  "parameters": {
    "query": "artificial intelligence",
    "subreddit": "MachineLearning",
    "sort": "top",
    "timeRange": "week",
    "limit": 100
  }
}
```

## Data Analysis

### Engagement Metrics

Calculate post and comment engagement:

```javascript
// Engagement rate calculation
{
  "engagementRate": "={{ ($json.comments / ($json.score || 1)) * 100 }}"
}

// Controversy score
{
  "controversyScore": "={{ (1 - $json.upvoteRatio) * 100 }}"
}

// Discussion density
{
  "discussionDensity": "={{ $json.comments / Math.max($json.text.length / 100, 1) }}"
}
```

### Content Analysis

Extract insights from Reddit content:

```json
{
  "name": "Extract Keywords",
  "type": "n8n-nodes-base.function",
  "parameters": {
    "functionCode": `
      const text = $input.first().json.text.toLowerCase();
      const keywords = text.match(/\\b\\w{4,}\\b/g) || [];
      const wordCount = {};
      
      keywords.forEach(word => {
        wordCount[word] = (wordCount[word] || 0) + 1;
      });
      
      const topKeywords = Object.entries(wordCount)
        .sort(([,a], [,b]) => b - a)
        .slice(0, 10)
        .map(([word, count]) => ({ word, count }));
        
      return [{ json: { ...item.json, topKeywords } }];
    `
  }
}
```

## Error Handling

### Common Errors

#### Subreddit Not Found

**Error:** `404 - Subreddit not found`

**Solution:**
- Verify subreddit name is spelled correctly
- Check if subreddit is private or banned
- Handle missing subreddits gracefully in bulk operations

#### Post Deleted

**Error:** `404 - Post not found`

**Solution:**
- Post may have been deleted by user or moderator
- Store post data when first accessed
- Implement fallback logic for missing posts

#### Rate Limit Hit

**Error:** `429 - Too many requests`

**Solution:**
- Add delays between requests (recommended: 2-3 seconds)
- Implement exponential backoff retry logic
- Consider upgrading API plan for higher limits

### Robust Error Handling

```json
{
  "name": "Reddit with Error Handling",
  "type": "@horizondatawave/n8n-nodes-anysite.Reddit",
  "continueOnFail": true,
  "retryOnFail": true,
  "maxTries": 3,
  "waitBetweenTries": 3000,
  "parameters": {
    "operation": "searchPosts",
    "query": "your search query"
  }
}
```

## Integration Examples

### Slack Notifications

Send alerts for important discussions:

```json
{
  "name": "High-Impact Alert",
  "type": "n8n-nodes-base.slack",
  "parameters": {
    "channel": "#marketing",
    "text": "🔥 Trending Reddit post about {{ $json.title }}\n📊 Score: {{ $json.score }} | 💬 Comments: {{ $json.comments }}\n🔗 {{ $json.url }}"
  }
}
```

### Database Storage

Store Reddit data for analysis:

```json
{
  "name": "Store in Database",
  "type": "n8n-nodes-base.postgres",
  "parameters": {
    "operation": "insert",
    "table": "reddit_posts",
    "columns": [
      "post_id",
      "title", 
      "subreddit",
      "score",
      "comments",
      "created_at"
    ],
    "values": [
      "={{ $json.id }}",
      "={{ $json.title }}",
      "={{ $json.subreddit }}",
      "={{ $json.score }}",
      "={{ $json.comments }}",
      "={{ $json.created }}"
    ]
  }
}
```

### Content Aggregation

Combine Reddit data with other sources:

```json
{
  "workflow": [
    "Reddit Search → Get Hot Posts",
    "Twitter Search → Find Related Tweets",
    "Google News → Get News Articles",
    "AI Analysis → Extract Common Themes",
    "Report Generation → Create Daily Brief"
  ]
}
```

## Performance Tips

### Efficient Bulk Operations

```json
{
  "name": "Batch Subreddit Monitor",
  "type": "n8n-nodes-base.splitInBatches",
  "parameters": {
    "batchSize": 5,
    "options": {
      "reset": false
    }
  }
}
```

### Data Deduplication

Remove duplicate posts:

```javascript
// Deduplicate by post ID
{
  "name": "Remove Duplicates",
  "type": "n8n-nodes-base.removeDuplicates",
  "parameters": {
    "compare": "selectedFields",
    "fieldsToCompare": ["id"]
  }
}
```

## Community Insights

### Subreddit Analysis

Analyze subreddit health and trends:

```json
{
  "name": "Subreddit Health Check",
  "type": "@horizondatawave/n8n-nodes-anysite.Reddit",
  "operation": "getSubredditInfo",
  "parameters": {
    "subredditName": "{{ $json.subreddit }}",
    "includeRules": true,
    "includeModerators": false
  }
}
```

### Discussion Quality

Assess discussion quality metrics:

```javascript
// Calculate discussion quality score
{
  "qualityScore": "={{ (($json.score * 0.4) + ($json.comments * 0.3) + (($json.upvoteRatio - 0.5) * 200 * 0.3)) }}"
}
```

## Next Steps

- [LinkedIn Node](/docs/n8n-nodes/linkedin-node) - LinkedIn data extraction
- [Twitter Node](/docs/n8n-nodes/twitter-node) - Twitter/X monitoring
- [Instagram Node](/docs/n8n-nodes/instagram-node) - Instagram content analysis
- [Workflows](/docs/n8n-nodes/workflows) - Pre-built workflow templates
