本文档提供了 Bloret BBS 的所有公开接口说明。开发者可以使用这些 API 开发第三方客户端、统计机器人或进行数据分析。
- API 根路径:
http://<your-domain>:21111/api - 认证方式: Cookie Session (需要在浏览器环境或请求头携带
sessioncookie)。 - 数据格式: JSON
获取论坛所有的板块及下属分区结构。
- URL:
/structure - Method:
GET - Auth: 不需要
- Response:
{ "技术交流": ["NodeJS", "Python", "Frontend"], "生活闲聊": ["灌水区", "摄影分享"] }
获取全站所有帖子信息(用于首页瀑布流或统计)。
- URL:
/all-posts - Method:
GET - Auth: 不需要
- Response: Array
[ { "filename": "17000000.json", "board": "技术交流", "section": "NodeJS", "title": "如何使用 Express", "author": "Admin", "time": 1700000000000, "likes": ["user1", "user2"], "content": "..." }, ... ]
根据关键词搜索帖子标题或内容。
- URL:
/search - Method:
GET - Auth: 不需要
- Params:
q(必填): 搜索关键词
- Response: Array
[ { "board": "技术交流", "section": "NodeJS", "title": "Express 中间件详解", "preview": "中间件是 Express 的核心...", "likes": 5 } ]
获取论坛的运行统计数据。
- URL:
/system/stats - Method:
GET - Auth: 不需要
- Response:
{ "version": "1.0.0", "stats": { "boards": 5, "sections": 12, "posts": 340 }, "server_time": 1700000000000 }
- URL:
/posts - Method:
GET - Params:
board(必填): 板块名section(必填): 分区名
- Response: Array (帖子对象列表)
- URL:
/post - Method:
POST - Auth: 需要登录
- Body:
{ "board": "技术交流", "section": "NodeJS", "title": "我的新发现", "content": "Markdown 内容...", "tags": [] }
- URL:
/post/like - Method:
POST - Auth: 需要登录
- Body:
{ "board": "技术交流", "section": "NodeJS", "filename": "1700000.json" } - Response:
{ "success": true, "liked": true, // true 表示点赞成功,false 表示取消点赞 "count": 10 // 当前总赞数 }
- URL:
/user - Method:
GET - Response:
(未登录返回
{ "username": "Admin", "email": "admin@example.com", "admin": true }null)
查询指定用户的发帖统计和最近动态。
- URL:
/user/profile/:username - Method:
GET - Example:
/api/user/profile/Admin - Response:
{ "username": "Admin", "postCount": 42, "receivedLikes": 156, "recentPosts": [ { "title": "最新公告", "board": "公告", "time": 17000... } ] }
- URL:
/user/follow - Method:
POST - Auth: 需要登录
- Body:
{ "type": "board", // 或 "section" "target": "技术交流" // 或 "技术交流/NodeJS" }
执行禁言、黑名单、分区管理等操作。
- URL:
/manage/update - Method:
POST - Auth: 需要登录 (且具有 Owner 或 Admin 权限)
- Body Action 类型:
setMuted: 禁言设置{"muted": true}updateBlacklist: 黑名单{"type": "add", "user": "badguy"}manageSecAdmin: 设置分区管理员{"type": "add", "user": "mod"}sectionConfig: 修改分区图片{"image": "http..."}deletePost: 删除帖子{"filename": "..."}reorderSections: 排序{"newOrder": ["A", "B"]}
将图片上传到 Bloret Image Host。
- URL:
/upload-proxy - Method:
POST - Content-Type:
multipart/form-data - Param:
image(文件) - Response:
{ "success": true, "data": { "url": "/img/..." } }