Open API

开放 API

公开只读接口可直接调用(已开 CORS);写接口需登录会话。

方法路径说明
GET/api/health服务健康状态
GET/api/posts文章列表(公开)
GET/api/posts/:slug文章详情:markdown / html(公开)
GET/api/comments?post=slug某文章评论(公开)
GET/api/stats站点统计:文章 / 评论 / 用户 / 字数
GET/api/weather当前天气(Open-Meteo 代理,10 分钟缓存)
POST/api/login登录(返回会话 Cookie)
POST/api/register注册新账号
POST/api/comments发表评论 / 回复(游客或登录)
POST/api/messages发送站内信(登录;管理员可群发)
GET/api/messages我的收件箱(登录)
POST/api/aiAI 辅助:inspire / outline / summary / continue / polish / postSummary / ask
GET/api/settings站点设置(管理员)
POST/api/settings保存设置(管理员)

示例

# 文章列表
curl http://localhost:8899/api/posts
# 单篇详情
curl http://localhost:8899/api/posts/hello-world/
# 站点统计
curl http://localhost:8899/api/stats