# Reddit 社区帖子接口

Reddit 社区帖子 API（数据接口）按社区名取一页该 Reddit 社区的帖子，可按热门、最新或最高分排。每次调用 2 积分（约 $0.004–$0.0067），失败不扣。用 HTTP 调用，或让 AI 客户端通过 MCP 调用。最近实测：2026-10-17。

- 页面：https://socialtoai.com/zh/reddit-subreddit-posts-api/
- 最近更新：2026-10-17
- 最近实测：2026-10-17

| 请求 | 价格键 | 积分 |
| --- | --- | --- |
| `POST /v1/call/reddit.subreddit_posts` | `reddit.subreddit_posts` | 2 |

## 请求

```bash
curl https://api.socialtoai.com/v1/call/reddit.subreddit_posts \
  -H "Authorization: Bearer $SOCIALTOAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "nasa"
  }'
```

```python
import os
import requests

response = requests.post(
    "https://api.socialtoai.com/v1/call/reddit.subreddit_posts",
    headers={"Authorization": f"Bearer {os.environ['SOCIALTOAI_KEY']}"},
    json={
        "id": "nasa",
    },
)
print(response.json())
```

## 参数

| 名称 | 类型 | 是否必填 | 默认值 | 说明 |
| --- | --- | --- | --- | --- |
| `id` | string | 必填 | — | 社区名，不带 r/ |
| `sort` | string | 选填 | hot | 按热门、最新或最高分排 `"hot"` `"latest"` `"popular"` |
| `cursor` | string | 选填 | — | 填上一次返回的 page.cursor，取下一页。 |

## 参数从哪里来

- `id`：社区名，不带 r/（例如 `nasa`）
  这些接口返回的每一条都带 `ref`：[user_subreddits](https://socialtoai.com/zh/reddit-user-subreddits-api.md)

## 返回字段

| 字段 | 类型 | 含义 | 能否给出 |
| --- | --- | --- | --- |
| `items[].url` | string | 能直接打开的链接。 | 有 |
| `items[].format` | string | video、image、text 或 article。 | Reddit 给不了，始终是 null |
| `items[].title` | string | 标题。 | 有 |
| `items[].text` | string | 正文或文案。 | 有 |
| `items[].published_at` | string | 发布时间，ISO 8601（UTC）。 | 有 |
| `items[].author.id` | string | 作者的账号编号。 | 有 |
| `items[].author.username` | string | 作者的账号名。 | 有 |
| `items[].author.name` | string | 作者的显示名。 | Reddit 给不了，始终是 null |
| `items[].author.verified` | boolean | 作者是否认证。 | Reddit 给不了，始终是 null |
| `items[].author.followers` | integer | 作者的粉丝数。 | Reddit 给不了，始终是 null |
| `items[].metrics.likes` | integer | 点赞数。 | Reddit 给不了，始终是 null |
| `items[].metrics.comments` | integer | 评论数。 | 有 |
| `items[].metrics.shares` | integer | 分享数。 | Reddit 给不了，始终是 null |
| `items[].metrics.collects` | integer | 收藏数。 | Reddit 给不了，始终是 null |
| `items[].metrics.views` | integer | 播放或阅读数。 | Reddit 给不了，始终是 null |
| `items[].metrics.reposts` | integer | 转发数。 | Reddit 给不了，始终是 null |
| `items[].images` | string[] | 图片地址。 | Reddit 给不了，始终是 null |
| `items[].hashtags` | string[] | 话题标签，不带 #。 | Reddit 给不了，始终是 null |
| `items[].is_pinned` | boolean | 是否被作者置顶。 | Reddit 给不了，始终是 null |

每一条另有 platform、id、ref、approx、type；items 外面的部分每个调用都一样。 [返回格式](https://socialtoai.com/zh/docs/api/response.md)

## 示例返回

示例数据：名称、链接和正文已替换成占位符，数字是录制时的真实值。

```json
{
  "request_id": "req_00000000-0000-4000-8000-000000000001",
  "schema_version": "v1",
  "fetched_at": "2026-10-12T18:46:27.000Z",
  "action": "call",
  "op": "reddit.subreddit_posts",
  "platform": "reddit",
  "status": "ok",
  "items": [
    {
      "platform": "reddit",
      "id": "…",
      "ref": "…",
      "approx": [],
      "type": "content",
      "url": "https://example.com/…",
      "format": null,
      "title": "…",
      "text": null,
      "published_at": "2026-10-11T22:55:35.000Z",
      "author": {
        "id": "…",
        "username": "…",
        "name": null,
        "verified": null,
        "followers": null
      },
      "metrics": {
        "likes": null,
        "comments": 30,
        "shares": null,
        "collects": null,
        "views": null,
        "reposts": null
      },
      "images": null,
      "hashtags": null,
      "is_pinned": null
    }
  ],
  "unavailable": ["format", "author.name", "author.verified", "author.followers", "metrics.likes", "metrics.shares", "metrics.collects", "metrics.views", "metrics.reposts", "images", "hashtags", "is_pinned"],
  "page": {
    "has_more": true,
    "cursor": "cur_…",
    "cursor_expires_at": "2026-10-12T19:16:27.000Z"
  },
  "warnings": [],
  "applied_params": {
    "id": "nasa"
  },
  "cost_credits": 2,
  "billing": {
    "cost_credits": 2,
    "balance_credits": 98,
    "today_spend_credits": 2,
    "daily_limit_credits": null,
    "daily_remaining_credits": null,
    "display": "本次 2 积分，余额 98 积分"
  },
  "replayed": false
}
```

## 翻页与失败

- 一次调用返回一页，最多 25 条；page.has_more 为 true 时把 page.cursor 填进 cursor 取下一页，每页 2 积分，cursor 30 分钟内有效。
- 正常执行但没有结果，算一次成功的调用：status 为 "empty"，items 为空，扣 2 积分。
- Reddit 的这个接口分不清“帖子不存在”和“没有数据”：两种情况都返回 empty，并照常扣费。
- 每把 Key 每秒 1 次，购买后 5 次；超出不扣费。 [频率限制](https://socialtoai.com/zh/docs/credits-and-billing.md#rate-limits)
- 失败的调用 0 积分，不会自动重试。 [错误码](https://socialtoai.com/zh/docs/api/errors.md)

## 在 AI 里这样问

- 按社区名取一页该 Reddit 社区的帖子，可按热门、最新或最高分排：nasa → `call {"op":"reddit.subreddit_posts","id":"nasa"}`，2 积分
- 按社区名取一页该 Reddit 社区的帖子，可按热门、最新或最高分排：nasa，sort 取 latest。 → `call {"op":"reddit.subreddit_posts","id":"nasa","sort":"latest"}`，2 积分
- 按用户名取这个 Reddit 用户活跃的社区：nasa，再对前 3 个结果：按社区名取一页该 Reddit 社区的帖子，可按热门、最新或最高分排。 → `call {"op":"reddit.user_subreddits","username":"nasa"}`, `call {"op":"reddit.subreddit_posts","id":"<ref>"}` × 3，8 积分

## Reddit 的其他接口

| 接口 | 做什么 | 价格键 | 积分 | 页面 |
| --- | --- | --- | --- | --- |
| `user_subreddits` | 按用户名取这个 Reddit 用户活跃的社区。 | `reddit.user_subreddits` | 2 | https://socialtoai.com/zh/reddit-user-subreddits-api.md |
| `subreddit` | 按社区名取 Reddit 社区的资料。 | `reddit.subreddit` | 2 | https://socialtoai.com/zh/reddit-subreddit-api.md |
| `search` | 按关键词找帖子：正文、作者、评论数和发布时间。 | `reddit.search` | 2 | https://socialtoai.com/zh/reddit-search-api.md |
| `trending` | 现在热门的帖子。 | `reddit.trending` | 2 | https://socialtoai.com/zh/reddit-trending-api.md |
| `detail` | 用编号或链接取一条帖子：正文、作者、评论数和发布时间。 | `reddit.detail` | 2 | https://socialtoai.com/zh/reddit-detail-api.md |
| `comments` | 一条帖子下的评论：正文、回复数和时间。 | `reddit.comments` | 2 | https://socialtoai.com/zh/reddit-comments-api.md |
| `user_profile` | 一个账号：名称、简介和作品数。 | `reddit.user_profile` | 2 | https://socialtoai.com/zh/reddit-user-profile-api.md |
| `user_posts` | 一个账号最近发布的帖子。 | `reddit.user_posts` | 2 | https://socialtoai.com/zh/reddit-user-posts-api.md |

## 常见问题

**需要 Reddit 账号，或者申请 Reddit 官方的 API 吗？**

不需要，只要一把 SocialToAI 的 Key。返回的是 Reddit 上公开可见的内容和账号信息，你不用登录 Reddit，也不用在那边申请任何东西。
