> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anysite.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Instagram Node

> Extract Instagram data with the Anysite Instagram node for n8n workflows

## Overview

The Anysite Instagram node enables Instagram data extraction within your n8n workflows. Get user profiles, analyze posts, track hashtags, and monitor engagement metrics for social media analysis.

## Node Configuration

### Authentication

<ParamField path="credential" type="Anysite API Credentials" required>
  Select your Anysite API credentials from the dropdown or create new ones.
</ParamField>

### Available Operations

<Tabs>
  <Tab title="Get User Profile">
    Extract detailed Instagram user profile information.

    **Parameters:**

    * **Username** (required): Instagram username (without @)
    * **Include Posts**: Whether to include recent posts
    * **Post Limit**: Number of recent posts to include (1-50)

    **Example Output:**

    ```json theme={null}
    {
      "user": {
        "id": "instagram123",
        "username": "travel_blogger",
        "displayName": "Sarah's Adventures",
        "bio": "Travel enthusiast ✈️ | 50+ countries | Photography tips 📸",
        "followers": 125000,
        "following": 800,
        "posts": 1250,
        "isVerified": false,
        "isPrivate": false,
        "profileImageUrl": "https://instagram.com/profiles/...",
        "website": "https://sarahtravels.com",
        "category": "Travel"
      }
    }
    ```
  </Tab>

  <Tab title="Get User Posts">
    Extract posts from a specific Instagram user.

    **Parameters:**

    * **Username** (required): Instagram username
    * **Post Count**: Number of posts to retrieve (1-50)
    * **Include Stories**: Whether to include story highlights
    * **Media Type**: "all", "photo", "video", "carousel"

    **Example Output:**

    ```json theme={null}
    {
      "posts": [
        {
          "id": "post456",
          "shortcode": "ABC123def",
          "caption": "Amazing sunset in Bali! 🌅 #sunset #bali #travel",
          "mediaType": "photo",
          "mediaUrl": "https://instagram.com/images/...",
          "timestamp": "2024-08-26T18:30:00Z",
          "likes": 2800,
          "comments": 145,
          "hashtags": ["#sunset", "#bali", "#travel"],
          "mentions": ["@bali_tourism"],
          "location": {
            "name": "Tanah Lot, Bali",
            "id": "location789"
          }
        }
      ]
    }
    ```
  </Tab>

  <Tab title="Search Users">
    Search for Instagram users by username or bio keywords.

    **Parameters:**

    * **Query** (required): Search terms for finding users
    * **Category**: User category filter (optional)
    * **Verified Only**: Only return verified accounts
    * **Limit**: Maximum results to return (1-50)

    **Example Output:**

    ```json theme={null}
    {
      "users": [
        {
          "id": "user789",
          "username": "food_critic_nyc",
          "displayName": "NYC Food Reviews",
          "followers": 85000,
          "isVerified": true,
          "category": "Food & Drink",
          "bio": "NYC's best restaurants 🍽️ | Food critic | DM for collabs"
        }
      ]
    }
    ```
  </Tab>

  <Tab title="Analyze Post">
    Get detailed analytics for a specific Instagram post.

    **Parameters:**

    * **Post URL** (required): Instagram post URL
    * **Include Comments**: Whether to include comment analysis
    * **Comment Limit**: Number of comments to analyze

    **Example Output:**

    ```json theme={null}
    {
      "post": {
        "id": "post123",
        "engagement": {
          "likes": 3200,
          "comments": 189,
          "saves": 245,
          "shares": 67,
          "engagementRate": 4.2
        },
        "audience": {
          "topCountries": ["US", "UK", "Canada"],
          "ageGroups": {
            "18-24": 35,
            "25-34": 45,
            "35-44": 20
          }
        },
        "performance": {
          "reach": 85000,
          "impressions": 125000,
          "profileVisits": 450
        }
      }
    }
    ```
  </Tab>
</Tabs>

## Workflow Examples

### Influencer Research

<Steps>
  <Step title="Find Influencers">
    Search for Instagram users in your niche with high engagement rates.
  </Step>

  <Step title="Analyze Profiles">
    Get detailed profile information including follower count, engagement, and content themes.
  </Step>

  <Step title="Content Analysis">
    Analyze recent posts to ensure brand alignment and authentic engagement.
  </Step>

  <Step title="Contact Database">
    Build a database of qualified influencers with contact information and collaboration notes.
  </Step>
</Steps>

**Example Workflow:**

```json theme={null}
{
  "nodes": [
    {
      "name": "Search Fashion Influencers",
      "type": "@horizondatawave/n8n-nodes-anysite.Instagram",
      "operation": "searchUsers",
      "parameters": {
        "query": "fashion blogger style influencer",
        "category": "Fashion",
        "limit": 50
      }
    },
    {
      "name": "Filter by Followers",
      "type": "n8n-nodes-base.filter",
      "parameters": {
        "conditions": [
          {
            "field": "followers",
            "operation": "greaterThan",
            "value": 10000
          },
          {
            "field": "followers",
            "operation": "lessThan",
            "value": 500000
          }
        ]
      }
    },
    {
      "name": "Get Recent Posts",
      "type": "@horizondatawave/n8n-nodes-anysite.Instagram",
      "operation": "getUserPosts",
      "parameters": {
        "username": "={{ $json.username }}",
        "postCount": 12,
        "mediaType": "all"
      }
    },
    {
      "name": "Calculate Engagement",
      "type": "n8n-nodes-base.function",
      "parameters": {
        "functionCode": `
          const avgLikes = items[0].json.posts.reduce((sum, post) => sum + post.likes, 0) / items[0].json.posts.length;
          const engagementRate = (avgLikes / items[0].json.followers) * 100;
          
          return [{
            json: {
              ...items[0].json,
              avgLikes,
              engagementRate
            }
          }];
        `
      }
    }
  ]
}
```

### Brand Monitoring

Track mentions of your brand across Instagram:

1. **Hashtag Monitoring** - Track branded hashtags and campaigns
2. **Mention Detection** - Find posts mentioning your brand handle
3. **User-Generated Content** - Discover customers posting about your products
4. **Competitor Analysis** - Monitor competitor social media activity
5. **Engagement Tracking** - Measure campaign performance and reach

### Content Strategy

Optimize your content strategy based on competitor analysis:

1. **Top Performers** - Find highest-performing posts in your niche
2. **Hashtag Analysis** - Identify trending and effective hashtags
3. **Posting Patterns** - Analyze optimal posting times and frequency
4. **Content Types** - Determine which content formats perform best
5. **Audience Insights** - Understand your target audience preferences

## Advanced Analytics

### Engagement Analysis

Calculate detailed engagement metrics:

```javascript theme={null}
// Comprehensive engagement calculation
{
  "engagementMetrics": {
    "rate": "={{ (($json.likes + $json.comments) / $json.followers * 100).toFixed(2) }}%",
    "likesToCommentsRatio": "={{ ($json.likes / Math.max($json.comments, 1)).toFixed(1) }}",
    "avgLikesPerPost": "={{ ($json.totalLikes / $json.postCount).toFixed(0) }}",
    "viralityScore": "={{ ($json.likes > ($json.followers * 0.05) ? 'High' : 'Normal') }}"
  }
}
```

### Content Performance

Analyze which content types perform best:

```json theme={null}
{
  "name": "Analyze Content Types",
  "type": "n8n-nodes-base.function",
  "parameters": {
    "functionCode": `
      const posts = items.map(item => item.json);
      const byType = posts.reduce((acc, post) => {
        acc[post.mediaType] = acc[post.mediaType] || [];
        acc[post.mediaType].push(post);
        return acc;
      }, {});
      
      const analysis = Object.entries(byType).map(([type, typePosts]) => ({
        type,
        count: typePosts.length,
        avgLikes: typePosts.reduce((sum, p) => sum + p.likes, 0) / typePosts.length,
        avgComments: typePosts.reduce((sum, p) => sum + p.comments, 0) / typePosts.length
      }));
      
      return [{ json: { contentAnalysis: analysis } }];
    `
  }
}
```

## Hashtag Research

### Trending Hashtags

Find trending hashtags in your niche:

```json theme={null}
{
  "name": "Extract Hashtags",
  "type": "n8n-nodes-base.function", 
  "parameters": {
    "functionCode": `
      const allHashtags = items.flatMap(item => 
        item.json.posts ? item.json.posts.flatMap(post => post.hashtags || []) : []
      );
      
      const hashtagCount = allHashtags.reduce((acc, tag) => {
        acc[tag] = (acc[tag] || 0) + 1;
        return acc;
      }, {});
      
      const trending = Object.entries(hashtagCount)
        .sort(([,a], [,b]) => b - a)
        .slice(0, 20)
        .map(([hashtag, count]) => ({ hashtag, count }));
        
      return [{ json: { trendingHashtags: trending } }];
    `
  }
}
```

### Hashtag Performance

Analyze hashtag effectiveness:

```javascript theme={null}
// Hashtag performance metrics
{
  "hashtagAnalysis": {
    "totalHashtags": "={{ $json.hashtags.length }}",
    "avgEngagement": "={{ ($json.likes + $json.comments) / Math.max($json.hashtags.length, 1) }}",
    "topHashtag": "={{ $json.hashtags[0] }}",
    "nicheTags": "={{ $json.hashtags.filter(tag => tag.includes('fashion') || tag.includes('style')).length }}"
  }
}
```

## Error Handling

### Common Issues

<AccordionGroup>
  <Accordion title="Private Account">
    **Error:** `403 - Account is private`

    **Solution:**

    * Skip private accounts in bulk operations
    * Focus on public profiles for analysis
    * Maintain a list of accessible accounts
  </Accordion>

  <Accordion title="Account Not Found">
    **Error:** `404 - User not found`

    **Solution:**

    * User may have changed username or deleted account
    * Update your user database regularly
    * Handle missing users gracefully in workflows
  </Accordion>

  <Accordion title="Rate Limit Reached">
    **Error:** `429 - Too many requests`

    **Solution:**

    * Add delays between requests (recommended: 2-3 seconds)
    * Implement exponential backoff
    * Monitor your API usage and plan accordingly
  </Accordion>
</AccordionGroup>

### Robust Request Handling

```json theme={null}
{
  "name": "Instagram with Retry",
  "type": "@horizondatawave/n8n-nodes-anysite.Instagram",
  "continueOnFail": true,
  "retryOnFail": true,
  "maxTries": 3,
  "waitBetweenTries": 4000,
  "parameters": {
    "operation": "getUserProfile",
    "username": "{{ $json.username }}"
  }
}
```

## Data Processing

### Profile Scoring

Score influencer profiles based on multiple factors:

```javascript theme={null}
// Influencer scoring algorithm
{
  "influencerScore": {
    "followersScore": "={{ Math.min($json.followers / 10000, 10) }}",
    "engagementScore": "={{ ($json.engagementRate > 3 ? 10 : $json.engagementRate * 3.33) }}",
    "contentScore": "={{ ($json.posts.length > 100 ? 10 : $json.posts.length / 10) }}",
    "verificationBonus": "={{ $json.isVerified ? 2 : 0 }}",
    "totalScore": "={{ ($json.followersScore + $json.engagementScore + $json.contentScore + $json.verificationBonus) / 3.2 }}"
  }
}
```

### Audience Analysis

Analyze follower demographics and interests:

```json theme={null}
{
  "name": "Analyze Audience",
  "type": "n8n-nodes-base.openAi",
  "parameters": {
    "operation": "analyze",
    "prompt": "Based on this Instagram profile bio and recent posts, what audience demographics and interests would this account attract? Bio: {{ $json.bio }}, Recent posts: {{ $json.recentPosts.map(p => p.caption).join(' | ') }}"
  }
}
```

## Integration Examples

### CRM Integration

Add qualified influencers to your CRM:

```json theme={null}
{
  "name": "Add to CRM",
  "type": "n8n-nodes-base.hubspot",
  "parameters": {
    "operation": "create",
    "resource": "contact",
    "data": {
      "firstname": "={{ $json.displayName.split(' ')[0] }}",
      "lastname": "={{ $json.displayName.split(' ').slice(1).join(' ') }}",
      "instagram_handle": "={{ $json.username }}",
      "follower_count": "={{ $json.followers }}",
      "engagement_rate": "={{ $json.engagementRate }}",
      "category": "={{ $json.category }}"
    }
  }
}
```

### Content Calendar

Build content calendar based on competitor analysis:

```json theme={null}
{
  "name": "Generate Content Ideas",
  "type": "n8n-nodes-base.openAi", 
  "parameters": {
    "operation": "generate",
    "prompt": "Based on these high-performing Instagram posts, generate 5 content ideas for our brand: {{ JSON.stringify($json.topPosts) }}"
  }
}
```

### Report Generation

Create Instagram analytics reports:

```json theme={null}
{
  "name": "Generate Report",
  "type": "n8n-nodes-base.googleDocs",
  "parameters": {
    "operation": "create",
    "title": "Instagram Analysis Report - {{ new Date().toLocaleDateString() }}",
    "content": `
      # Instagram Analysis Report
      
      ## Top Performers
      {{ $json.topInfluencers.map(inf => \`- \${inf.username}: \${inf.followers} followers, \${inf.engagementRate}% engagement\`).join('\\n') }}
      
      ## Trending Hashtags
      {{ $json.trendingHashtags.map(tag => \`- \${tag.hashtag} (\${tag.count} uses)\`).join('\\n') }}
      
      ## Recommendations
      {{ $json.recommendations }}
    `
  }
}
```

## Performance Optimization

### Bulk Operations

Process multiple accounts efficiently:

```json theme={null}
{
  "name": "Batch Process Users",
  "type": "n8n-nodes-base.splitInBatches",
  "parameters": {
    "batchSize": 10,
    "options": {
      "reset": false
    }
  }
}
```

### Data Caching

Cache profile data to reduce API calls:

```javascript theme={null}
// Simple caching mechanism
{
  "name": "Cache Profile Data",
  "type": "n8n-nodes-base.function",
  "parameters": {
    "functionCode": `
      const cacheKey = \`profile_\${items[0].json.username}\`;
      const cached = $('Cache').last()?.json?.[cacheKey];
      
      if (cached && Date.now() - cached.timestamp < 3600000) { // 1 hour cache
        return [{ json: cached.data }];
      }
      
      // Store in cache for next time
      const cacheData = {
        [cacheKey]: {
          data: items[0].json,
          timestamp: Date.now()
        }
      };
      
      return [
        { json: items[0].json },
        { json: cacheData, pairedItem: { item: 0, input: 0 } }
      ];
    `
  }
}
```

## Best Practices

### Ethical Data Collection

* Respect user privacy and Instagram's terms of service
* Only collect publicly available data
* Implement proper rate limiting
* Store data securely and delete when no longer needed

### Performance Tips

* Use batch processing for large datasets
* Implement caching for frequently accessed profiles
* Add appropriate delays between requests
* Monitor your API usage to stay within limits

## Next Steps

* [LinkedIn Node](/n8n-nodes/linkedin-node) - LinkedIn data extraction
* [Twitter Node](/n8n-nodes/twitter-node) - Twitter/X monitoring
* [Reddit Node](/n8n-nodes/reddit-node) - Reddit discussion analysis
* [Workflows](/n8n-nodes/workflows) - Pre-built workflow templates
