# Instagram 帖子详情 API

> 按短码或链接取一条帖子或 Reel：文案、作者、点赞、评论和播放、图片，以及合拍帖的其他作者。

网页版：https://okdata.online/zh/apis/instagram/posts/get/

- **接口**：`GET /v1/instagram/posts/get`
- **ID**：`instagram.posts.get`
- **价格**：$0.004/次
- **返回**：一个 Post 对象（`data.item`）
- **状态**：预览
- **适合**：竞品监控、内容调研

## 价格

每次调用 $0.004，返回一个结果。查 1,000 次共 $4.00。失败的调用不扣费。

## 参数

| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| `id` | string | 否 |  | 帖子短码：链接里 /p/ 或 /reel/ 后面那一段。id 和 url 二选一。（例：`DeCPVhERA8e`） |
| `url` | string | 否 |  | 分享链接或网页地址，会从中解析出 ID。（例：`https://www.instagram.com/p/DeCPVhERA8e/`） |
| `view` | string: compact / standard / full | 否 | `standard` | 返回多少字段。full 会在 ext 里带上平台特有字段。 |
| `fields` | string[] | 否 |  | 只保留这些字段，按路径写（如 author.name），用来省 token。放在查询参数里时用逗号分隔。 |

id 和 url 给一个就行。 
cursor、view、fields 的用法见 [请求说明](https://okdata.online/zh/docs/requests/)。

## 返回字段

每一条都是一个 [Post](https://okdata.online/zh/docs/objects/post/)。

| 字段 | 类型 | 说明 |
|---|---|---|
| `id` | string | 内容在平台上的 ID。 |
| `url` | string | 内容链接。 |
| `type` | string | 内容类型。 |
| `title` | string \| null | 标题（视频、笔记、文章才有）。 |
| `text` | string | 文案、正文或简介，纯文本；文章为 Markdown。 |
| `lang` | string \| null | 语言代码，平台给出或检测得到。 |
| `published_at` | string \| null | 发布时间，ISO 8601，UTC；只有数据源不给时间时为 null（wechat_mp.articles.metrics、wechat_channels.videos.metrics、youtube.channels.videos.list 取 Shorts 时），并列在 meta.unavailable 里。 |
| `author` | AccountRef | 发布者。 |
| `metrics` | Metrics | 抓取时的数据；平台不公开的为 null。 |
| `images` | string[] \| null | 图文内容的图片地址。 |
| `hashtags` | string[] \| null | 话题标签，不带 #。 |
| `ext` | object | 平台特有字段，只在 view=full 时返回。 |

## 请求示例

### cURL

```bash
curl -G "https://api.okdata.online/v1/instagram/posts/get" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'id=DeCPVhERA8e'
```

### Python

```python
import os
import requests

resp = requests.get(
    "https://api.okdata.online/v1/instagram/posts/get",
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"id": "DeCPVhERA8e"},
    timeout=60,
)
body = resp.json()
if body["code"] != "ok":
    raise RuntimeError(f"{body['code']}: {body['message']} (charged: {body['charged']})")

row = body["data"]["item"]
print(row["id"], row["metrics"]["likes"], row["text"][:60])
print("cost: $" + body["meta"]["billing"]["amount"])
```

### TypeScript

```ts
const url = new URL('https://api.okdata.online/v1/instagram/posts/get');
url.searchParams.set('id', "DeCPVhERA8e");

const res = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OKDATA_API_KEY}`,
  },
});
const body = await res.json();
if (body.code !== 'ok') throw new Error(`${body.code}: ${body.message}`);

const row = body.data.item;
console.log(row.id, row.metrics.likes, row.text.slice(0, 60));
console.log('cost: $' + body.meta.billing.amount);
```

### MCP

```json
{
  "name": "call",
  "arguments": {
    "capability": "instagram.posts.get",
    "id": "DeCPVhERA8e"
  }
}
```

或者对接好 MCP 的智能体直接说：

> 用「Instagram 帖子详情」找出点赞最多的五条内容，附链接。

## 返回示例

```json
{
  "code": "ok",
  "request_id": "0f6c2a8e-4b1d-4e0a-9a51-3c7d2b9e1f20",
  "data": {
    "item": {
      "id": "DeCPVhERA8e",
      "url": "https://www.instagram.com/p/DeCPVhERA8e/",
      "type": "video",
      "title": null,
      "text": "Two nights, one backpack: the full camping kit. #camping #gear",
      "lang": null,
      "published_at": "2026-11-02T09:30:00Z",
      "author": {
        "id": "528817151",
        "username": "trailkit",
        "name": "Trail Kit",
        "avatar_url": "https://cdn.example.com/avatar/trailkit.jpg",
        "followers": 182300,
        "verified": true
      },
      "metrics": {
        "views": 1250000,
        "likes": 48200,
        "comments": 1312,
        "shares": null,
        "favorites": null,
        "reposts": null
      },
      "images": [
        "https://scontent.cdninstagram.example.com/DeCPVhERA8e.jpg"
      ],
      "hashtags": [
        "camping",
        "gear"
      ]
    }
  },
  "warnings": [],
  "meta": {
    "capability": "instagram.posts.get",
    "billing": {
      "amount": "0.004",
      "currency": "USD",
      "balance_after": "9.996"
    },
    "unavailable": {
      "metrics.shares": "platform",
      "metrics.favorites": "platform",
      "metrics.reposts": "platform"
    },
    "cached": false,
    "replayed": false,
    "fetched_at": "2026-11-11T08:00:00Z"
  }
}
```

## 错误

所有错误同一种结构：code、request_id、message 和 message_zh（每个 code 一句固定的话）、charged、retry、retry_after_seconds、param 和 docs_url，具体问题写在 problems 里。错误不扣费；只有 settlement_unknown 的扣费结果要查询后才知道。完整列表：https://okdata.online/zh/docs/errors/

## 常见问题

### Instagram 帖子详情接口多少钱？

每次调用 $0.004，返回一个结果。查 1,000 次共 $4.00。失败的调用不扣费。

### 可以直接传分享链接吗？

可以。把链接放进 url 参数，okdata 会从中解析出 ID，短链接也行。

### 需要Instagram账号、Cookie 或扫码登录吗？

不需要。只要带上 okdata 的 API key。返回的是Instagram上的公开数据，不会用到你自己的Instagram账号。

### 调用失败会扣费吗？

不会。所有错误都会返回 charged: false；只有超时返回 charged: null，表示结果还没确定。带同一个 Idempotency-Key 重发，绝不会重复扣费。

### Instagram不展示某个字段怎么办？

这个字段会是 null，meta.unavailable 里会列出它和原因：platform（平台本来就不展示）或 capability（我们暂时取不到）。

## Instagram的其他接口

- [Instagram 账号信息](https://okdata.online/zh/apis/instagram/users/get/)：$0.004/次
- [Instagram 账号帖子](https://okdata.online/zh/apis/instagram/users/posts/list/)：$0.004/次 · 每页约 12 条帖子
- [Instagram 帖子评论](https://okdata.online/zh/apis/instagram/posts/comments/list/)：$0.004/次 · 每页约 15 条评论
- [Instagram 评论回复](https://okdata.online/zh/apis/instagram/comments/replies/list/)：$0.004/次 · 每页约 15 条评论
- [Instagram 话题帖子](https://okdata.online/zh/apis/instagram/hashtags/posts/list/)：$0.004/次 · 每页约 10 条帖子
- [Instagram 视频字幕](https://okdata.online/zh/apis/instagram/posts/transcript/get/)：$0.004/次
- [Instagram 账号搜索](https://okdata.online/zh/apis/instagram/users/search/)：$0.002/次 · 每页约 20 个账号

## 概要

- **简称**：Instagram 帖子详情
- **英文名**：Instagram post detail API
- **分类**：[社交媒体](https://okdata.online/zh/categories/social/)
- **数据类型**：[内容详情接口](https://okdata.online/zh/roles/posts-get/)
- **状态**：预览。还可能调整，改动会提前公告。
- **价格**：$0.004（约 ¥0.028） / 次 · 出错和超时不收费
- **返回**：一个 Post，放在 data.item 里
- **调用出错时**：不收费。一个数据源出错就换下一个；出错和超时都不扣费。

## 什么时候收费

- 返回了数据：$0.004，每次调用收一次
- 参数不合法、出错、超时：不收费

| 情况 | 收费 |
|---|---|
| 单次最高扣费 | $0.004 |
| 空结果 | 不收费 |
| 查无此项（平台上没有） | 不收费 |
| 参数不合法、出错、超时 | 不收费 |
| 24 小时内带同一个 Idempotency-Key 重试 | 只扣一次 |

调用失败不收费；空结果不收费；查无此项不收费。

价格取自价目表版本 1b273c48fea9634e。 [这个平台的全部价格](https://okdata.online/zh/pricing/instagram/)

- 新账号送 $0.10 试用额度，不用绑卡：够调这个接口 25 次。
- 查 1,000 次共 $4.00。

## 已知限制

- `id`、`url` 只给一个。

## 各视图返回的字段

“视图”一列是字段最早出现的 `view`：`compact` 只返回 compact 字段，`standard` 再加上 standard 字段，`full` 返回全部。默认是 `standard`。

- `compact`：`id`, `url`, `type`, `title`, `text`, `published_at`, `author`, `metrics`
- `standard`：`lang`, `images`, `hashtags`
- `full`：`ext`

## 这个接口给不了的

- `metrics.shares`：平台不展示（为 null，列在 meta.unavailable 里）
- `metrics.favorites`：平台不展示（为 null，列在 meta.unavailable 里）
- `metrics.reposts`：平台不展示（为 null，列在 meta.unavailable 里）

## 这个接口的常见报错

| 状态码 | 代码 | 含义 | 是否扣费 | 能否重试 |
|---|---|---|---|---|
| 400 | `invalid_params` | 参数缺失、类型或取值不对，或者请求方法不对。problems 列出每一处问题，param 是第一个出错的参数。 | 否 | 修正后重试 |
| 401 | `unauthorized` | Key 缺失、格式不对、已撤销、已停用或已过期（知道原因时 reason 会写明）。 | 否 | 不要重试 |
| 402 | `insufficient_balance` | 余额（available）不够这次调用的最高费用（required）。 | 否 | 修正后重试 |
| 404 | `not_found` | 内容、账号或页面不存在或不公开。charge_when_not_found 大于 0 的接口会对这个结果计费（数据源也向我们收了钱）：这时返回体里 charged 为 true，并给出 amount。 | 否 | 不要重试 |
| 429 | `rate_limited` | 账号这一分钟请求太多（reason: rate），或同时进行的调用太多（reason: concurrency）。 | 否 | 可以重试 |
| 500 | `settlement_unknown` | 数据已返回，但没能确认是否扣费。 | 查询后才知道 | 用同一个 Idempotency-Key 重试 |
| 502 | `upstream_failed` | 这个接口的所有数据源这次都失败了。 | 否 | 可以重试 |
| 503 | `capability_paused` | 这个接口暂时停用了，这次没有执行。 | 否 | 可以重试 |
| 504 | `timeout` | 数据没有及时返回。预扣已退回，这次没有扣费。 | 否 | 可以重试 |

[全部错误码](https://okdata.online/zh/docs/errors/)

## 其他平台的同类数据

- [抖音视频详情](https://okdata.online/zh/apis/douyin/videos/get/)：$0.002/次
- [小红书笔记详情](https://okdata.online/zh/apis/xiaohongshu/notes/get/)：$0.02/次
- [公众号文章详情](https://okdata.online/zh/apis/wechat_mp/articles/get/)：$0.02/次
- [B站视频详情](https://okdata.online/zh/apis/bilibili/videos/get/)：$0.002/次
- [TikTok 视频详情](https://okdata.online/zh/apis/tiktok/videos/get/)：$0.002/次
- [X 帖子详情](https://okdata.online/zh/apis/x/posts/get/)：$0.0003/次
- [YouTube 视频详情](https://okdata.online/zh/apis/youtube/videos/get/)：$0.002/次
- [Reddit 帖子详情](https://okdata.online/zh/apis/reddit/posts/get/)：$0.002/次
- [快手作品详情](https://okdata.online/zh/apis/kuaishou/videos/get/)：$0.002/次
- [知乎文章详情](https://okdata.online/zh/apis/zhihu/articles/get/)（即将上线）：$0.002/次
- [视频号作品详情](https://okdata.online/zh/apis/wechat_channels/videos/get/)：$0.02/次
- [抖音星图视频数据报告](https://okdata.online/zh/apis/douyin/xingtu/videos/get/)：$0.004/次
- [小红书视频笔记详情（视频地址）](https://okdata.online/zh/apis/xiaohongshu/videos/get/)：$0.02/次
- [微博详情](https://okdata.online/zh/apis/weibo/posts/get/)：$0.002/次
- [YouTube 帖子详情](https://okdata.online/zh/apis/youtube/posts/get/)：$0.002/次

[内容详情接口](https://okdata.online/zh/roles/posts-get/)

## 在你的 AI 里用

> 先读 https://okdata.online/zh/apis/instagram/posts/get.md，再用 okdata 帮我调这个接口，key 在环境变量 OKDATA_API_KEY 里。用「Instagram 帖子详情」找出点赞最多的五条内容，附链接。
