接口地址
GET
https://example.com/api/random|https://example.com/api/random/image请求参数
| 参数 | 可选值 | 说明 |
|---|---|---|
orientation | h / horizontal · v / vertical · (不传) | 横图 / 竖图 / 随机 |
source | link · file · all(默认) | txt 链接 / 服务器文件 / 混合 |
mode | inline(默认)· redirect · image | JSON / 302 重定向 / 图片二进制 |
调用示例
https://example.com/api/random随机图片,返回 JSON
https://example.com/api/random?orientation=h随机横图
https://example.com/api/random?orientation=v&mode=redirect竖图,302 重定向
https://example.com/api/random?source=link仅从 txt 链接中随机
https://example.com/api/random?source=file仅从服务器本地文件中随机
https://example.com/api/random?mode=image直接返回图片二进制
https://example.com/api/random/image快捷路径,直接返回图片
https://example.com/api/random/image?orientation=v&source=link返回 txt 中的随机竖图
响应示例
当 mode=inline(默认)时返回 JSON:
{
"url": "https://example.com/image.jpg",
"orientation": "h",
"source": "all"
}直接图片路径
https://example.com/api/random/image 可直接用作 <img>,无需解析 JSON。
<img src="https://example.com/api/random/image?orientation=h&source=file" />