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

> 使用 Anysite Instagram 节点在 n8n 工作流中提取 Instagram 数据

## 概述

Anysite Instagram 节点在您的 n8n 工作流中实现 Instagram 数据提取。获取用户资料、分析帖子、跟踪标签并监控互动指标，用于社交媒体分析。

## 节点配置

### 认证

<ParamField path="credential" type="Anysite API Credentials" required>
  从下拉菜单中选择您的 Anysite API 凭证，或创建新凭证。
</ParamField>

### 可用操作

<Tabs>
  <Tab title="获取用户资料">
    提取详细的 Instagram 用户资料信息。

    **参数：**

    * **Username**（必填）：Instagram 用户名（不带 @）
    * **Include Posts**：是否包含最近的帖子
    * **Post Limit**：要包含的最近帖子数量（1-50）

    **输出示例：**

    ```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="获取用户帖子">
    从特定 Instagram 用户提取帖子。

    **参数：**

    * **Username**（必填）：Instagram 用户名
    * **Post Count**：要检索的帖子数量（1-50）
    * **Include Stories**：是否包含精选故事
    * **Media Type**："all"、"photo"、"video"、"carousel"

    **输出示例：**

    ```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="搜索用户">
    按用户名或简介关键词搜索 Instagram 用户。

    **参数：**

    * **Query**（必填）：用于查找用户的搜索词
    * **Category**：用户类别筛选（可选）
    * **Verified Only**：仅返回认证账户
    * **Limit**：返回的最大结果数（1-50）

    **输出示例：**

    ```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="分析帖子">
    获取特定 Instagram 帖子的详细分析。

    **参数：**

    * **Post URL**（必填）：Instagram 帖子 URL
    * **Include Comments**：是否包含评论分析
    * **Comment Limit**：要分析的评论数量

    **输出示例：**

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

## 工作流示例

### 影响者研究

<Steps>
  <Step title="寻找影响者">
    在您的细分市场中搜索具有高互动率的 Instagram 用户。
  </Step>

  <Step title="分析资料">
    获取详细的资料信息，包括粉丝数、互动和内容主题。
  </Step>

  <Step title="内容分析">
    分析最近的帖子以确保品牌一致性和真实互动。
  </Step>

  <Step title="联系人数据库">
    建立包含联系信息和合作备注的合格影响者数据库。
  </Step>
</Steps>

**工作流示例：**

```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
            }
          }];
        `
      }
    }
  ]
}
```

### 品牌监控

跟踪您品牌在 Instagram 上的提及：

1. **标签监控** - 跟踪品牌标签和活动
2. **提及检测** - 查找提及您品牌账号的帖子
3. **用户生成内容** - 发现发布您产品内容的客户
4. **竞争对手分析** - 监控竞争对手的社交媒体活动
5. **互动追踪** - 测量活动表现和触达

### 内容策略

基于竞争对手分析优化您的内容策略：

1. **顶级表现者** - 找到您细分市场中表现最好的帖子
2. **标签分析** - 识别热门和有效的标签
3. **发布模式** - 分析最佳发布时间和频率
4. **内容类型** - 确定哪种内容格式表现最好
5. **受众洞察** - 了解您的目标受众偏好

## 高级分析

### 互动分析

计算详细的互动指标：

```javascript theme={null}
// 全面的互动计算
{
  "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') }}"
  }
}
```

### 内容表现

分析哪种内容类型表现最好：

```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 } }];
    `
  }
}
```

## 标签研究

### 热门标签

在您的细分市场中找到热门标签：

```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 } }];
    `
  }
}
```

### 标签表现

分析标签效果：

```javascript theme={null}
// 标签表现指标
{
  "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 }}"
  }
}
```

## 错误处理

### 常见问题

<AccordionGroup>
  <Accordion title="私密账户">
    **错误：** `403 - Account is private`

    **解决方案：**

    * 在批量操作中跳过私密账户
    * 专注于公开资料进行分析
    * 维护可访问账户列表
  </Accordion>

  <Accordion title="账户未找到">
    **错误：** `404 - User not found`

    **解决方案：**

    * 用户可能已更改用户名或删除账户
    * 定期更新您的用户数据库
    * 在工作流中优雅地处理缺失用户
  </Accordion>

  <Accordion title="达到速率限制">
    **错误：** `429 - Too many requests`

    **解决方案：**

    * 在请求之间添加延迟（推荐：2-3 秒）
    * 实现指数退避
    * 监控您的 API 使用情况并相应计划
  </Accordion>
</AccordionGroup>

### 健壮的请求处理

```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 }}"
  }
}
```

## 数据处理

### 资料评分

基于多个因素对影响者资料评分：

```javascript theme={null}
// 影响者评分算法
{
  "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 }}"
  }
}
```

### 受众分析

分析粉丝人口统计和兴趣：

```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(' | ') }}"
  }
}
```

## 集成示例

### CRM 集成

将合格的影响者添加到您的 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 }}"
    }
  }
}
```

### 内容日历

基于竞争对手分析构建内容日历：

```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) }}"
  }
}
```

### 报告生成

创建 Instagram 分析报告：

```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 }}
    `
  }
}
```

## 性能优化

### 批量操作

高效处理多个账户：

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

### 数据缓存

缓存资料数据以减少 API 调用：

```javascript theme={null}
// 简单的缓存机制
{
  "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 小时缓存
        return [{ json: cached.data }];
      }

      // 存储到缓存供下次使用
      const cacheData = {
        [cacheKey]: {
          data: items[0].json,
          timestamp: Date.now()
        }
      };

      return [
        { json: items[0].json },
        { json: cacheData, pairedItem: { item: 0, input: 0 } }
      ];
    `
  }
}
```

## 最佳实践

### 道德数据收集

* 尊重用户隐私和 Instagram 的服务条款
* 仅收集公开可用的数据
* 实施适当的速率限制
* 安全存储数据并在不再需要时删除

### 性能技巧

* 对大型数据集使用批处理
* 为频繁访问的资料实施缓存
* 在请求之间添加适当的延迟
* 监控您的 API 使用情况以保持在限制范围内

## 后续步骤

* [LinkedIn 节点](/n8n-nodes/linkedin-node) - LinkedIn 数据提取
* [Twitter 节点](/n8n-nodes/twitter-node) - Twitter/X 监控
* [Reddit 节点](/n8n-nodes/reddit-node) - Reddit 讨论分析
* [工作流](/n8n-nodes/workflows) - 预构建的工作流模板
