# Instagram 内容发现 API (instagram.discover)

- Canonical page: https://everyinfra.com/instagram-api/discover
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "instagram", "action": "discover", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 30, max 200 per call
- Mode: async by default (202 + job_id, poll GET /api/v1/jobs/{job_id})

Instagram 内容发现按 `keyword` 取一个话题标签下的内容，每条有帖子链接和正文，带媒体类型，点赞、评论、浏览三个数，以及作者用户名和 ID、发布时间、地点。它和话题内容查的是同一类东西，差别在条数和运行方式：这里默认 30 条、单次最多 200 条，调用是异步的，先返回 `job_id`，任务完成后才能取到列表。

虽然参数叫 `keyword`，它填的是话题标签词：开头的 # 会被去掉，再去查这个标签，并不是任意文本的全文搜索。话题内容那一页用的参数名不同，换页时别把请求原样照搬。`results_type` 省略时给普通帖子，传 `reel` 或 `reels` 改成短视频。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | discover 的话题标签词，会去掉开头 # 后查询 hashtag；不是任意全文关键词搜索。与 hashtag action 的输入名不同。 |
| results_type | enum: reel / reels | no | not declared | discover/hashtag 省略此参数时返回 posts（普通帖子）；显式传参只接受 reel 或 reels，均切换到短视频结果。posts 不是可显式提交的枚举值，其他显式值也会在公开 API 参数校验阶段返回 422；该参数不是 JSON/CSV 输出格式选择。 |
| limit | integer (1–200) | no | 30 | 这次调用最多返回的条数，整数，1–200；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| post_id | 帖子 ID。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| media_type | 媒体类型（图/视频/轮播）。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| author_name | 作者昵称（显示名）。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| location | 地理位置描述，原文透传，格式随平台而异。 |
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| image_url | 图片链接。多图能力可能返回 image_urls 数组。 |
| video_url | platform-native meaning |
| author_id | 作者在原平台的唯一 ID。 |
| width | platform-native meaning |
| height | platform-native meaning |
| is_comments_disabled | 帖子是否关闭评论。 |
| author_follower_count | 作者粉丝数。null 表示不公开。 |
| hashtags | 正文里的话题标签数组，按出现顺序；没有时不出现这个字段。 |
| top_comments | 帖子下展示的几条评论，每项含正文（text）和评论人（author_username）；没有时不出现这个字段。 |

## 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": "discover",
  "params": {
    "keyword": "coffee"
  }
}'
```

```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": "discover",
        "params": {
            "keyword": "coffee",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-10-24T18:28:34Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 18. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "instagram",
  "action": "discover",
  "results": [
    {
      "post_id": "De4za3DANzi",
      "url": "https://www.instagram.com/p/De4za3DANzi/",
      "text": "Some days I wake up a baddie, and some days I wake up a saddie.\n.\n.\n.\n.\n.\n.\n#fyp #instamood #burberry #coffee #cafe @••• @••• @••• @••• @•••",
      "media_type": "image",
      "like_count": -1,
      "comment_count": 0,
      "author_username": "•••",
      "author_name": "•••",
      "posted_at": "2026-10-24T18:43:18+00:00",
      "id": "•••",
      "image_url": "https://scontent-cph2-1.cdninstagram.com/v/t51.82787-15/865668555_18501136627099477_1202278696858241993_n.jpg?stp=dst-jpg_e35_p1080x1080_sh2.08_tt6&_nc_cat=102&ig_cache_key=NDAxNTE4NDU5MzExMTA0MDM5MQ%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=58cdad&efg=eyJ2ZW5jb2RlX3RhZyI6IkNBUk9VU0VMX0lURU…",
      "author_id": "•••",
      "width": 2479,
      "height": 3305,
      "hashtags": [
        "fyp",
        "instamood",
        "burberry"
      ]
    },
    {
      "post_id": "De4zXldkb3j",
      "url": "https://www.instagram.com/p/De4zXldkb3j/",
      "text": "♥️🌎🌎👌🏻👌🏻.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n#لايك #الكحلي #coffee #flowers #venezuela",
      "media_type": "image",
      "like_count": 1,
      "comment_count": 0,
      "author_username": "•••",
      "author_name": "•••",
      "posted_at": "2026-10-24T18:42:51+00:00",
      "id": "•••",
      "image_url": "https://scontent-cph2-1.cdninstagram.com/v/t51.82787-15/863292678_17970790107172812_3863795868010461481_n.webp?stp=dst-webp_p1080x1080_sh2.08&_nc_cat=102&ig_cache_key=NDAxNTE4NDUzNjc5NDMwNjU5MQ%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=58cdad&efg=eyJ2ZW5jb2RlX3RhZyI6IkNBUk9VU0VMX0lURU0ueHBp…",
      "author_id": "•••",
      "width": 1440,
      "height": 1920,
      "hashtags": [
        "لايك",
        "الكحلي",
        "coffee"
      ]
    }
  ],
  "count": 18,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### `keyword` 可以搜任意词吗？

不能。它必须是话题标签词，系统去掉开头的 # 之后，去查这个标签下的内容。填 coffee 就是查 #coffee，而不是在全站帖子正文里找 coffee。要找某个账号，请用账号搜索。

### 内容发现和话题内容怎么选？

要一次拿得多、又能等任务完成，用内容发现，单次最多 200 条；要马上拿到结果，用话题内容，它是同步返回，单次最多 100 条。两页默认都是 30 条，`results_type` 的取值也相同，要的标签相同时，字段基本一样。

### `author_follower_count` 和 `location` 读的时候要注意什么？

`author_follower_count` 为 null 表示作者没有公开粉丝数，不等于 0，按作者体量排序时要单独放。`location` 是平台原文透传，格式随平台而异，入库前别按固定格式解析，先当一段文本存下。

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