Skip to content

API 接口参考

默认服务地址为 http://localhost:6688。项目没有统一的 /api 全局前缀:实时热榜使用 /hot-lists,历史、调度和简报接口使用 /api/*

健康检查

方法路径说明
GET/服务首页
GET/health进程、内存和 Redis 健康状态
bash
curl http://localhost:6688/health

Redis 不可用时可能返回 status: "degraded"

实时热榜

方法路径说明
GET/hot-lists/all获取所有已注册来源
GET/hot-lists/:source获取指定来源热榜

通用查询参数:

参数类型必填说明
limitnumber限制返回条数
noCacheboolean是否尝试绕过缓存
rssboolean是否返回 RSS XML
typestring部分来源支持的榜单类别
bash
curl 'http://localhost:6688/hot-lists/zhihu?limit=10&noCache=false'

详细说明见获取热榜

历史热点

方法路径说明
GET/api/history/search搜索和分页查询历史热点
GET/api/history/sources获取已保存的数据源列表
GET/api/history/stats获取热点数据统计
GET/api/history/configs获取来源抓取配置
GET/api/history/latest获取最新历史热点
GET/api/history/range/:source/:startTime/:endTime按 Unix 毫秒时间戳范围查询

GET /api/history/search 查询参数:

参数类型默认值说明
sourcestring全部来源 ID
keywordstring标题和描述关键词
startDatedate开始日期,ISO 日期字符串
endDatedate结束日期,ISO 日期字符串
pagenumber1页码,最小为 1
limitnumber20每页条数,范围 1–100
sortBystringtimestamptimestamptitlecreatedAt
sortOrderstringdescascdesc
bash
curl 'http://localhost:6688/api/history/search?source=zhihu&keyword=AI&page=1&limit=10'

详细说明见历史热点

热点抓取调度器

方法路径说明
GET/api/scheduler/status获取运行状态
GET/api/scheduler/ignored-sources获取不保存的来源
GET/api/scheduler/configs获取全部来源配置
POST/api/scheduler/start启动调度器
POST/api/scheduler/stop停止调度器
POST/api/scheduler/trigger立即抓取全部或指定来源
POST/api/scheduler/reconfigure根据当前配置重新注册 Cron
PUT/api/scheduler/config/:source更新来源的启用状态或抓取间隔

立即抓取单个来源:

bash
curl -X POST http://localhost:6688/api/scheduler/trigger \
  -H 'Content-Type: application/json' \
  -d '{"source":"zhihu"}'

更新来源配置:

bash
curl -X PUT http://localhost:6688/api/scheduler/config/zhihu \
  -H 'Content-Type: application/json' \
  -d '{"enabled":true,"interval":30}'

AI 每日简报

方法路径说明
POST/api/briefs/generate手动生成简报
GET/api/briefs/config获取非敏感简报配置
GET/api/briefs/latest获取最新成功简报
GET/api/briefs分页查询简报
GET/api/briefs/statistics/stocks获取历史股票出现次数排名
GET/api/briefs/:date获取指定日期简报
DELETE/api/briefs/:date删除指定日期简报
DELETE/api/briefs/history按日期或保留周期批量清理
GET/api/briefs/scheduler/status获取简报调度状态
POST/api/briefs/scheduler/start启动简报调度器
POST/api/briefs/scheduler/stop停止简报调度器
POST/api/briefs/scheduler/reconfigure重新注册简报 Cron

生成测试简报:

bash
curl -X POST http://localhost:6688/api/briefs/generate \
  -H 'Content-Type: application/json' \
  -d '{"sources":["cls"],"period":"manual-test","force":true}'

调试字段

includeDebug=true 会返回体积较大的 rawInputItemssearchEvidence,只应在后端排查时使用,常规前端请求不要携带。

删除接口

DELETE 路由会直接删除 MongoDB 记录。执行前先通过查询接口确认日期和 period,并优先用 1900-01-01deletedCount: 0 的安全检查。

每日简报的请求参数、响应字段和清理规则见AI 每日简报

校验与错误

服务启用了全局请求校验:

  • 查询参数会根据 DTO 做类型转换。
  • 未声明字段通常会被移除或拒绝。
  • forbidNonWhitelisted 已启用,DTO 不接受的请求体字段会得到 400 Bad Request
  • 不存在的热榜来源返回 404 Not Found
  • 单个上游热榜抓取失败时,实时热榜接口可能返回 200、空数组和 message,调用方应检查响应内容。

仅供技术研究与开发测试使用