> ## 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.

# 按关键词发现 TikTok 帖子

## 查询参数

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

  <Warning>
    必须设置为 `gd_lu702nij2f790tmv9h` 以收集**按关键词发现**数据。
  </Warning>
</ParamField>

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

<ParamField query="discover_by" type="string" default="keyword">
  必须设置为 `keyword`。
</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="search_keyword" type="string" required>
      用于搜索 TikTok 帖子的关键词。
    </ParamField>

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

    <ParamField body="what_to_collect" type="string">
      指定从每个帖子收集的数据。
    </ParamField>
  </Expandable>

  #### 示例

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

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

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

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

  print(response.text)
  ```

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

  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: [
        {
          search_keyword: "cooking recipes",
          num_of_posts: 20,
        },
      ],
      limit_per_input: null,
    }),
  });

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

<ResponseExample>
  ```json 200 theme={null}
  [
    {
      "post_id": "7500000000000000000",
      "description": "Easy pasta recipe you need to try #cooking #recipes #foodtok",
      "create_time": "2025-02-10T09:15:00.000Z",
      "share_count": 3200,
      "collect_count": 8900,
      "comment_count": 1500,
      "play_count": 5200000,
      "video_duration": 60,
      "hashtags": [
        "#cooking",
        "#recipes",
        "#foodtok"
      ],
      "video_url": "https://v16-webapp-prime.tiktok.com/video/example.mp4",
      "profile_username": "homechef",
      "profile_url": "https://www.tiktok.com/@homechef",
      "is_verified": false
    }
  ]
  ```
</ResponseExample>
