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/ai | AI 辅助: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