← 返回首页

QuickForm CLI 接口说明

供命令行、扣子编程、OpenClaw 等工具自动化创建与查看数据任务,无需打开网页。


1. 基础信息

用户名含中文、特殊 Unicode

说明:本文档涵盖两类能力
- CLI 接口(/cli/*):给“校园版/教师版迁移、脚本、大模型工具”调用的账号密码接口(无需 Cookie)。
- 网页端「任务导出 / 导入」:站内按钮触发的导出 ZIP / 导入 ZIP|JSON(需要网页登录)。


2. 获取当前用户信息 POST /cli/getuser

使用用户名与密码认证,返回账号资料(不写 Session,适合脚本判断认证状态)。

请求参数

参数 必填 说明
username 用户名(也可用已绑定的邮箱/手机号登录)
password 与 auth_code 二选一 密码
auth_code 与 password 二选一 QFLink 授权码(qf + 32 位十六进制)

成功响应(200)

{
  "success": true,
  "user": {
    "id": 12,
    "username": "teacher1",
    "email": "teacher@example.com",
    "email_verified": true,
    "phone": "13800138000",
    "school": "某某中学",
    "school_province": "浙江省",
    "role": "user",
    "is_certified": true,
    "certified_at": "2025-03-01 10:00:00",
    "task_limit": 3,
    "created_at": "2024-09-01 08:00:00"
  }
}

说明:

错误响应

示例(curl)

curl -X POST "https://quickform.cn/cli/getuser" \
  -H "Content-Type: application/json" \
  -d '{"username":"teacher1","password":"your_password"}'

(兼容旧路径:POST /mcp/getuser。)


2.1 QFLink 校验 POST /cli/qflink/verify

教师版/校园版连接在线服务器时使用;认证参数同 getuser,另可加 clientteacher / school)。

成功时返回 userqflink.online_baseqflink.cli_endpoints。详见 QFLINK.md

未认证教师(用户名+密码或授权码)示例响应(403):

{
  "success": false,
  "code": "certification_required",
  "message": "该账号尚未完成教师认证,无法使用 QFLink / CLI 连接在线版。用户名+密码与 QFLink 授权码均不可用,请先完成教师认证。",
  "is_certified": false,
  "certification_url": "https://quickform.cn/certification/request",
  "hint": "请登录在线版个人中心提交「教师认证」申请,审核通过后再从校园版/教师版重试。"
}

3. 增加数据任务 POST /cli/add

创建一条新的数据任务,并返回用于提交数据的 apiid

请求参数

参数 必填 说明
username 用户名
password 密码
task_name 任务名称
task_intro 任务介绍/描述

(兼容字段:title 等同 task_namedescription 等同 task_intro。)

成功响应(200)

{
  "success": true,
  "apiid": "a1b2c3d4ef"
}

apiid 即该任务的 API 标识,后续提交数据、拉取数据都使用此 id。

错误响应

示例(curl)

# JSON
curl -X POST "https://quickform.cn/cli/add" \
  -H "Content-Type: application/json" \
  -d '{"username":"teacher1","password":"your_password","task_name":"课堂签到表","task_intro":"本周签到"}'

# 表单
curl -X POST "https://quickform.cn/cli/add" \
  -d "username=teacher1&password=your_password&task_name=课堂签到表&task_intro=本周签到"

4. 查看数据任务列表 POST /cli/list

获取当前账号下所有数据任务及其 apiid 与名称。

请求参数

参数 必填 说明
username 用户名
password 密码

成功响应(200)

{
  "success": true,
  "tasks": [
    { "apiid": "a1b2c3d4ef", "name": "课堂签到表" },
    { "apiid": "x9y8z7w6vu", "name": "问卷回收" }
  ]
}

错误响应

示例(curl)

curl -X POST "https://quickform.cn/cli/list" \
  -H "Content-Type: application/json" \
  -d '{"username":"teacher1","password":"your_password"}'

5. 查看单个任务详情(用于迁移导出端)POST /cli/show

通过 apiid 获取任务的基本信息与附件(用于“校园版/教师版”从在线版拉取任务并下载 HTML 附件)。

请求参数

参数 必填 说明
username 用户名
password 密码
apiid 任务 API 标识
include_data true 时额外返回 submissions 数组(仅任务所有者;公开任务不可用)。不计入 /all 配额,禁读模式下仍可用。

成功响应(200)

{
  "success": true,
  "apiid": "a1b2c3d4ef",
  "name": "课堂签到表",
  "intro": "任务描述(可空)",
  "tutorial": "教程链接(可空)",
  "share_url": "分享链接(可空)",
  "attachments": [
    { "name": "index.html", "url": "https://quickform.cn/static/uploads/xxxxxxxx.html" }
  ],
  "submissions": [],
  "total_submissions": 0
}

(无 include_data 时不含 submissions / total_submissions。)

attachments 重要要求(迁移导出端必读)

错误响应

示例(curl)

curl -X POST "https://quickform.cn/cli/show" \
  -H "Content-Type: application/json" \
  -d '{"username":"teacher1","password":"your_password","apiid":"a1b2c3d4ef"}'

含提交数据(所有者,JSON 内联,适合条数较少时):

curl -X POST "https://quickform.cn/cli/show" \
  -H "Content-Type: application/json" \
  -d '{"username":"teacher1","password":"your_password","apiid":"a1b2c3d4ef","include_data":true}'

5.1 导出任务迁移 ZIP POST /cli/export_task

与网页「导出任务」相同,返回 application/zip 附件(v2 仅结构,v3 含 submissions.json 与附件目录)。

请求参数

参数 必填 说明
username 用户名
password 密码
apiid 任务 API 标识(也可用 task_id / id
include_data true 时导出含全部提交数据(默认 false 仅 HTML+manifest)

成功响应(200)

错误响应

示例(curl,含数据保存为文件)

curl -X POST "https://quickform.cn/cli/export_task" \
  -H "Content-Type: application/json" \
  -d '{"username":"teacher1","password":"your_password","apiid":"a1b2c3d4ef","include_data":true}' \
  -o task_migration.zip

6. 上传 HTML 文件 POST /cli/upload

上传单个 HTML/HTM 文件,并绑定到某个已创建的任务(用于迁移导入端:后续需要带 taskid 的可访问页面)。

说明:CLI 上传时必须指定目标任务apiid 推荐 / task_idtaskid / id)。否则会出现“未走教师认证/任务权限校验就拿到可访问公网 HTML”的问题。

请求方式

成功响应(200)

{
  "success": true,
  "url": "https://quickform.cn/uploads/xxxxxxxx.html?taskid=a1b2c3d4ef",
  "filename": "xxxxxxxx.html"
}

若你需要该上传结果马上用于迁移导入/展示,请确保当前账号已满足“教师认证通过/任务 HTML 可访问”条件。

错误响应

示例(curl)

curl -X POST "https://quickform.cn/cli/upload" \
  -F "username=teacher1" \
  -F "password=your_password" \
  -F "apiid=a1b2c3d4ef" \
  -F "file=@/path/to/your/page.html"

7. 使用 apiid 提交与获取数据

拿到 apiid 后,与网页端一致:

高并发与网页优先(自建部署):当 POST /api/<apiid>GET /api/<apiid>/all 等数据通道瞬时占满 Waitress 工作线程时,进程内可对上述路由施加有界并发。POST /api/<apiid>(JSON 或 application/x-www-form-urlencoded,非 multipart)在槽位已满时默认将已解析数据写入本地临时队列并返回 202queued: truespool_id),后台线程在有空槽时写入数据库;若关闭落盘(QF_API_POST_SPOOL_ON_BUSY=0)或队列目录积压超过上限,则仍返回 503(含 retry_after)。GET /api/<apiid>/all 等仍以 503 退避为主。环境变量:QF_BULK_API_MAX_INFLIGHT(0 关闭)、QF_WEB_IN_FLIGHT_RESERVEQF_BULK_API_RETRY_AFTERQF_API_POST_SPOOL_*(见 core/api_submit_spool.py)。详见 core/bulk_api_gate.py 注释。

完整提交地址示例https://quickform.cn/api/a1b2c3d4ef


8. 与扣子 / OpenClaw 的自动化流程

  1. 创建任务:调用 POST /cli/add,传入用户名、密码、任务名称(及可选介绍),得到 apiid
  2. 配置提交地址:在扣子/OpenClaw 应用中将「数据提交接口」配置为:
    https://quickform.cn/api/<apiid>
    例如:https://quickform.cn/api/a1b2c3d4ef
  3. 应用内提交:用户在前端填写的数据以 JSON 形式 POST 到上述地址即可写入 QuickForm。
  4. 查询任务列表:需要展示或选择「往哪个任务提交」时,可调用 POST /cli/list 获取当前用户下所有 apiid 与名称。

这样即可在不打开 QuickForm 网页的情况下,完成任务的创建、列表查看与数据提交地址的配置。


9. 网页端「任务导出 / 导入」(站内功能)

如果你是在网页里操作(不是脚本/CLI),请看这里。

8.1 开关

管理员可用环境变量控制是否启用:

8.2 导出任务(ZIP)

环境变量(可选):

注意:导出通常仅任务创建者/管理员可用;含数据导出走站内/CLI 所有者通道,不因「禁读」或 /all 配额用尽而拒绝(公开 API 的 /all 仍受配额限制)。在线版不负责将 v3 包导入为提交记录,由校园版自行消费 ZIP。

8.3 导入任务(ZIP 或 JSON)


10. 返回数据格式小结

接口 成功时返回字段 说明
POST /cli/getuser success: true, user 用户信息(认证、单位、邮箱等)
POST /cli/add success: true, apiid 新任务的 API 标识
POST /cli/list success: true, tasks tasks[{ apiid, name }, ...]
POST /cli/show success: true, attachments 迁移导出端:返回 HTML 附件直链;include_data 可拉 JSON
POST /cli/export_task ZIP 文件流 与网页「导出任务」一致;include_data=true 含全部数据,不计 /all 配额
POST /cli/upload success: true, url, filename 上传并绑定到任务的可访问页面地址与保存文件名(未认证时返回审核提示页)

所有错误均为 success: false 且带 message 字段,便于 CLI 或技能内统一处理。