获取Reddit APP动态搜索结果/Fetch Reddit APP Dynamic Search Results
Changed on[中文]
用途:
- 执行Reddit APP动态搜索,支持搜索帖子、社区、评论、媒体和用户
参数:
- query: 搜索关键词或搜索表达式;帖子搜索默认可匹配标题或正文中的部分关键词,详细语法见下方说明
- search_type: 搜索类型,可选值:
- post: 搜索帖子(默认)
- community: 搜索社区/版块
- comment: 搜索评论
- media: 搜索媒体(图片/视频/GIF)
- people: 搜索用户
- sort: 排序方式(仅适用于post/comment/media类型),可选值:
- RELEVANCE: 相关性
- HOT: 热门
- TOP: 最受欢迎
- NEW: 最新
- COMMENTS: 评论数(仅适用于post类型)
- time_range: 时间范围(仅适用于post/media类型),可选值:
- all: 所有时间
- year: 去年
- month: 上个月
- week: 上周
- day: 今天
- hour: 过去1小时
- safe_search: 安全搜索设置,"unset"或"strict"
- allow_nsfw: 是否允许NSFW内容,"0"或"1"
- after: 分页游标;need_format=true时,将pageInfo.endCursor原样传入以获取下一页
- need_format: 默认false;true时将data精简为children和pageInfo,保留结果核心内容及翻页参数
返回:
- need_format=false: 返回原始嵌套搜索结果数据
- need_format=true: data仅包含:
- children: 结果列表,按search_type包含post、comment、community或author等对应内容
- pageInfo: 分页信息,保留endCursor、startCursor、hasNextPage和hasPreviousPage等可用字段
- children为空列表时表示没有结果;hasNextPage为true时,可继续使用endCursor翻页
- 精简结果保留ID、标题、正文、时间、统计、作者、社区和媒体等核心内容;正文优先保留markdown,移除重复正文表示和重复尺寸头像
注意:
- community和people类型不支持sort和time_range参数
- COMMENTS排序方式仅适用于post类型
- time_range参数仅适用于post和media类型
- 帖子搜索中,TOP和NEW分别按受欢迎程度和发布时间排序,不保证结果包含query的全部关键词;需要全部匹配时请使用AND
- time_range限制结果的时间范围,不改变关键词匹配条件
- need_format=true移除冗余字段、辅助展示信息、用户交互状态和空值,保留false和0等有效值,以及分页中的null结束游标
- 翻页时保持query、search_type、sort及其他筛选条件与上一页一致
精简结果示例:
{
"children": [{"post": {"id": "t3_abc123", "postTitle": "Rust borrow checker", "score": 0}}],
"pageInfo": {"endCursor": "<cursor>", "hasNextPage": true, "hasPreviousPage": false}
}
帖子搜索语法:
| 语法 | query示例 | 含义 |
|---|---|---|
| AND | rust AND borrow AND checker | 同时匹配所有指定词 |
| OR | rust OR golang | 匹配任意一个指定词 |
| NOT | rust NOT game | 排除指定词 |
| 括号 | rust AND (ownership OR borrowing) | 明确组合条件 |
| 引号 | "borrow checker" | 搜索短语 |
| title: | title:"borrow checker" | 在标题中搜索 |
| selftext: | selftext:"borrow checker" | 在帖子正文中搜索 |
| subreddit: | subreddit:rust | 限定社区 |
| author: | author:reddit | 限定作者 |
| flair: | flair:discussion | 搜索帖子标签 |
| site: | site:github.com | 限定链接域名 |
| url: | url:github.com | 搜索链接地址 |
| self: | self:true | 限定文字帖;false为非文字帖 |
- AND、OR、NOT必须大写;字段冒号后不要加空格,例如subreddit:rust
- 字段中的多词短语需要引号,例如title:"borrow checker"
- 可组合字段,例如title:"borrow checker" subreddit:rust,再配合sort=TOP或sort=NEW
- 使用HTTP客户端的查询参数编码功能传递query,保留空格、引号和括号
- Reddit官方搜索语法说明
- Reddit官方排序说明
[English]
Purpose:
- Perform Reddit APP dynamic search, supporting posts, communities, comments, media, and users
Parameters:
- query: Search keywords or expression; post searches may match only some terms in titles or post bodies. See the syntax reference below
- search_type: Search type, options:
- post: Search posts (default)
- community: Search communities/subreddits
- comment: Search comments
- media: Search media (images/videos/GIFs)
- people: Search users
- sort: Sort method (only for post/comment/media types), options:
- RELEVANCE: By relevance
- HOT: Hot/trending
- TOP: Most popular
- NEW: Newest
- COMMENTS: By comment count (only for post type)
- time_range: Time range (only for post/media types), options:
- all: All time
- year: Past year
- month: Past month
- week: Past week
- day: Today
- hour: Past hour
- safe_search: Safe search setting, "unset" or "strict"
- allow_nsfw: Allow NSFW content, "0" or "1"
- after: Pagination cursor; when need_format=true, pass pageInfo.endCursor unchanged to fetch the next page
- need_format: Defaults to false; true reduces data to children and pageInfo, retaining core result content and pagination
Returns:
- need_format=false: Original nested search result data
- need_format=true: data contains only:
- children: Results containing the corresponding post, comment, community or author content for search_type
- pageInfo: Available pagination fields, including endCursor, startCursor, hasNextPage and hasPreviousPage
- An empty children list means no results; when hasNextPage is true, continue using endCursor
- Compact results retain IDs, titles, content, timestamps, statistics, authors, communities and media. Markdown is preferred for bodies; duplicate body representations and avatar sizes are removed
Notes:
- community and people types do not support sort and time_range parameters
- COMMENTS sort option only applies to post type
- time_range parameter only applies to post and media types
- For post searches, TOP and NEW sort by popularity and publication time respectively; results may match only some query terms. Use AND when all terms are required
- time_range limits the age of results without changing keyword matching conditions
- need_format=true removes redundant fields, auxiliary presentation details, user interaction state and empty values; valid false and 0 values and null terminal pagination cursors are retained
- Keep query, search_type, sort and other filters unchanged when fetching subsequent pages
Compact result example:
{
"children": [{"post": {"id": "t3_abc123", "postTitle": "Rust borrow checker", "score": 0}}],
"pageInfo": {"endCursor": "<cursor>", "hasNextPage": true, "hasPreviousPage": false}
}
Post search syntax:
| Syntax | query example | Meaning |
|---|---|---|
| AND | rust AND borrow AND checker | Require all specified terms |
| OR | rust OR golang | Match any specified term |
| NOT | rust NOT game | Exclude a specified term |
| Parentheses | rust AND (ownership OR borrowing) | Group conditions |
| Quotes | "borrow checker" | Search for a phrase |
| title: | title:"borrow checker" | Search in titles |
| selftext: | selftext:"borrow checker" | Search in post bodies |
| subreddit: | subreddit:rust | Limit to a community |
| author: | author:reddit | Limit to an author |
| flair: | flair:discussion | Search post flair text |
| site: | site:github.com | Limit linked domains |
| url: | url:github.com | Search link addresses |
| self: | self:true | Limit to text posts; false selects non-text posts |
- AND, OR and NOT must be uppercase. Do not add spaces after field colons, e.g. subreddit:rust
- Quote multi-word field values, e.g. title:"borrow checker"
- Combine fields, e.g. title:"borrow checker" subreddit:rust, with sort=TOP or sort=NEW
- Use your HTTP client's query parameter encoding to preserve spaces, quotes and parentheses in query
- Official Reddit search syntax
- Official Reddit sorting reference
[示例/Example]
query="python programming" search_type="post" sort="RELEVANCE" time_range="all" safe_search="unset" allow_nsfw="0" after="" need_format=false
Request
- Base URLhttps://api.tikhub.io (the document declares no server; this is the origin it was published from)
- AuthHTTP bearer
Query parameters
返回内容使用的语言,采用 IETF 语言标签;默认 en-US / Preferred response language as an IETF language tag; default: en-US
搜索关键词或搜索表达式;帖子搜索默认可匹配部分关键词,支持 AND、OR、NOT、括号分组、引号短语和字段限定 / Search keywords or expression; post searches may match only some keywords. Supports AND, OR, NOT, grouping, quoted phrases and field filters
搜索类型/Search type: post(帖子), community(社区), comment(评论), media(媒体), people(用户)
排序方式(仅适用于post/comment/media)/Sort method (only for post/comment/media): RELEVANCE(相关性), HOT(热门), TOP(最受欢迎), NEW(最新), COMMENTS(评论数,仅post)
时间范围(仅适用于post/media)/Time range (only for post/media): all(所有时间), year(去年), month(上月), week(上周), day(今天), hour(过去1小时)
安全搜索设置/Safe search setting: unset, strict
是否允许NSFW内容/Allow NSFW content: 0, 1
分页游标;need_format=true时使用pageInfo.endCursor / Pagination cursor; use pageInfo.endCursor when need_format=true
true时data仅包含children和pageInfo,并精简每条结果的冗余字段;false时保留原始搜索结构 / When true, data contains only children and pageInfo with redundant result fields removed; false preserves the original search structure
Response
Successful Response
Changes
- info
added the optional property
//to the response with the status - info
added the optional property
//to the response with the status
- info
- breaking
the
queryrequest parameterallow_nsfwwas restricted to a list of enum values - breaking
the
queryrequest parametersafe_searchwas restricted to a list of enum values - breaking
the
queryrequest parametersearch_typewas restricted to a list of enum values - breaking
for the
queryrequest parameterquery, the minLength was increased from0to1 - warning
for the
queryrequest parameterafter, the maxLength was set to4096 - warning
for the
queryrequest parameterquery, the maxLength was set to512 - info
added the new optional
queryrequest parameterlanguage - info
added the new enum value
0to thequeryrequest parameterallow_nsfw - info
added the new enum value
1to thequeryrequest parameterallow_nsfw - info
added the new enum value
commentto thequeryrequest parametersearch_type - info
added the new enum value
communityto thequeryrequest parametersearch_type - info
added the new enum value
mediato thequeryrequest parametersearch_type - info
added the new enum value
peopleto thequeryrequest parametersearch_type - info
added the new enum value
postto thequeryrequest parametersearch_type - info
added the new enum value
strictto thequeryrequest parametersafe_search - info
added the new enum value
unsetto thequeryrequest parametersafe_search - info
queryrequest parametersortlist-of-types was widened by adding typesnull - info
queryrequest parametertime_rangelist-of-types was widened by adding typesnull - info
for the
queryrequest parametersort, the type was generalized fromstringto no type - info
for the
queryrequest parametertime_range, the type was generalized fromstringto no type
- breaking