Files
media-center/ref/resource-pipeline/references/quark-api.md
T
sutong 5d296ee38b feat: add quark rename API
- storage/quark/v1/usage.md: 新增重命名操作
- ref/quark-netdisk-helper/SKILL.md: 新增重命名操作
- ref/resource-pipeline/quark-api.md: 端点表新增重命名

POST /1/clouddrive/file/rename {"fid":"...","file_name":"..."}

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-16 22:17:43 +08:00

113 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Quark API 补全方案
`netdisk-mcp-server` 缺失的创建/移动/删除功能,通过直接调用夸克内部 API 实现。
> **警告**:这些 API 是夸克网页版的内部接口,非官方公开 API,可能随时变更。
## 通用参数
```bash
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. 创建文件夹
```bash
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 查询
```bash
# 查根目录
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. 移动文件
```bash
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. 删除文件
```bash
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` 异步任务 ID`data.finish: true` 表示已完成
## API 端点速查
| 操作 | 方法 | 端点 |
|------|------|------|
| 列出目录 | GET | `/1/clouddrive/file/sort` |
| 创建文件夹 | POST | `/1/clouddrive/file` |
| 重命名 | POST | `/1/clouddrive/file/rename` |
| 移动 | POST | `/1/clouddrive/file/move` |
| 删除 | POST | `/1/clouddrive/file/delete` |
## 注意事项
- **FID 每次都会变**:不能硬编码 FID,每次操作前重新获取
- **异步操作**`finish: false` 表示任务还在进行,需要等待
- **频率限制**:连续请求间隔至少 500ms(返回中有 `tq_gap` 提示)
- **Cookie 有效期**:夸克 Cookie 有效期不定,失效时返回 `401/403`