Files
media-center/ref/resource-pipeline/references/quark-api.md
T
sutong 750f981c7e feat: init media-center skill
资源中心——从多渠道获取资源链接,转存到夸克网盘并整理归档。
- sources/tencent-doc: 腾讯文档读取
- sources/search: 网盘搜索
- storage/quark: 夸克网盘操作
- ref/: 来源 skill 参考归档

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-16 18:28:23 +08:00

3.4 KiB
Raw Blame History

Quark API 补全方案

netdisk-mcp-server 缺失的创建/移动/删除功能,通过直接调用夸克内部 API 实现。

警告:这些 API 是夸克网页版的内部接口,非官方公开 API,可能随时变更。

通用参数

COOKIE="你的夸克网盘Cookie"

BASE_CURL="curl -s --max-time 15 \
  -H \"cookie: $COOKIE\" \
  -H \"accept: application/json\" \
  -H \"content-type: application/json\" \
  -H \"origin: https://pan.quark.cn\" \
  -H \"referer: https://pan.quark.cn/\""

API 列表

1. 创建文件夹

curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file?pr=ucpro&fr=pc&__t=$(date +%s)000" \
  -H "cookie: $COOKIE" \
  -H "content-type: application/json" \
  -H "origin: https://pan.quark.cn" \
  -H "referer: https://pan.quark.cn/" \
  -d '{"pdir_fid":"<父文件夹FID>","file_name":"<文件夹名>","file_type":0,"dir_init":true}'

参数

  • pdir_fid:父文件夹 FID(根目录为 0
  • file_name:文件夹名称
  • file_type:固定为 0(目录)
  • dir_init:固定为 true

返回data.fid 是新文件夹的 FID

2. 获取文件夹 FID

方式一:从 netdisk.list 的输出中提取

3. [dir] 遮.天(2023 (ID: 1ffc622be174429fa36de460856cad05)
                                     ↑ 这就是 FID

方式二:逐层 API 查询

# 查根目录
curl -s "https://drive-h.quark.cn/1/clouddrive/file/sort?pr=ucpro&fr=pc&pdir_fid=0" \
  -H "cookie: $COOKIE" | python -X utf8 -c "
import json,sys
data = json.load(sys.stdin)
for item in data.get('data',{}).get('list',[]):
    if item.get('file_type')==0:
        print(f'{item[\"file_name\"]} -> {item[\"fid\"]}')
"

3. 移动文件

curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/move?pr=ucpro&fr=pc&__t=$(date +%s)000" \
  -H "cookie: $COOKIE" \
  -H "content-type: application/json" \
  -H "origin: https://pan.quark.cn" \
  -H "referer: https://pan.quark.cn/" \
  -d '{"action_type":1,"filelist":["<FID1>","<FID2>"],"to_pdir_fid":"<目标FID>"}'

参数

  • action_type:固定为 1(移动)
  • filelist:要移动的文件/文件夹 FID 数组(建议 ≤30 个)
  • to_pdir_fid:目标文件夹 FID

返回data.finish: true 表示完成

4. 删除文件

curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc&__t=$(date +%s)000" \
  -H "cookie: $COOKIE" \
  -H "content-type: application/json" \
  -H "origin: https://pan.quark.cn" \
  -H "referer: https://pan.quark.cn/" \
  -d '{"action_type":2,"filelist":["<FID1>","<FID2>"]}'

参数

  • action_type:固定为 2(删除)
  • filelist:要删除的文件 FID 数组

返回data.task_id 异步任务 IDdata.finish: true 表示已完成

API 端点速查

操作 方法 端点
列出目录 GET /1/clouddrive/file/sort
创建文件夹 POST /1/clouddrive/file
移动 POST /1/clouddrive/file/move
删除 POST /1/clouddrive/file/delete

注意事项

  • FID 每次都会变:不能硬编码 FID,每次操作前重新获取
  • 异步操作finish: false 表示任务还在进行,需要等待
  • 频率限制:连续请求间隔至少 500ms(返回中有 tq_gap 提示)
  • Cookie 有效期:夸克 Cookie 有效期不定,失效时返回 401/403