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

# Reddit API 爬取器

## 概览

Reddit API 套件提供多种类型的 API，每种 API 旨在满足不同的 Reddit 数据采集需求。以下是这些 API 之间的交互方式概览，基于可用的功能：

<CardGroup cols={1}>
  <Card title="帖子 API" icon="images" href="/cn/api-reference/web-scraper-api/social-media-apis/reddit#posts-api">
    该 API 允许用户根据单个输入 URL 采集多个帖子。

    <br />

    *   **发现功能**：

    *   通过 Subreddit URL 发现。

    *   通过关键词发现。

    <br />

    *   **重要字段**：

    *   `url`、`title`、`num_comments`、`description`
  </Card>

  <Card title="评论 API" icon="comments" href="/cn/api-reference/web-scraper-api/social-media-apis/reddit#comments-api">
    该 API 允许用户通过帖子 URL 采集多个评论。

    <br />

    *   **发现功能**：

    *   不适用

    <br />

    *   **重要字段**：

    *   `url`、`comment`、`community_name`、`num_replies`
  </Card>
</CardGroup>

## 帖子 API

### 通过 URL 采集

该 API 允许用户使用提供的 URL 检索特定 Reddit 帖子的详细数据。

**输入参数**

<ParamField path="URL" type="string" required="true">
  需要检索的 Reddit 帖子 URL。
</ParamField>

**输出结构**:\
包含全面的数据点：

* **帖子详情**:\
  `post_id`、`url`、`title`、`description`、`num_comments`、`date_posted`、`tag`、`related_posts`、`comments`、`photos`、`videos`。

  > 查看所有数据点，请[点击这里](https://brightdata.com/cp/data_api/gd_lvz8ah06191smkebj4?id=all\&tab=overview)。

* **用户详情**:\
  `user_posted`。

* **社区详情**:\
  `community_name`、`community_url`、`community_description`、`community_members_num`、`community_rank`。

* **互动指标**:\
  `num_upvotes`。

该 API 可高效获取 Reddit 帖子信息，包括用户互动数据、社区详情及多媒体内容，支持高级分析和内容跟踪。

### 通过关键词发现

该 API 允许用户通过特定关键词发现 Reddit 帖子，并可选择按日期筛选和设置要检索的帖子数量。

**输入参数**

<ParamField path="keyword" type="string" required="true">
  用于搜索相关帖子的关键词。
</ParamField>

<ParamField path="date" type="string" required="true">
  过滤帖子发布时间，以确保结果符合指定时间范围。
</ParamField>

<ParamField path="num_of_posts" type="number">
  需要采集的帖子数量。如果未提供，则默认检索所有符合条件的帖子。
</ParamField>

**输出结构**:\
包含全面的数据点：

* **帖子详情**:\
  `post_id`、`url`、`user_posted`、`title`、`description`、`num_comments`、`date_posted`、`tag`、`related_posts`、`comments`。

  > 查看所有数据点，请[点击这里](https://brightdata.com/cp/data_api/gd_lvz8ah06191smkebj4/keyword?id=all\&tab=overview)。

* **社区详情**:\
  `community_name`、`community_url`、`community_description`、`community_members_num`、`community_rank`。

* **媒体详情**:\
  `photos`、`videos`。

该 API 使用户能够高效发现并分析与特定关键词相关的 Reddit 帖子，提供关于社区讨论、帖子热度及相关媒体内容的宝贵洞察。

### 通过 Subreddit URL 发现

该 API 允许用户使用 Subreddit URL 检索特定 Subreddit 中的帖子，并可选择基于特定标准对结果进行排序。

**输入参数**

<ParamField path="URL" type="string" required="true">
  需要采集帖子的 Subreddit URL。
</ParamField>

<ParamField path="sort_by" type="string">
  确定帖子排序方式（例如 `new`、`top`、`hot`）。
</ParamField>

**输出结构**:\
包含全面的数据点：

* **帖子详情**:\
  `post_id`、`url`、`user_posted`、`title`、`description`、`num_comments`、`date_posted`、`tag`、`related_posts`、`comments`。

  > 查看所有数据点，请[点击这里](https://brightdata.com/cp/data_api/gd_lvz8ah06191smkebj4/subreddit_url?id=all)。

* **社区详情**:\
  `community_name`、`community_url`、`community_description`、`community_members_num`、`community_rank`。

* **媒体详情**:\
  `photos`、`videos`。

该 API 提供了一种简化方式来探索和分析 Subreddit 内的帖子，帮助深入了解帖子内容、社区动态及相关媒体文件，非常适合监控 Subreddit 活动或提取帖子级别的数据进行进一步分析。

## 评论 API

### 通过 URL 收集

该 API 允许用户从特定的 Reddit 帖子或评论 URL 采集详细的评论数据，并可选择根据发布时间筛选评论。

**输入参数**

<ParamField path="URL" type="string" required="true">
  要获取评论的 Reddit 帖子或评论的 URL。
</ParamField>

<ParamField path="days_back" type="number">
  仅采集指定天数内发布的所有评论。
</ParamField>

**输出结构**\
包含全面的数据点：

* **评论详情**：\
  `comment_id`, `user_posted`, `comment`, `date_posted`, `replies`, `num_upvotes`, `num_replies`。

  > 所有数据点，请[点击这里](https://brightdata.com/cp/data_api/gd_lvzdpsdlw09j6t702?tab=overview)。

* **帖子详情**：\
  `post_url`, `post_id`, `post_language`, `post_state`, `post_type`, `images`。

* **社区详情**：\
  `community_name`, `community_url`, `community_description`, `community_members_num`, `community_rank`。

* **帖子属性**：\
  `is_moderator`, `is_pinned`, `has_bot_in_username`, `is_locked`, `is_admin_post`, `is_archived_post`, `is_moderator_post`, `is_quarantined_post`, `is_not_safe_for_work_post`, `is_eligible_for_content_blocking_post`, `is_promoted_post`。

该 API 提供对 Reddit 评论及其关联帖子的全面洞察，帮助用户有效分析互动情况、用户活动和内容趋势。
