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

# 按话题标签发现 YouTube 视频

> 使用 Bright Data Scraper API 发现带有指定话题标签的 YouTube 视频。发送 POST /datasets/v3/scrape 请求，dataset_id 为 gd_lk56epmy2i5g7lzu0k。

## 查询参数

<ParamField query="dataset_id" type="string" default="gd_lk56epmy2i5g7lzu0k" required>
  用于此请求的数据集 ID。

  <Warning>
    必须设置为 `gd_lk56epmy2i5g7lzu0k` 以收集**按主题标签发现视频**数据。
  </Warning>
</ParamField>

<ParamField query="type" type="string" default="discover_new">
  必须设置为 `discover_new`。
</ParamField>

<ParamField query="discover_by" type="string" default="hashtag">
  必须设置为 `hashtag`。
</ParamField>

<ParamField query="notify" type="boolean" default={false}>
  请求完成时是否发送通知。
</ParamField>

<ParamField query="include_errors" type="boolean" default={true}>
  是否在响应中包含错误。
</ParamField>

## 请求体

<ParamField body="input" type="object[]" required>
  输入对象数组。

  <Expandable title="properties">
    <ParamField body="hashtag" type="string" required>
      要发现YouTube视频的主题标签。
    </ParamField>

    <ParamField body="num_of_posts" type="number">
      要收集的帖子数量。缺少该值表示无限制。
    </ParamField>

    <ParamField body="posts_to_not_include" type="array">
      要从结果中排除的帖子URL数组。
    </ParamField>

    <ParamField body="start_date" type="string">
      用于筛选结果的开始日期 (MM-DD-YYYY)。
    </ParamField>

    <ParamField body="end_date" type="string">
      用于筛选结果的结束日期 (MM-DD-YYYY)。
    </ParamField>
  </Expandable>

  #### 示例

  ```json wrap theme={null}
  {
    "input": [
      {
        "hashtag": "trend",
        "num_of_posts": 20
      }
    ]
  }
  ```
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"input":[{"hashtag":"trend","num_of_posts":20}],"limit_per_input":null}' \
    "https://api.brightdata.com/datasets/v3/scrape?dataset_id=gd_lk56epmy2i5g7lzu0k&notify=false&include_errors=true&type=discover_new&discover_by=hashtag"
  ```

  ```python Python (requests) theme={null}
  import requests

  response = requests.post(
      "https://api.brightdata.com/datasets/v3/scrape",
      params={
          "dataset_id": "gd_lk56epmy2i5g7lzu0k",
          "notify": "false",
          "include_errors": "true",
          "type": "discover_new",
          "discover_by": "hashtag",
      },
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      json={
          "input": [{"hashtag": "trend", "num_of_posts": 20}],
          "limit_per_input": None,
      },
  )

  print(response.text)
  ```

  ```javascript Node.js (fetch) theme={null}
  const params = new URLSearchParams({
    dataset_id: "gd_lk56epmy2i5g7lzu0k",
    notify: "false",
    include_errors: "true",
    type: "discover_new",
    discover_by: "hashtag",
  });

  const response = await fetch(`https://api.brightdata.com/datasets/v3/scrape?${params}`, {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      input: [{ hashtag: "trend", num_of_posts: 20 }],
      limit_per_input: null,
    }),
  });

  console.log(await response.text());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  [
    {
      "url": "https://www.youtube.com/watch?v=4L_m0m3bEtE",
      "title": "Video Title Here",
      "youtuber": "@channelname",
      "video_url": "https://...",
      "video_length": 96,
      "likes": 18,
      "views": 1648,
      "date_posted": "2025-04-18T05:26:16.000Z",
      "description": "Video description...",
      "num_comments": 0,
      "subscribers": 4810000,
      "video_id": "4L_m0m3bEtE",
      "channel_url": "https://www.youtube.com/@channelname",
      "preview_image": "https://i.ytimg.com/vi/4L_m0m3bEtE/maxresdefault.jpg",
      "shortcode": "4L_m0m3bEtE",
      "verified": true,
      "handle_name": "Channel Name",
      "is_sponsored": false,
      "quality": "hd1080",
      "transcript": "...",
      "tags": ["tag1", "tag2"],
      "is_age_restricted": false
    }
  ]
  ```
</ResponseExample>
