Skip to Content
API 参考HTTP API

HTTP API

教师端服务是完整课堂数据面,API 同时挂载在 /api/api/teacher。core runtime server 只提供运行时兼容接口,不托管完整课程数据。

教师端服务

源码位置:repos/teacher/server/src/routes.jsrepos/teacher/server/index.js

健康检查

GET /api/health

返回服务状态、应用名、端口和进程 ID。

Session bootstrap

POST /api/session/bootstrap

为 host/teacher 或 viewer 创建启动会话。教师端服务会使用 LUMESYNC_HOST_TOKENLUMESYNC_VIEWER_TOKEN_SECRET 和 TTL 环境变量生成 token。

示例 body:

{ "role": "viewer" }

课程接口

方法路径说明
GET/api/courses返回课程、文件夹和当前课堂状态
GET/api/components-manifest返回组件 manifest
GET/api/course-status返回当前课程和页码
POST/api/refresh-courses重新扫描课程目录
DELETE/api/delete-course删除课程,courseId 来自 body 或 query
GET`/api/export-course/:courseId?format=pdflume`

文件夹接口

方法路径说明
POST/api/course-folders创建文件夹
DELETE/api/course-folders/:folderId删除文件夹
PUT/api/course-folders/:folderId/move移动文件夹
PUT/api/course-folders/:folderId重命名或更新文件夹
PUT/api/course-folders/:folderId/courses/:courseId移动课程到文件夹

创建文件夹示例:

{ "name": "人工智能", "icon": "book", "parentId": null }

课堂布局

方法路径说明
GET/api/classroom-layout读取座位表
POST/api/save-classroom-layout保存座位表

学生提交

方法路径说明
POST/api/save-submission保存提交内容
GET/api/submission-config读取提交目录配置
POST/api/submission-config更新提交目录配置
GET/api/submissions/:courseId列出课程提交文件
GET/api/submissions/:courseId/file/:fileName(*)下载单个提交文件
POST/api/submissions/:courseId/download-batch批量打包下载

批量下载示例:

{ "files": ["student-a/answer.json", "student-b/answer.json"] }

学生状态和日志

index.js 中还挂载了顶层接口:

方法路径说明
GET/api/students当前学生状态
GET/api/student-log学生行为日志

静态与代理资源

路径说明
/courses课程文件
/components组件资源
/enginerender engine 静态资源
/teacher-app.js教师端 UI bundle
/render-engine.jsrender engine bundle
/lib/:fileName缓存依赖资源
/webfonts/:fileName字体资源
/lib/fonts/:fileName兼容字体路径
/images/proxy图片代理
/weights/:fileName权重文件

core runtime API

源码位置:repos/teacher/core/src/server/create-core-server.ts

方法路径说明
GET/api/health返回 LumeSync-Core 状态
GET/api/courses返回空课程兼容结构,mode: "core-runtime"
GET/api/course-status返回 runtime 模式状态
POST/api/refresh-courses空刷新兼容接口
GET/api/components-manifest空组件 manifest 兼容接口
GET/api/runtime-status返回 host/viewer runtime 快照
GET/api/students兼容接口
GET/api/student-log兼容接口
POST/api/session/bootstrap仅支持 viewer token bootstrap

core server 的 /api/session/bootstrap 需要配置 LUMESYNC_VIEWER_TOKEN_SECRET

错误处理

常见错误响应结构:

{ "success": false, "error": "Missing courseId parameter" }

下一步阅读

Last updated on