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

# YouTube 趋势视频

> 按国家获取 YouTube 某个分类的趋势视频，按名次排列。

# YouTube 趋势视频

读取 YouTube 在某个国家为某个分类维护的趋势页，按名次返回其中的视频。选择新闻、游戏、体育、学习、课程、时尚或购物分类，再给出两位字母的国家代码，每条视频都带名次、标题、频道、播放次数、时长、缩略图，以及发布到现在多久。按固定频率重复查询同一个分类和国家，就能看出哪些视频和频道一直留在榜上，哪些是新冲上来的。

```json theme={"dark"}
{
  "category": "news",
  "region": "US",
  "results_limit": 50
}
```

category 必填：news、gaming、sports、learning、courses、fashion 或 shopping。region 为两位字母国家代码，默认 US。按名次返回该分类的趋势视频；results\_limit 默认 50，可设 1 到 50。

## 标准结果字段

任务结果使用下方稳定的 SocQ 字段。系统会统一来源特有的字段名和格式，但不会推断或补充来源未提供的数据。如需缩小返回字段集合，MCP 查询使用 `fields`，Typed 工具使用 `_result_fields`，CLI 使用 `--result-fields`。声明字段的值为 `null` 时仍会保留。

| 字段 | 类型 | 可空 | 说明 |
| - | - | - | - |
| `id` | `string` | 是 | YouTube 视频 ID。 |
| `platform` | `string` | 否 | 结果所属的平台，例如 `instagram` 或 `linkedin`。 |
| `resource` | `string` | 否 | 该结果对应的 SocQ 资源，例如 `videos` 或 `comments`。 |
| `type` | `string` | 否 | 结果项的类别，例如 `video`、`post` 或 `comment`。 |
| `url` | `string` | 是 | 视频的观看地址。 |
| `published_at` | `string` | 是 | 视频的发布时间，使用 ISO 8601 格式。趋势页上显示的发布时长见 published\_time\_text。 |
| `collected_at` | `string` | 否 | SocQ 采集或处理该结果的时间，使用 ISO 8601 格式。 |
| `rank` | `integer` | 是 | 视频在趋势页上的名次，从 1 开始。 |
| `category` | `string` | 是 | 视频所在的趋势分类，例如 `news` 或 `gaming`。 |
| `region` | `string` | 是 | 趋势页所属国家的两位字母代码。 |
| `title` | `string` | 是 | 视频标题。 |
| `text` | `string` | 是 | 趋势页上显示的视频简介片段。 |
| `author` | `object` | 是 | 发布视频的频道。 |
| `author.id` | `string` | 是 | 作者的唯一标识。 |
| `author.username` | `string` | 是 | 账号的公开用户名或账号标识。 |
| `author.name` | `string` | 是 | 作者的显示名称。 |
| `author.url` | `string` | 是 | 作者的公开访问地址（如可获得）。 |
| `author.avatar_url` | `string` | 是 | 账号头像图片的地址。 |
| `author.is_verified` | `boolean` | 是 | 账号是否已通过平台认证。 |
| `author.is_private` | `boolean` | 是 | 账号是否为私密账号。 |
| `metrics` | `object` | 是 | 结果项可获得的计数和度量数据。 |
| `metrics.views_count` | `integer` | 是 | 趋势页上显示的播放次数。 |
| `duration_seconds` | `number` | 是 | 视频时长，单位为秒。 |
| `thumbnail_url` | `string` | 是 | 视频缩略图的地址。 |
| `published_time_text` | `string` | 是 | YouTube 显示的发布时间距今多久，例如 `3h ago`。 |

以下示例展示任务完成后的响应格式，具体数据以实际查询结果为准。

## 任务完成响应

```json theme={"dark"}
{
  "code": 200,
  "data": {
    "task_id": "example-youtube-trending-videos",
    "status": "succeeded",
    "public_id": "youtube/trending-videos",
    "result_count": 2,
    "credits_amount": 1,
    "results": {
      "limit": 50,
      "next_cursor": null,
      "has_more": false,
      "schema_id": "trending-video",
      "schema_version": "1.0",
      "items": [
        {
          "id": "X92BwhZZKOU",
          "platform": "youtube",
          "resource": "trending-videos",
          "type": "video",
          "url": "https://www.youtube.com/watch?v=X92BwhZZKOU",
          "published_at": null,
          "collected_at": "2026-11-20T08:10:17Z",
          "rank": 1,
          "category": "news",
          "region": "US",
          "title": "Historic or just a photo op? Reading Trump's Xi-Putin summit",
          "text": "US President Donald Trump hailed his unprecedented three-way summit with Chinese President Xi Jinping and Russian President Vladimir Putin as a success.",
          "author": {
            "id": "UChqUTb7kYRX8-EiaN3XFrSQ",
            "username": "Reuters",
            "name": "Reuters",
            "url": "https://www.youtube.com/@Reuters",
            "avatar_url": "https://example.com/reuters-avatar.jpg",
            "is_verified": true,
            "is_private": null
          },
          "metrics": {
            "views_count": 387
          },
          "duration_seconds": 177,
          "thumbnail_url": "https://i.ytimg.com/vi/X92BwhZZKOU/hqdefault.jpg",
          "published_time_text": "15 min ago"
        },
        {
          "id": "FKBYgR7fz0I",
          "platform": "youtube",
          "resource": "trending-videos",
          "type": "video",
          "url": "https://www.youtube.com/watch?v=FKBYgR7fz0I",
          "published_at": null,
          "collected_at": "2026-11-20T08:10:17Z",
          "rank": 2,
          "category": "news",
          "region": "US",
          "title": "Trump put Xi Jinping in HIS PLACE, expert says",
          "text": "Fox News co-host Charlie Hurt and author Gordon Chang discuss President Donald Trump's trilateral meeting with Xi Jinping and Vladimir Putin in China on 'Hannity.'",
          "author": {
            "id": "UCXIJgqnII2ZOINSWNOGFThA",
            "username": "FoxNews",
            "name": "Fox News",
            "url": "https://www.youtube.com/@FoxNews",
            "avatar_url": "https://example.com/foxnews-avatar.jpg",
            "is_verified": true,
            "is_private": null
          },
          "metrics": {
            "views_count": 4987
          },
          "duration_seconds": 496,
          "thumbnail_url": "https://i.ytimg.com/vi/FKBYgR7fz0I/hqdefault.jpg",
          "published_time_text": "1 hr ago"
        }
      ]
    }
  }
}
```


## OpenAPI

````yaml zh/api-manual/agent-api/agent-api.json POST /v1/youtube/trending-videos
openapi: 3.1.0
info:
  title: SocQ Agent API 中文版
  version: v1-c5d5a0c07a78
  description: 根据 SocQ 能力目录生成的异步社交数据 API。
servers:
  - url: https://api.socq.ai
security: []
paths:
  /v1/youtube/trending-videos:
    post:
      tags:
        - youtube
      summary: YouTube 趋势视频
      description: 按国家获取 YouTube 某个分类的趋势视频，按名次排列。
      operationId: socq_youtube_trending_videos
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $schema: https://json-schema.org/draft/2020-12/schema
              type: object
              additionalProperties: false
              properties:
                callback_url:
                  type: string
                  format: uri
                  description: 可选的任务完成回调 URL。
                category:
                  type: string
                  minLength: 1
                  enum:
                    - courses
                    - fashion
                    - gaming
                    - learning
                    - news
                    - shopping
                    - sports
                  description: 趋势分类：news、gaming、sports、learning、courses、fashion 或 shopping。
                region:
                  type: string
                  minLength: 1
                  pattern: ^[A-Za-z]{2}$
                  default: US
                  description: 趋势页所属国家的两位字母代码，例如 US、GB 或 JP，默认 US。
                results_limit:
                  type: integer
                  minimum: 1
                  maximum: 50
                  default: 50
                  description: 返回的视频数量，默认 50，最多 50。
              required:
                - category
              description: >-
                category 必填：news、gaming、sports、learning、courses、fashion 或
                shopping。region 为两位字母国家代码，默认 US。按名次返回该分类的趋势视频；results_limit 默认
                50，可设 1 到 50。
      responses:
        '200':
          description: 任务已受理
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSubmitResponse'
        '422':
          description: Input validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentValidationErrorResponse'
      security:
        - bearerAuth: []
        - apiKeyAuth: []
components:
  schemas:
    AgentSubmitResponse:
      type: object
      properties:
        code:
          type: integer
          const: 200
          description: HTTP 业务状态码。
        data:
          type: object
          properties:
            task_id:
              type: string
              description: 任务 ID，用于查询任务状态和结果。
            status:
              type: string
              description: 任务当前状态。
            created_time:
              type:
                - string
                - 'null'
              description: 任务创建时间。
          required:
            - task_id
            - status
    AgentValidationErrorResponse:
      type: object
      properties:
        code:
          type: integer
          const: 422
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            details:
              type: object
          required:
            - message
            - type
      required:
        - code
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: '使用 `Authorization: Bearer <token>` 请求头进行身份验证。'
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: 也可以通过 `x-api-key` 请求头提供 API Key。

````

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