# Instagram 互动率统计 API (instagram.engagement)

- Canonical page: [https://everyinfra.com/instagram-api/engagement](https://everyinfra.com/instagram-api/engagement?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "instagram", "action": "engagement", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: single object
- Mode: sync; add "mode": "async" for slow tasks

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=instagram&action=engagement

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | 要统计的 Instagram 账号用户名，如 natgeo（可带 @，也收主页链接）。 |
| posts | integer | no | not declared | 按最近多少条帖子算，3–60 的整数，不传按 24 条。置顶帖也算在内，按发帖时间取最近的。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| username | 用户名（@handle）。 |
| display_name | 显示名，可能与 username 不同。 |
| url | 该记录在原平台上的可访问链接。 |
| follower_count | 粉丝数。null 表示不公开，不等于 0。 |
| is_verified | 是否为平台认证账号（蓝V等）。null 表示无法判定。 |
| sample_size | （engagement）实际算进统计的帖子条数。 |
| period_start | （engagement）算进统计的最早一条帖子的发布时间，ISO 8601，UTC。 |
| period_end | （engagement）算进统计的最新一条帖子的发布时间，ISO 8601，UTC。 |
| posts_per_week | （engagement）这段时间里平均每周发几条。 |
| avg_like_count | （engagement）平均每条的点赞数。作者藏了赞数的帖子按 0 算。 |
| avg_comment_count | （engagement）平均每条的评论数。 |
| avg_view_count | （engagement）平均播放数；图片帖没有播放数。 |
| median_like_count | （engagement）每条点赞数的中位数。 |
| avg_interactions | （engagement）平均每条的互动数（点赞 + 评论）。 |
| median_interactions | （engagement）每条互动数（点赞 + 评论）的中位数。 |
| engagement_rate | （engagement）互动率，单位是 %：平均每条互动数 ÷ 粉丝数 × 100。0.0118 表示 0.0118%。 |
| media_mix | （engagement）各类帖子的条数，对象：image 图片、carousel 轮播、reel Reels。 |
| posts_by_hour_utc | （engagement）按发帖的钟点（UTC）分的条数，24 个数，第 1 个是 0 点。 |
| top_hours_utc | （engagement）发帖最多的几个钟点（UTC 的小时数，0–23），多的在前。 |
| posts_by_weekday_utc | （engagement）按星期几（UTC）分的发帖条数，7 个数，依次是周日、周一……周六。 |
| top_posts | （engagement）互动最多的 3 条帖子，每项：url、text（正文的前 140 个字符）、posted_at、interactions（点赞 + 评论）、like_count、comment_count、view_count（图片帖没有这一项）。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "instagram",
  "action": "engagement",
  "params": {
    "username": "nasa"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "instagram",
        "action": "engagement",
        "params": {
            "username": "nasa",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "instagram",
  "action": "engagement",
  "results": {
    "username": …,
    "display_name": …,
    "url": …,
    "follower_count": …,
    "is_verified": …,
    "sample_size": …,
    "period_start": …,
    "period_end": …,
    "posts_per_week": …,
    "avg_like_count": …,
    "avg_comment_count": …,
    "avg_view_count": …,
    "median_like_count": …,
    "avg_interactions": …,
    "median_interactions": …,
    "engagement_rate": …,
    "media_mix": …,
    "posts_by_hour_utc": …,
    "top_hours_utc": …,
    "posts_by_weekday_utc": …,
    "top_posts": …,
    "platform": …
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=instagram
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
