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

# Instagram API

> 以 JSON 读取公开的 Instagram 个人主页、带点赞数和评论数的最新帖子、单条帖子和 Reels、评论以及关键词搜索。

通过异步任务 API 以 JSON 读取公开的 Instagram 数据。发送 `taskType` `SOCIAL` 并设置 `platform` `instagram`，用 `action` 选择要读取的内容。每次完成的请求消耗 **0.5 积分**。

## 请求

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "SOCIAL", "payload": { "platform": "instagram", "action": "profile", "username": "natgeo" } }'
```

提交任务后，轮询 `GET /v1/async/task/{id}` 或通过 webhook 接收。参见[异步任务](https://docs.querying.ai/zh/concepts/async-tasks.md)。

## 操作

| `action` | 读取内容 | 必填 |
| - | - | - |
| `search`（默认） | 某个关键词的帖子和 Reels | `query` |
| `profile` | 公开账号的个人主页及其最新 12 条帖子 | `username` |
| `posts` | 账号最新 12 条帖子，各带计数 | `username` |
| `post` | 一条帖子或 Reel 及其前几条评论 | `postUrl` |
| `comments` | 帖子的评论 | `postUrl` |

`username` 接受用户名或个人主页 URL。`postUrl` 接受帖子、Reel 或 IGTV 的 URL，例如 `https://www.instagram.com/p/Df147tCiAyB/`。

## 参数

* `query`：`search` 必填。关键词、话题标签词或品牌名。
* `limit`：可选。`search` 范围 1-30，默认 10。`posts` 范围 1-12，默认 12。`comments` 范围 1-500，默认 50。

## 响应示例

```json theme={"theme":"css-variables"}
{
  "platform": "instagram",
  "action": "profile",
  "id": "787132",
  "username": "natgeo",
  "displayName": "National Geographic",
  "biography": "Step into wonder and find your inner explorer with National Geographic.",
  "profileUrl": "https://www.instagram.com/natgeo/",
  "isVerified": true,
  "isPrivate": false,
  "followerCount": 268096466,
  "followingCount": 195,
  "postCount": 32000,
  "hasReels": true,
  "threadsUsername": "natgeo",
  "latestStoryAt": "2026-11-17T15:07:32.000Z",
  "recentPosts": [
    {
      "id": "4032379434794749057",
      "code": "Df147tCiAyB",
      "url": "https://www.instagram.com/p/Df147tCiAyB/",
      "mediaType": "carousel",
      "caption": "National Geographic photographers ventured to places far and wide this year.",
      "imageUrl": "https://scontent.cdninstagram.com/v/t51.82787-15/912032737.jpg"
    }
  ]
}
```

## 结果字段

* 每个响应都会原样返回 `platform` 和 `action`。列表带有 `returnedCount`。
* `profile` 返回 `id`、`username`、`displayName`、`biography`、`bioLinks`、`avatarUrl`、`profileUrl`、`isVerified`、`isPrivate`、`followerCount`、`followingCount`、`postCount`、`hasReels`、`highlights`、`threadsUsername`、`pronouns` 和 `recentPosts`。账号有快拍在线时会出现 `latestStoryAt`，`isMemorialized` 表示纪念账号。
* `posts` 返回 `posts`，即账号最新的 12 条帖子，带有从每条帖子页面读取的 `likeCount`、`commentCount` 和 `publishedAt`。
* `post` 返回 `post` 和帖子的前几条 `comments`。帖子包含 `id`、`code`、`url`、`mediaType`（`image`、`video` 或 `carousel`）、`caption`、`imageUrl`、`images`、`videoUrl`、`width`、`height`、`likeCount`、`commentCount`、`publishedAt`、`username`、`authorFullName`、`authorIsVerified`、`authorProfileImageUrl`、`coauthors`、`taggedUsers`、`topics`、`audio`（歌曲或作者的原创音频）、`hasAudio`、`captionIsEdited`、`aiLabel` 和 `commentsDisabled`。
* `comments` 返回 `comments`，每条评论包含 `id`、`text`、`username`、`likeCount`、`replyCount` 和 `publishedAt`。GIF 评论带有 `gifUrl`。`availableCount` 是帖子的评论数，`partial: true` 表示列表短于该数量。
* `search` 返回 `posts`，包含 `position`、作者的 `username`、`authorId`、`authorIsVerified` 和 `authorProfileImageUrl`，Reels 还有 `playCount`。Instagram 为该关键词提供搜索页时，`source` 为 `instagram`，并加上该页的 `title`、`relatedKeywords`、Instagram 对该关键词的 `summary`，以及脚注编号所指的 `sources`。其他关键词的 `source` 为 `web`，`posts` 包含最近 30 天的公开帖子和 Reels。
* Instagram 向未登录的访客显示个人主页最新的 12 条帖子和一条帖子的十几条评论，`posts`、`post` 和 `comments` 返回的就是这些内容。搜索结果的计数和发布时间请用 `post` 读取。
* 不存在的账号或帖子、私密帖子，或 Instagram 只向已登录访客显示的页面，会使任务以 `PAGE_UNAVAILABLE` 结束。只对完成的请求计费。

## 相关

* [YouTube](https://docs.querying.ai/zh/engines/youtube.md)
* [Threads](https://docs.querying.ai/zh/engines/threads.md)
* [引擎概览](https://docs.querying.ai/zh/engines/overview.md)
* [积分与限制](https://docs.querying.ai/zh/concepts/credits-and-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.