随机图片接口(/v1/img)

端点

方法 路径 说明
GET /v1/img 随机一张(UA 自适应横/竖屏)
GET /v1/img/h 随机一张(强制横屏)
GET /v1/img/v 随机一张(强制竖屏)
GET /v1/img/list 图片列表(UA 自适应)
GET /v1/img/list/h 图片列表(强制横屏)
GET /v1/img/list/v 图片列表(强制竖屏)
参数 类型 默认 说明
type string 302 返回格式:302 / json / text / img

302 重定向

curl -L http://api.mfawa.top/v1/img

响应:302 FoundLocation: https://cdn.mfawa.top/image/background/xxx.png

JSON

curl http://api.mfawa.top/v1/img?type=json
{
  "status": "success",
  "time": 1730000000000,
  "data": {
    "id": "1",
    "name": "100066591_p0.png",
    "url": "https://cdn.mfawa.top/image",
    "path": "/background/100066591_p0.png",
    "fullUrl": "https://cdn.mfawa.top/image/background/100066591_p0.png"
  }
}
字段 类型 说明
data.id string 序号
data.name string 文件名
data.url string 基础 URL
data.path string 图片路径
data.fullUrl string 完整图片 URL

纯文本

curl http://api.mfawa.top/v1/img?type=text
https://cdn.mfawa.top/image/background/100066591_p0.png

图片流

curl http://api.mfawa.top/v1/img?type=img -o img.png

图片列表

curl http://api.mfawa.top/v1/img/list?type=json
{
  "status": "success",
  "total": 3,
  "time": 1730000000000,
  "data": [
    { "id": "1", "name": "100066591_p0.png", "url": "https://cdn.mfawa.top/image", "path": "/background/100066591_p0.png" }
  ]
}
curl http://api.mfawa.top/v1/img/list?type=text
https://cdn.mfawa.top/image/background/100066591_p0.png
https://cdn.mfawa.top/image/background/100257227_p0.png

UA 规则

命中任一关键词判定为竖屏,否则横屏:

Mobile Android iPhone iPad iPod HarmonyOS Windows Phone


错误响应

状态码 场景
400 type 值不合法
502 上游请求失败或图片列表为空
429 触发限流
{ "status": "error", "time": 1730000000000, "message": "未获取到图片列表" }