Reddit-APP-API

获取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示例含义
ANDrust AND borrow AND checker同时匹配所有指定词
ORrust OR golang匹配任意一个指定词
NOTrust 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:

Syntaxquery exampleMeaning
ANDrust AND borrow AND checkerRequire all specified terms
ORrust OR golangMatch any specified term
NOTrust NOT gameExclude a specified term
Parenthesesrust 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:rustLimit to a community
author:author:redditLimit to an author
flair:flair:discussionSearch post flair text
site:site:github.comLimit linked domains
url:url:github.comSearch link addresses
self:self:trueLimit 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

get/api/v1/reddit/app/fetch_dynamic_search

Request

  • Base URL
    https://api.tikhub.io (the document declares no server; this is the origin it was published from)
  • Auth
    HTTP bearer

Query parameters

languagestring

返回内容使用的语言,采用 IETF 语言标签;默认 en-US / Preferred response language as an IETF language tag; default: en-US

querystring required

搜索关键词或搜索表达式;帖子搜索默认可匹配部分关键词,支持 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'

搜索类型/Search type: post(帖子), community(社区), comment(评论), media(媒体), people(用户)

sort'RELEVANCE' | 'HOT' | 'TOP' | 'NEW' | 'COMMENTS' nullable

排序方式(仅适用于post/comment/media)/Sort method (only for post/comment/media): RELEVANCE(相关性), HOT(热门), TOP(最受欢迎), NEW(最新), COMMENTS(评论数,仅post)

time_range'all' | 'year' | 'month' | 'week' | 'day' | 'hour' nullable

时间范围(仅适用于post/media)/Time range (only for post/media): all(所有时间), year(去年), month(上月), week(上周), day(今天), hour(过去1小时)

safe_search'unset' | 'strict'

安全搜索设置/Safe search setting: unset, strict

allow_nsfw'0' | '1'

是否允许NSFW内容/Allow NSFW content: 0, 1

afterstring

分页游标;need_format=true时使用pageInfo.endCursor / Pagination cursor; use pageInfo.endCursor when need_format=true

need_formatboolean

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

codeinteger

HTTP status code | HTTP状态码

request_idstring nullable

Unique request identifier | 唯一请求标识符

messagestring

Response message (EN-US) | 响应消息 (English)

message_zhstring

Response message (ZH-CN) | 响应消息 (中文)

supportstring

Support message | 支持消息

timestring

The time the response was generated | 生成响应的时间

time_stampinteger

The timestamp the response was generated | 生成响应的时间戳

time_zonestring

The timezone of the response time | 响应时间的时区

docsstring nullable

Link to the API Swagger documentation for this endpoint | 此端点的 API Swagger 文档链接

cache_messagestring nullable

Cache message (EN-US) | 缓存消息 (English)

cache_message_zhstring nullable

Cache message (ZH-CN) | 缓存消息 (中文)

cache_urlstring nullable

The URL to access the cached result | 访问缓存结果的 URL

routerstring

The endpoint that generated this response | 生成此响应的端点

paramsunknown
dataunknown

Changes

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • breaking

      the query request parameter allow_nsfw was restricted to a list of enum values

    • breaking

      the query request parameter safe_search was restricted to a list of enum values

    • breaking

      the query request parameter search_type was restricted to a list of enum values

    • breaking

      for the query request parameter query, the minLength was increased from 0 to 1

    • warning

      for the query request parameter after, the maxLength was set to 4096

    • warning

      for the query request parameter query, the maxLength was set to 512

    • info

      added the new optional query request parameter language

    • info

      added the new enum value 0 to the query request parameter allow_nsfw

    • info

      added the new enum value 1 to the query request parameter allow_nsfw

    • info

      added the new enum value comment to the query request parameter search_type

    • info

      added the new enum value community to the query request parameter search_type

    • info

      added the new enum value media to the query request parameter search_type

    • info

      added the new enum value people to the query request parameter search_type

    • info

      added the new enum value post to the query request parameter search_type

    • info

      added the new enum value strict to the query request parameter safe_search

    • info

      added the new enum value unset to the query request parameter safe_search

    • info

      query request parameter sort list-of-types was widened by adding types null

    • info

      query request parameter time_range list-of-types was widened by adding types null

    • info

      for the query request parameter sort, the type was generalized from string to no type

    • info

      for the query request parameter time_range, the type was generalized from string to no type