返回首页

随机一图 API

随机返回一张图片,支持横图 / 竖图筛选,图片来源支持 txt 链接、服务器本地文件或混合。

接口地址

GEThttps://example.com/api/random|https://example.com/api/random/image

请求参数

参数可选值说明
orientationh / horizontal · v / vertical · (不传)横图 / 竖图 / 随机
sourcelink · file · all(默认)txt 链接 / 服务器文件 / 混合
modeinline(默认)· redirect · imageJSON / 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" />