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

# Reddit 搜索、帖子与评论 API（REDDIT）

> 搜索 Reddit 帖子，读取单个帖子及其第一页评论，或列出子版块或用户的最新帖子。

`REDDIT` 读取公开的 Reddit 内容。它有四种模式，由 payload 决定：搜索（`query`）、单个帖子及其评论（`url`）、子版块信息流（`action: "feed"`）和用户发布的帖子（`action: "user_posts"`）。

| | |
| - | - |
| `taskType` | `REDDIT` |
| 输入 | `query`，或 `url`，或 `action`（`feed`、`user_posts`）；`subreddit`、`username`、`commentSort`、`commentMaxDepth`、`limit`、`country` |
| 积分 | 每个任务 1 积分 |
| 国家 | 默认 `US`。 |
| 位置 | 不支持（`422 LOCATION_UNSUPPORTED`）。 |

## 搜索帖子

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "REDDIT", "payload": { "query": "running shoes for flat feet", "subreddit": "RunningShoeGeeks" } }'
```

| 字段 | 必填 | 说明 |
| - | - | - |
| `query` | 是 | 搜索查询。缺少 `query` 时接受 `prompt`。 |
| `subreddit` | 否 | 只搜索一个子版块：不含 `r/` 的名称，2-21 个字母、数字或下划线。 |

搜索最多返回 25 个帖子。例如：

```json theme={"theme":"css-variables"}
{
  "results": [
    { "postId": "1uzk9m4", "title": "...", "url": "https://www.reddit.com/r/RunningShoeGeeks/comments/1uzk9m4/...", "subreddit": "RunningShoeGeeks", "preview": "..." }
  ]
}
```

帖子有正文时，`preview` 是正文的开头部分，最多 2,000 个字符。已完成任务中的 `results` 为空，表示 Reddit 没有找到任何内容。

## 读取帖子及其评论

用帖子 `url` 代替 `query`：

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "REDDIT", "payload": { "url": "https://www.reddit.com/r/RunningShoeGeeks/comments/1uer62n/", "commentSort": "top", "commentMaxDepth": 1 } }'
```

| 字段 | 必填 | 说明 |
| - | - | - |
| `url` | 是 | reddit.com 帖子地址：`https://www.reddit.com/r/{subreddit}/comments/{postId}/...`。其他地址返回 `422 VALIDATION_ERROR`。 |
| `commentSort` | 否 | `top`、`new`、`controversial`、`old` 或 `qa`。不传时使用 Reddit 自身的默认排序。 |
| `commentMaxDepth` | 否 | 去掉比此值更深的回复，0 到 100 的整数。`0` 表示只保留顶层评论。 |

任务读取帖子及其第一页评论，约 20-25 条。例如：

```json theme={"theme":"css-variables"}
{
  "post": {
    "postId": "1uer62n", "title": "...", "body": "...", "author": "...", "subreddit": "RunningShoeGeeks",
    "score": 12, "upvoteRatio": 0.9, "commentCount": 48, "createdAt": "2026-06-24T21:51:21.586000+0000",
    "archived": false, "url": "https://www.reddit.com/r/RunningShoeGeeks/comments/1uer62n/..."
  },
  "comments": {
    "availableCount": 24,
    "returnedCount": 24,
    "items": [
      { "commentId": "otlz8m5", "author": "...", "body": "...", "score": 5, "depth": 0, "isSubmitter": false, "createdAt": "...", "url": "https://www.reddit.com/r/..." }
    ]
  }
}
```

| 字段 | 说明 |
| - | - |
| `post.commentCount` | Reddit 报告的帖子评论数。Reddit 未提供时，为实际读取的那一页上的评论数。`comments` 只包含那一页。 |
| `post.archived` | 根据帖子发布时长推算；Reddit 约 180 天后锁定评论。 |
| `post.author`、`post.body` | Reddit 未显示时为 `null`（作者已删除、链接帖）。 |
| `comments.items[].depth` | 回复深度；`0` 为顶层评论。回复带有 `parentId`。 |
| `comments.items[].isSubmitter` | 评论由帖子作者发布时为 `true`。 |

> [!NOTE]
>
> 只能获取第一页评论。用于展开更多评论的 `commentLimit` 在自助套餐上返回 `422 VALIDATION_ERROR`。

## 列出最新帖子

| Payload | 返回内容 |
| - | - |
| `{ "action": "feed", "subreddit": "RunningShoeGeeks" }` | 该子版块的最新帖子。不指定 `subreddit` 时为 r/popular。 |
| `{ "action": "user_posts", "username": "example_user" }` | 该用户发布的内容。`username` 为 3-20 个字母、数字、下划线或连字符。 |

两者都以搜索的结构返回 `results`，最多 `limit` 个帖子（默认 25）。

## 限制与错误

* `REDDIT` 忽略 `markdown`、`rawResponse` 和 `searchQueries`。它以 `422` 拒绝 `html` 和 `analysis`，以 `400` 拒绝 `citationAnalysis`；见[不支持的标志](/zh/engines/response-options.md#不支持的标志)。
* 无效的 `subreddit`、`username`、`url` 或 `commentSort` 返回 `422 VALIDATION_ERROR`。
* 其他请求错误见[错误](/zh/concepts/errors.md)。

## 相关内容

* [网页抓取](/zh/engines/web-scrape.md)：读取 Reddit 以外的页面
* [异步任务](/zh/concepts/async-tasks.md)


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