Reddit 版块帖子
Reddit 版块里的帖子,可按热门、最新、最高分、最佳或上升中排序,含得分、评论、分享数和图片,已去掉广告帖。
API 数据样例
直接查看该接口实际使用的请求体和完整响应结构。
{
"community": "airfryer",
"sortBy": "top"
}{
"request_id": "78e14c2d-ca10-48dd-9f16-f90506a6e1e4",
"data": {
"items": [
{
"post_id": "t3_ma5jsi",
"title": "Am I right or am I right?",
"url": "https://www.reddit.com/r/airfryer/comments/ma5jsi/",
"author": "example_user_1",
"created_at": "2021-03-21T20:37:22.661Z",
"score": 4183,
"comment_count": 111,
"share_count": 29,
"image_url": "https://preview.redd.it/za4qbg5szfo61.jpg?width=1080&auto=webp&s=6f6855122f17144a4f145e709d275c79a9cee3f6"
},
{
"post_id": "t3_1hke8w1",
"title": "I have mastered the art of fries in the air fryer",
"url": "https://www.reddit.com/r/airfryer/comments/1hke8w1/",
"author": "example_user_2",
"created_at": "2024-12-23T02:42:29.837Z",
"score": 2596,
"comment_count": 147,
"share_count": 1469,
"image_url": "https://preview.redd.it/yvp48li3hi8e1.jpeg?width=1080&auto=webp&s=48e9657a376dc06085a07551a5b1e7975770eda2"
}
],
"next_cursor": "dDNfMWF5YzY1MQ==…"
}
}可用状态:已开放
该接口已进入 v1 网关、OpenAPI 和订阅权限目录,每次调用消耗 1 个计费单位,查不到数据(
RESULT_NOT_FOUND)也照常计费。
POST /v1/social/reddit/communities/posts
下方请求和响应字段已与当前公开契约核对。
MCP 调用
| 项目 | 内容 |
|---|---|
| MCP Code | social_reddit_communities_posts |
快速调用
先创建 API 密钥,再将密钥写入服务端环境变量:
export ECOMMERCE_DATA_API_KEY="your_api_key"curl --request POST \
--url https://ecommercedataapi.com/v1/social/reddit/communities/posts \
--header "Content-Type: application/json" \
--header "X-API-Key: ${ECOMMERCE_DATA_API_KEY}" \
--data '{
"community": "airfryer",
"sortBy": "top"
}'使用 AI CLI 接入
复制给 AI CLI
粘贴到 Codex、Claude Code、Gemini CLI 或其他编程智能体中直接完成接入。
请直接在当前代码库中接入 Ecommerce Data API 的「Reddit 版块帖子」接口,不要只给示例代码。
接口文档:https://ecommercedataapi.com/zh/docs/social/reddit/community-posts
请求接口:POST https://ecommercedataapi.com/v1/social/reddit/communities/posts
API 密钥环境变量:ECOMMERCE_DATA_API_KEY
请求示例:
{
"community": "airfryer",
"sortBy": "top"
}
请按以下要求执行:
1. 先阅读接口文档,并检查当前项目使用的语言、框架、HTTP 客户端、目录结构和环境变量约定。
2. 优先复用项目现有的 API 客户端和错误处理方式;如果没有,再创建最小可复用的 Ecommerce Data API 客户端与该接口调用封装。
3. 从服务端环境变量 ECOMMERCE_DATA_API_KEY 读取密钥,发送 Content-Type: application/json 和 X-API-Key 请求头。绝不能把真实密钥写入源码、前端代码、日志、测试快照或 Git。
4. 如果环境变量不存在,提示我自行设置 ECOMMERCE_DATA_API_KEY;不要索取、输出或猜测真实密钥,并继续完成不依赖真实请求的代码与测试。
5. 根据接口文档实现请求与响应类型,处理非 2xx 响应、request_id、error.code、error.message 和 429 限流。
6. 添加一个符合当前项目习惯的最小调用示例或测试。如果密钥已配置且当前环境允许外部请求,再执行一次最小真实调用;否则使用 mock 或静态验证。
7. 运行相关格式化、类型检查和测试,最后汇报修改文件、调用方法、验证结果以及仍需我配置的环境变量。还没有 API 密钥?创建 API 密钥
在 Postman 中打开当前请求
下载当前接口的预配置 Collection,再通过 Postman Import 导入。
导入后在 Collection Variables 中填写 apiKey。创建 API 密钥
Node.js 示例
const response = await fetch(
'https://ecommercedataapi.com/v1/social/reddit/communities/posts',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.ECOMMERCE_DATA_API_KEY,
},
body: JSON.stringify({
community: 'airfryer',
sortBy: 'top',
}),
}
);
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.error?.code}: ${result.error?.message}`);
}
console.log(result.data);Python 示例
import os
import requests
response = requests.post(
"https://ecommercedataapi.com/v1/social/reddit/communities/posts",
headers={
"Content-Type": "application/json",
"X-API-Key": os.environ["ECOMMERCE_DATA_API_KEY"],
},
json={
"community": "airfryer",
"sortBy": "top",
},
timeout=30,
)
response.raise_for_status()
print(response.json()["data"])请求参数
请求体直接发送下表字段,不要再包裹额外对象;未定义字段会被拒绝。
| 字段 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
community | 字符串 | 是 | 版块名称,可带或不带 r/。 | airfryer |
sortBy | 字符串 | 否 | hot(默认,热门)、new(最新)、top(最高分)、best(最佳)或 rising(上升中)。 | top |
cursor | 字符串 | 否 | 上一页响应里的 next_cursor,原样传入;第一页不传。 | dDNfMWF5YzY1MQ== |
返回结构
| 字段 | 类型 | 说明 |
|---|---|---|
request_id | 字符串 | 本次请求的唯一标识。 |
data | 对象 | 接口业务数据。 |
下表字段位于 data 内。数组接口描述的是单个数组元素,分页接口描述的是 items[] 中的单条记录。
返回字段
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
items.post_id | 字符串 | 帖子 ID(t3_ 前缀),正文和回复用 Reddit 帖子详情、帖子回复获取 | - |
items.title | 字符串 | 帖子标题 | - |
items.url | 字符串 | 帖子链接 | - |
items.author | 字符串 | 作者用户名 | - |
items.created_at | 字符串 | 发帖时间(ISO 8601,UTC) | - |
items.score | 整数 | 得分 | 4183 |
items.comment_count | 整数 | 评论数 | 111 |
items.share_count | 整数 | 分享数 | 29 |
items.image_url | 字符串 | 首图;纯文字帖为 null | - |
next_cursor | 字符串 | 下一页游标;最后一页为 null。 | - |
返回示例
{
"request_id": "78e14c2d-ca10-48dd-9f16-f90506a6e1e4",
"data": {
"items": [
{
"post_id": "t3_ma5jsi",
"title": "Am I right or am I right?",
"url": "https://www.reddit.com/r/airfryer/comments/ma5jsi/",
"author": "example_user_1",
"created_at": "2021-03-21T20:37:22.661Z",
"score": 4183,
"comment_count": 111,
"share_count": 29,
"image_url": "https://preview.redd.it/za4qbg5szfo61.jpg?width=1080&auto=webp&s=6f6855122f17144a4f145e709d275c79a9cee3f6"
},
{
"post_id": "t3_1hke8w1",
"title": "I have mastered the art of fries in the air fryer",
"url": "https://www.reddit.com/r/airfryer/comments/1hke8w1/",
"author": "example_user_2",
"created_at": "2024-12-23T02:42:29.837Z",
"score": 2596,
"comment_count": 147,
"share_count": 1469,
"image_url": "https://preview.redd.it/yvp48li3hi8e1.jpeg?width=1080&auto=webp&s=48e9657a376dc06085a07551a5b1e7975770eda2"
}
],
"next_cursor": "dDNfMWF5YzY1MQ==…"
}
}错误响应、请求追踪和限流头说明见错误与限流。