https://img.01ai.space
全部接口需 Token 鉴权
所有接口必须携带 Token(在管理页或 /www/wwwroot/img.01ai.space/config.php 查看),二选一:
# 方式一(推荐)
X-API-Token: <你的 Token>
# 方式二
Authorization: Bearer <你的 Token>
未带或 Token 错误返回 401:{"success":false,"msg":"unauthorized..."}
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /api/upload | 上传文件:图片 / 视频 / 音频 / 文档(multipart 或 raw 二进制) |
| GET | /api/list | 文件列表(分页,时间倒序) |
| POST | /api/delete | 删除文件 |
| GET | /api/settings | 读取存储策略(保留天数/空间上限/已用) |
| POST | /api/settings | 修改存储策略 |
分类 type | 格式 | 单文件上限 |
|---|---|---|
image 图片 | PNG / JPG / WebP / GIF / BMP / AVIF / HEIC / SVG | 20 MB |
video 视频 | MP4 / WebM / MOV / AVI / MKV / FLV | 100 MB |
audio 音频 | MP3 / WAV / FLAC / OGG / M4A | 50 MB |
file 文档 | PDF / ZIP / TXT | 50 MB |
415config.php 的 EXT_BY_MIME / SIZE_LIMITSfile):
curl -H "X-API-Token: <token>" -F file=@本地图片.png https://img.01ai.space/api/upload
curl -H "X-API-Token: <token>" -F file=@视频.mp4 https://img.01ai.space/api/upload
curl -H "Authorization: Bearer <token>" \
--data-binary @本地图片.png https://img.01ai.space/api/upload
{"success": true, "data": {
"id": "20260903_143000_ab12cd34ef56.png", // 删除时用这个 id
"url": "https://img.01ai.space/i/2026/09/03/20260903_143000_ab12cd34ef56.png",
"type": "image", // image / video / audio / file
"mime": "image/png", // 探测出的真实类型
"size": 123456, "width": 1024, "height": 768, // 宽高仅图片有值,其余为 0
"markdown": "", // 图片为 ![](),其余为 [文件名](链接)
"html": "<img src=\"...\" />", // 按类型给 img/video/audio/a
"time": 1788421130,
"cleaned": ["被自动清理的旧文件 id"] // 本次上传触发的清理(无则为空数组)
}}
| 参数 | 类型 | 默认 | 必填 | 说明 |
|---|---|---|---|---|
| page | int | 1 | 否 | 页码,从 1 开始 |
| size | int | 50 | 否 | 每页条数,最大 100 |
curl -H "X-API-Token: <token>" "https://img.01ai.space/api/list?page=1&size=50"
{"success": true, "data": {"total": 2, "page": 1, "size": 50, "items": [
{"id": "...", "url": "...", "type": "image", "size": 70, "time": 1788421130}
]}}
curl -H "X-API-Token: <token>" -H "Content-Type: application/json" \
-X POST -d '{"id":"20260903_143000_ab12cd34ef56.png"}' https://img.01ai.space/api/delete
# 或按 url:
curl -H "X-API-Token: <token>" -H "Content-Type: application/json" \
-X POST -d '{"url":"https://img.01ai.space/i/2026/09/03/xxx.png"}' https://img.01ai.space/api/delete
{"success": true, "data": {"id": "20260903_143000_ab12cd34ef56.png"}}
# 不存在 → 404; 格式非法 → 400
curl -H "X-API-Token: <token>" https://img.01ai.space/api/settings
{"success": true, "data": {
"retentionDays": 0, // 0=永久, 1/7/30 天
"storageGb": 2, // 2/5/8 GB
"updatedAt": 1788423177,
"storageUsedBytes": 0, // 当前已用
"storageLimitBytes": 2147483648 // 空间上限
}}
curl -H "X-API-Token: <token>" -H "Content-Type: application/json" \
-X POST -d '{"retentionDays":30,"storageGb":5}' https://img.01ai.space/api/settings
| 参数 | 可选值 | 必填 | 说明 |
|---|---|---|---|
| retentionDays | 0 / 1 / 7 / 30 | 是 | 0 = 永久保留(只按空间清理) |
| storageGb | 2 / 5 / 8 | 是 | 总空间上限,超出时从最旧开始删 |
cleaned 数组列出)413,类型不识别返回 415getimagesize + 文件头魔数),伪装后缀会被拒绝/i/年/月/日/<文件名>),带一年长缓存;视频/音频支持 Range 分段播放CSP sandbox 头,内嵌脚本不会执行安装 web-uploader 插件,新建自定义图床:
/api/uploadfileX-API-Token: <token>data.urlhttps://img.01ai.space/api/uploadfileX-API-Token: <token>$json:data.url$设置 → 图像 → 上传服务选 PicGo(app),在 PicGo 里配上面那组参数即可。
const fd = new FormData();
fd.append('file', fileInput.files[0]);
const r = await fetch('/api/upload', {
method: 'POST',
headers: { 'X-API-Token': token },
body: fd
});
const j = await r.json();
// j.data.url 即外链