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 | 修改存储策略 |
file):
curl -H "X-API-Token: <token>" -F file=@本地图片.png https://img.01ai.space/api/upload
curl -H "Authorization: Bearer <token>" \
-H "Content-Type: image/png" \
--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",
"size": 123456, "width": 1024, "height": 768,
"markdown": "",
"html": "<img src=\"...\" />",
"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": "...", "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 数组列出)PNG / JPG / WebP / GIF,单张 ≤ 20MB(超限返回 413,非图片返回 415)getimagesize 探测真实内容,伪装后缀会被拒绝/i/年/月/日/<文件名>),带一年长缓存,适合外链 / AI 参考图安装 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 即外链