📖 API 文档
免费公共图床 提供简洁的 REST API,上传、查看、搜索全部无需认证,删除仅限上传者。
📤 上传图片
POST
/api/upload
支持 multipart/form-data 文件上传或直接 POST 原始图片数据(剪贴板粘贴)。
请求参数
| 参数 | 类型 | 默认 | 说明 | |--------------|--------|--------|----------------------------------------| | image | file | 必填 | 图片文件 (multipart 方式) | | format | string | webp | 输出格式: webp/jpeg/png/avif/gif/auto | | strip_exif | bool | true | 是否移除 EXIF 信息 | | password | string | 无 | 设置访问密码 | | max_width | int | 4096 | 最大宽度 | | max_height | int | 4096 | 最大高度 |
cURL 示例
# 基本上传
curl -F "image=@photo.jpg" http://localhost:5050/api/upload
# 指定格式 + 密码保护
curl -F "image=@photo.jpg" \
-F "format=png" \
-F "password=mypass123" \
http://localhost:5050/api/upload
# 剪贴板粘贴上传 (raw body)
curl -X POST --data-binary @photo.png http://localhost:5050/api/upload
响应示例
{
"success": true,
"id": "aB3xK9mQ",
"url": "http://localhost:5050/i/aB3xK9mQ",
"raw_url": "http://localhost:5050/i/aB3xK9mQ.webp",
"markdown": "",
"html": "<img src=\"...\" alt=\"photo.jpg\">",
"bbcode": "[img]http://localhost:5050/i/aB3xK9mQ.webp[/img]",
"width": 1920,
"height": 1080,
"size": 245760,
"format": "webp"
}
🔍 查询图片信息
GET
/api/info/{id}
curl http://localhost:5050/api/info/aB3xK9mQ
📋 图片列表
GET
/api/list?page=1&per_page=30
curl "http://localhost:5050/api/list?page=1&per_page=20"
🔎 搜索
GET
/api/search?q=keyword
curl "http://localhost:5050/api/search?q=photo"
📊 统计
GET
/api/stats
curl http://localhost:5050/api/stats
🗑️ 删除图片
DELETE
/api/delete/{id}
仅上传者(同IP)可以删除自己的图片。
curl -X DELETE http://localhost:5050/api/delete/aB3xK9mQ
🧹 清理过期图片
POST
/api/cleanup
删除 90 天未访问的图片,可配合 cron 定时执行。
curl -X POST http://localhost:5050/api/cleanup
🖼️ 免费公共图床 · 自托管图床 · 无广告 · 永久免费