API 文档

Reddit 搜索 API

Reddit 搜索 API 参数、分页、真实响应与计费说明。

测试 API

查询公开数据,使用明确的参数与真实响应示例。

打开产品页并测试
POST https://api.goanyapi.com/api/v1/reddit/search

请求与鉴权

同步 POST JSON 接口,不生成任务、无需轮询。使用 Authorization: Bearer YOUR_API_KEY。没有 Path 或 Query 参数。

输入参数

参数 位置 类型 必填 默认值 范围与说明
Authorization Header string 是 — Bearer YOUR_API_KEY
Content-Type Header string 是 application/json application/json
query JSON body string 是 — 搜索关键词。 maxLength: 2048
sort JSON body string 否 relevance 结果排序;完整取值见下方枚举,区分大小写。 enum: "relevance", "hot", "top", "new", "comments" maxLength: 2048
type JSON body string 否 posts 搜索结果类型。posts 返回 data.result.posts;comments 返回 data.result.comments;communities 返回 data.result.communities;media 返回 data.result.posts。响应只包含实际返回的列表。 enum: "posts", "comments", "communities", "media"
time JSON body string 否 all 时间范围;完整取值见下方枚举,区分大小写。 enum: "hour", "day", "week", "month", "year", "all"
subreddit JSON body string 否 — 可选的单版块筛选。支持版块名、r/版块名或完整的 HTTPS Reddit 版块或帖子链接,翻页时保持该值不变。 maxLength: 2048
cursor JSON body string 否 — 首次不传;下一页将 data.result.next_cursor 原样传入,不自行构造游标。 maxLength: 16384
feedLength JSON body integer 否 0 此前累计返回的记录条数,首次为 0,翻页加上上一页实际列表长度;不是每页条数。 minimum: 0 maximum: 1000000

每次返回一页,实际条数可能因筛选结果而变化。

sort

值 默认
"relevance" 是
"hot" —
"top" —
"new" —
"comments" —

type

值 默认
"posts" 是
"comments" —
"communities" —
"media" —

time

值 默认
"hour" —
"day" —
"week" —
"month" —
"year" —
"all" 是

请求示例

POST /api/v1/reddit/search
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "query": "united airlines",
  "sort": "relevance",
  "feedLength": 0
}

type = "posts"

POST /api/v1/reddit/search
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "query": "united airlines",
  "sort": "relevance",
  "feedLength": 0,
  "type": "posts",
  "time": "week",
  "subreddit": "r/unitedairlines"
}

type = "comments"

POST /api/v1/reddit/search
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "query": "united airlines",
  "sort": "relevance",
  "feedLength": 0,
  "type": "comments",
  "time": "week",
  "subreddit": "r/unitedairlines"
}

type = "communities"

POST /api/v1/reddit/search
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "query": "united airlines",
  "sort": "relevance",
  "feedLength": 0,
  "type": "communities",
  "time": "week"
}

type = "media"

POST /api/v1/reddit/search
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "query": "united airlines",
  "sort": "relevance",
  "feedLength": 0,
  "type": "media",
  "time": "week",
  "subreddit": "r/unitedairlines"
}

结果类型

请求的 type 决定结果列表。省略时查找帖子。未返回的列表字段会省略。

type 响应列表
posts data.result.posts
comments data.result.comments
communities data.result.communities
media data.result.posts

输出字段

成功返回 HTTP 200,业务数据位于 data.result。null、空字符串、空数组、缺失字段原样保留,不补造数据。false 和 0 是合法业务值,不等于空结果。

字段 类型 说明
code string 成功为 ok,失败为公开错误码
message string 请求状态说明
data.result object / null 实际公开结果,可为空
data.creditsUsed integer 本次实际扣费,空结果为 0;非空价格来自数据库
data.remainingCredits number 结算后的账户积分余额
data.result.count integer 当前页记录数,不是全部记录总数
data.result.has_more boolean 是否仍有后续结果;没有有效游标时不可自行构造分页
data.result.next_cursor string / null 下一页不透明游标;仅在非空、不同且允许继续时原样传回
data.result.posts array 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].author string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].authorId string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].awardCount number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].commentCount number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].contentUrl string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].createdAt string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].domain string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].id string 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].images array 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].language string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].score number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].state string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].subreddit string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].subredditId string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].text string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].title string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].type string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].upvoteRatio number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].url string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video object / null 可用的视频信息;媒体地址可能过期
data.result.posts[].video.url string 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.mimeType string 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.hlsUrl string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.dashUrl string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.duration number / null 视频时长(秒)
data.result.posts[].video.width number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.height number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.poster string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.captionUrl string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants array 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants[].url string 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants[].mimeType string 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants[].width number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants[].height number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants[].bitrate number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.posts[].video.variants[].codec string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments array 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].id string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].parentId string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].postId string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].postTitle string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].author string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].score number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].commentCount number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].depth number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].createdAt string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].url string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].text string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].subreddit string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].subredditId string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].nsfw boolean / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.comments[].spoiler boolean / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities array 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].id string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].name string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].displayName string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].url string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].description string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].avatar string / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].weeklyVisitors number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].weeklyContributions number / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].nsfw boolean / null 实际公开业务字段;保留 null、空值与字段缺失
data.result.communities[].quarantined boolean / null 实际公开业务字段;保留 null、空值与字段缺失

分页与结果边界

首次不传 cursor。下一页保持相同筛选条件,将 data.result.next_cursor 原样传入 cursor。每页独立请求,只有非空成功结果计费。has_more 为 false、游标为空或与本页相同时停止;不猜造游标。

feedLength 是此前累计返回的记录条数,首次为 0;翻页时加上上一页实际列表长度。count 仅表示当前页条数,不代表全量总数。

真实响应示例

采集时间: 2026-11-18T09:31:47Z

此示例使用默认的帖子搜索模式(type = posts)。

保存自真实成功请求,完整保留公开结果列表。结构省略 data.creditsUsed 与 data.remainingCredits,实际响应包含按当前配置计算的费用与余额。保存示例不会请求或扣费;媒体地址可能过期。

{
  "code": "ok",
  "message": "ok",
  "data": {
    "result": {
      "posts": [
        {
          "id": "t3_1xy37z4",
          "title": "United Airlines says it is working to fix ‘widespread’ system outage",
          "author": "NW3",
          "authorId": "t2_f9u54",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/unitedairlines/comments/1xy37z4/united_airlines_says_it_is_working_to_fix/",
          "subreddit": "r/unitedairlines",
          "subredditId": "t5_2vmjq",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://styles.redditmedia.com/t5_2vmjq/styles/communityIcon_qcnp5rk9z28a1.png?width=64&frame=1&auto=webp&s=db812ffbdd668566f6dfd4f85a92ad2c14d3b609"
          ],
          "video": null
        },
        {
          "id": "t3_1xy3x8s",
          "title": "United Airlines just reported ANOTHER systemwide outage. First NVIDIA, then Microsoft, then the FAA ground stop, then banking apps and now United. What's your leading theory on all of this?",
          "author": "snowscovered",
          "authorId": "t2_z590g4jkw",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/AskReddit/comments/1xy3x8s/united_airlines_just_reported_another_systemwide/",
          "subreddit": "r/AskReddit",
          "subredditId": "t5_2qh1i",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://styles.redditmedia.com/t5_2qh1i/styles/communityIcon_p6kb2m6b185b1.png?width=64&frame=1&auto=webp&s=8e8d7fabcc18322bde1c5a388488f19477ed60ed"
          ],
          "video": null
        },
        {
          "id": "t3_1xy3659",
          "title": "United Airlines says it has a widespread system outage just days after nationwide ground stop",
          "author": "UBC145",
          "authorId": "t2_6p70ej85",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/news/comments/1xy3659/united_airlines_says_it_has_a_widespread_system/",
          "subreddit": "r/news",
          "subredditId": "t5_2qh3l",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://styles.redditmedia.com/t5_2qh3l/styles/communityIcon_fmygcobc22z81.png?width=64&frame=1&auto=webp&s=15e4415eb5a845375cc91d8125012005374f153c"
          ],
          "video": null
        },
        {
          "id": "t3_1xw9opa",
          "title": "UNACCEPTABLE Treatment of a LOYAL flyer. NEVER AGAIN",
          "author": "Alternative_Salad_83",
          "authorId": "t2_737mv2h1",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/unitedairlines/comments/1xw9opa/unacceptable_treatment_of_a_loyal_flyer_never/",
          "subreddit": "r/unitedairlines",
          "subredditId": "t5_2vmjq",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://styles.redditmedia.com/t5_2vmjq/styles/communityIcon_qcnp5rk9z28a1.png?width=64&frame=1&auto=webp&s=db812ffbdd668566f6dfd4f85a92ad2c14d3b609"
          ],
          "video": null
        },
        {
          "id": "t3_1xy34m2",
          "title": "United Airlines says it has a widespread system outage just days after nationwide ground stop",
          "author": "thatfreshjive",
          "authorId": "t2_exr56",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/technology/comments/1xy34m2/united_airlines_says_it_has_a_widespread_system/",
          "subreddit": "r/technology",
          "subredditId": "t5_2qh16",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://b.thumbs.redditmedia.com/J_fCwTYJkoM-way-eaOHv8AOHoF_jNXNqOvPrQ7bINY.png"
          ],
          "video": null
        },
        {
          "id": "t3_1xxvjrc",
          "title": "For $400 an hour, yes, I'll kick myself off the flight.",
          "author": "The_Chieftain_WG",
          "authorId": "t2_8za88",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/unitedairlines/comments/1xxvjrc/for_400_an_hour_yes_ill_kick_myself_off_the_flight/",
          "subreddit": "r/unitedairlines",
          "subredditId": "t5_2vmjq",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://styles.redditmedia.com/t5_2vmjq/styles/communityIcon_qcnp5rk9z28a1.png?width=64&frame=1&auto=webp&s=db812ffbdd668566f6dfd4f85a92ad2c14d3b609"
          ],
          "video": null
        },
        {
          "id": "t3_1xy376b",
          "title": "United Airlines experiencing a widespread system outage, airline says",
          "author": "Stock412",
          "authorId": "t2_6ucns",
          "score": null,
          "upvoteRatio": null,
          "commentCount": null,
          "createdAt": null,
          "type": null,
          "domain": null,
          "contentUrl": null,
          "url": "https://www.reddit.com/r/sysadmin/comments/1xy376b/united_airlines_experiencing_a_widespread_system/",
          "subreddit": "r/sysadmin",
          "subredditId": "t5_2qnp7",
          "awardCount": null,
          "language": null,
          "state": null,
          "text": null,
          "images": [
            "https://styles.redditmedia.com/t5_2qnp7/styles/communityIcon_gcx9bz62dbg01.png?width=64&frame=1&auto=webp&s=a28cc248064bce907c57266cb1a2ada1375d5e1c"
          ],
          "video": null
        }
      ],
      "count": 7,
      "next_cursor": "eyJjYW5kaWRhdGVzX3JldHVybmVkIjoie1wic2VjdGlvbl8xX3BpcGVsaW5lXzBfZ2xvYmFsX21vZGlmaWVyc1wiOlwiMVwiLFwic2VjdGlvbl8xX3BpcGVsaW5lXzFfbG9jYWxfbW9kaWZpZXJzXCI6XCIyXCIsXCJzZWN0aW9uXzJfcGlwZWxpbmVfMTBfcXVlcnlfc3VnZ2VzdGlvbnNcIjpcIjZcIixcInNlY3Rpb25fMl9waXBlbGluZV84X2R5bmFtaWNfNF9hbnN3ZXJzX3ByZXZpZXdcIjpcIjBcIixcInNlY3Rpb25fMl9waXBlbGluZV84X2R5bmFtaWNfNV9wb3N0X3NlYXJjaFwiOlwiN1wiLFwic2VjdGlvbl8zX3BpcGVsaW5lXzBfZHluYW1pY18wX3N1YnJlZGRpdF9zZWFyY2hcIjpcIjVcIixcInNlY3Rpb25fM19waXBlbGluZV8wX2R5bmFtaWNfMV9hdXRob3Jfc2VhcmNoXCI6XCIxXCJ9IiwiZHluYW1pY19hbGxfcmFua2VyIjoibGVnYWN5X2Fuc3dlcnMiLCJleHBlcmllbmNlX3NlbGVjdGlvbiI6ImR5bmFtaWNfYWxsIiwiZXhwZXJpZW5jZV92ZXJzaW9uIjoiZGVza3RvcCIsInNlY3Rpb25fMl9waXBlbGluZV84X2R5bmFtaWNfNV9wb3N0X3NlYXJjaCI6IjcifQ==",
      "has_more": true
    }
  }
}

计费

…

仅非空成功结果按数据库当前配置扣费;空结果和失败不扣费,内部标识处理不单独收费。每页独立结算;false、0 等合法结果不按空结果处理。

状态码

HTTP 含义
200 成功,包含免费空结果
400 JSON、参数或资源 URL 无效
401 未鉴权或凭证无效
402 积分不足
429 请求过于频繁,遵循 Retry-After
502 数据请求失败
503 接口或价格未配置