# 随机图片站 · API 文档
Base URL
公网 https://img.axsproject.dpdns.org
内网 http://192.168.5.3:8899
所有接口返回 JSON(除图片/页面)。跨域未开启,服务端调用无需 header。
---
## 1. 随机图(JSON)
GET /api/random
GET /api/random?dir=share 只从某个子目录随机
返回(url / thumb 均为完整地址,可直接用)
{
"url": "https://img.axsproject.dpdns.org/img/QQ/xxx.jpg",
"path": "/img/QQ/xxx.jpg",
"thumb": "https://img.axsproject.dpdns.org/thumb/QQ/xxx.jpg?w=1280",
"file": "QQ/xxx.jpg",
"count": 2674,
"base": "https://img.axsproject.dpdns.org"
}
---
## 2. 随机图(直接跳转)
GET /r
GET /random
GET /r?dir=share
返回 302,Location 指向随机图的 /img/... 地址。
适合 <img src="https://.../r"> 或 OBS 背景(每次刷新换图)。
---
## 3. 站点统计
GET /api/stats
返回
{
"images": 2674, 图片总数
"visits": 5264, 累计访问次数
"permit": false, 当前 cookie 是否持有效许可
"freeLeft": 19 今日剩余上传次数(-1 = 不限)
}
---
## 4. 上传图片
POST /upload
Content-Type: multipart/form-data
字段名: file
curl -F "file=@a.jpg" https://img.axsproject.dpdns.org/upload
成功
{ "ok": true, "file": "20261202_ab12cd_a.jpg", "url": "/img/share/...", "left": 19 }
失败
{ "ok": false, "error": "今日免费上传已达 20 次,请使用访问许可码" } HTTP 429
{ "ok": false, "error": "文件不是有效图片(已拦截)" } HTTP 400
{ "ok": false, "error": "文件太大(上限 25MB)" } HTTP 413
规则
· 单文件 ≤ 25MB
· 类型: jpg/jpeg/png/webp/gif/avif/bmp(服务端校验魔数)
· 免费额度: 20 次/天/IP;持许可码无限
· 文件名自动重命名,防覆盖与猜测
---
## 5. 访问许可码
### 5.1 使用许可码(换取 cookie)
POST /permit/use
Content-Type: application/json
{ "code": "your-code" }
或表单
curl -c cookie.txt -d "code=your-code" https://.../permit/use
成功 { "ok": true }
失败 { "ok": false, "error": "许可码无效" }
{ "ok": false, "error": "该许可码已达使用上限(3次)" }
注意
· 需要用返回的 cookie(permit=code)后续请求才算授权
· 授权后: 无限上传 + 可访问加密目录(r-18)
· cookie 有效期 30 天
### 5.2 管理端(需 admin 登录)
POST /admin/login pass=密码
POST /admin/permit/new note=备注&limit=使用次数(0=不限)
POST /admin/permit/del code=许可码
---
## 6. 留言墙
### 6.1 读取
GET /api/msgs
返回
{ "messages": [ { "id": "ab12", "name": "小明", "text": "你好", "ts": 1796104789824 } ] }
### 6.2 发送
POST /msg
Content-Type: application/json
{ "name": "小明", "text": "你好呀" }
成功 { "ok": true }
失败 { "ok": false, "error": "含违禁词(刷单),请文明留言" }
{ "ok": false, "error": "太快啦,60 秒后再试" }
{ "ok": false, "error": "不要发代码/标签喵,只收纯文字" }
{ "ok": false, "error": "重复字符太多啦,好好说话喵" }
规则
· 文本 2~100 字;昵称 ≤ 12 字
· 同 IP 冷却 60 秒
· 拒绝 HTML/脚本标签、刷屏重复字符、违禁词
· 最多保留 500 条
---
## 7. 图片与缩略图
GET /img/<相对路径> 原图(Cache-Control: 1 天)
GET /thumb/<相对路径>?w=1280 缩略图(自动生成 + 磁盘缓存,30 天)
说明
· w 范围 200~2000,默认 1280
· 缩略图首次生成后落盘,后续 3~30ms 返回
· 加密目录需持许可码,否则 403
· 缩略图生成失败自动 302 回原图(不会白屏)
---
## 8. 页面
GET / 首页(随机图)
GET /share 网友投稿(302 到 /?dir=share)
GET /wall 留言墙(弹幕 / 便利贴)
GET /permit 许可码输入
GET /support 支持页(微信 / 支付宝)
GET /docs 本接口文档
GET /admin 管理面板(密码登录)
---
## 9. 安全与限流
· 接口 120 次/分/IP,图片 600 次/分/IP(超出 429)
· 管理登录 5 次失败锁 15 分钟
· 缩略图生成并发上限 2(防 CPU 打爆)
· 上传/留言均按真实客户端 IP 计(PROXY protocol / X-Forwarded-For)
· 全站 HTTPS,HTTP 自动 301 跳转
---
## 10. 示例脚本
#!/bin/bash
# 拉一张随机图存本地
curl -sL "$(curl -s https://img.axsproject.dpdns.org/api/random \
| python3 -c 'import json,sys;print("https://img.axsproject.dpdns.org"+json.load(sys.stdin)["url"])')" \
-o random.jpg
# 每 10 秒换一次壁纸
while true; do
curl -sL -o /tmp/wall.jpg "https://img.axsproject.dpdns.org/r"
sleep 10
done
← 回首页