---
title: "YouTube 字幕接口：按链接取完整字幕 · SocialToAI"
canonical: https://socialtoai.com/zh/youtube-transcript-api/
updated: 2026-10-30
---

# YouTube 字幕接口

用链接或视频编号取任意公开 YouTube 视频的完整字幕：语言、全文，以及每一段的开始和结束时间。它是 YouTube 详情调用加上 `include=transcript`，每个视频 2 积分（约 ¥0.05），失败不扣。可以用 HTTP 调用，也可以让 AI 通过 MCP 调用。

- 页面：https://socialtoai.com/zh/youtube-transcript-api/
- 最近更新：2026-10-30

## 能拿到什么

每个视频一个对象。视频用视频链接：watch、shorts、embed、live 或 youtu.be 的写法或视频编号指定。

| 字段 | 类型 | 含义 |
| --- | --- | --- |
| `fields.lang` | string | 逐字稿的语言。 |
| `fields.text` | string | 全文。 |
| `fields.segments` | array | 带时间的分段：start、end、text。 |

## 请求

**cURL**

```
curl https://api.socialtoai.com/v1/detail \
  -H "Authorization: Bearer $SOCIALTOAI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "youtube",
    "id": "dQw4w9WgXcQ",
    "include": "transcript"
  }'
```

**Python**

```
import os
import uuid
import requests

response = requests.post(
    "https://api.socialtoai.com/v1/detail",
    headers={
        "Authorization": f"Bearer {os.environ['SOCIALTOAI_API_KEY']}",
        # A new key for each request; the same one again retries it without paying twice.
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "platform": "youtube",
        "id": "dQw4w9WgXcQ",
        "include": "transcript",
    },
)
print(response.json())
```

**一次录制的返回（名称和正文已去掉）**

```
{
  "request_id": "req_00000000-0000-4000-8000-000000000001",
  "schema_version": "v1",
  "fetched_at": "2026-10-12T03:34:28.000Z",
  "action": "detail",
  "platform": "youtube",
  "status": "ok",
  "items": [
    {
      "platform": "youtube",
      "id": "…",
      "ref": "…",
      "approx": [],
      "type": "entry",
      "entry_type": "transcript",
      "title": null,
      "url": null,
      "rank": null,
      "heat": null,
      "fields": {
        "lang": "en",
        "text": "…",
        "segments": [
          {
            "start": 0.4,
            "end": 4.24,
            "text": "…"
          },
          {
            "start": 2.08,
            "end": 6.56,
            "text": "…"
          }
        ]
      }
    }
  ],
  "unavailable": [],
  "warnings": [],
  "applied_params": {
    "id": "dQw4w9WgXcQ",
    "include": "transcript"
  },
  "cost_credits": 2,
  "billing": {
    "cost_credits": 2,
    "balance_credits": 98,
    "today_spend_credits": 2,
    "daily_limit_credits": null,
    "daily_remaining_credits": null,
    "display": "本次 2 积分（约 $0.0067），余额 98 积分（约 $0.33）"
  },
  "replayed": false
}
```

## YouTube 官方 API 能给什么

YouTube 官方 Data API 只能为登录用户下载他有编辑权限的视频的字幕，并按次扣配额；任意公开视频的字幕它不给。

| 官方 API | 谁能用 | 费用 | 限制 | 来源 |
| --- | --- | --- | --- | --- |
| YouTube Data API v3 | 有 Google Cloud 项目和 API Key 的开发者。 | 配额内免费：默认每天 100 次 search.list，其余接口合计 10,000 单位。 | 读一个列表通常 1 单位；要更多配额得填 Google 的配额扩展申请表。 | [developers.google.com](https://developers.google.com/youtube/v3/getting-started)，核对于 2026-10-29 |
| 字幕下载（captions.download） | 对视频有编辑权限、已登录授权的用户。 | 每次 200 配额单位。 | 只能下载自己能编辑的视频的字幕，任意公开视频不行。 | [developers.google.com](https://developers.google.com/youtube/v3/docs/captions/download)，核对于 2026-10-29 |

## 在 AI 客户端里

通过 [MCP](https://socialtoai.com/zh/mcp.md) 把 SocialToAI 接一次，然后用大白话问。AI 自己发调用、读字幕。

| 提问 | 积分 |
| --- | --- |
| 读一下这条 YouTube 视频：dQw4w9WgXcQ | 2 |

## 花多少

每个视频 2 积分：按第一档约 $0.0067（约 ¥0.05），一千个视频约 $6.67。失败不扣；一批要花多少，用[成本估算](https://socialtoai.com/zh/free-tools/api-cost-estimator.md) 算一下。注册送 100 积分，不用绑卡。

## 常见问题

### 任意公开的 YouTube 视频都能取字幕吗？

能，用链接或视频编号，每个视频 2 积分（约 ¥0.05）。调用失败不扣。

### YouTube 官方 API 能取字幕吗？

只能取你有编辑权限的视频：官方字幕下载要求对视频有编辑权限，每次 200 配额单位。

### 要建 Google Cloud 项目或登录 YouTube 账号吗？

不用。只要一把 SocialToAI 的 Key，或在 AI 客户端里登录。

### Claude 或 ChatGPT 能读 YouTube 字幕吗？

能。通过 MCP 接上 SocialToAI 后，把链接给它，让它取字幕或做总结。

- [YouTube 详情接口](https://socialtoai.com/zh/youtube-detail-api.md)：完整的调用、参数和字段。
- [YouTube API](https://socialtoai.com/zh/platforms/youtube.md)：YouTube 上的每个调用和积分。
- [怎么用 AI 看 YouTube 上大家怎么聊一个产品？](https://socialtoai.com/zh/docs/guides/track-brand-mentions-on-youtube.md)：一次 YouTube 上的录制。
- [YouTube MCP 服务器](https://socialtoai.com/zh/mcp/youtube.md)：让你的 AI 读 YouTube。
