随机图片
获取一张随机图片链接,支持自定义宽高
GET
https://api.tinyaii.cn/v1/random/image
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| width | integer | 可选 | 图片宽度(默认 800) | 800 |
| height | integer | 可选 | 图片高度(默认 600) | 600 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| url | string | 随机图片链接 |
| width | int | 图片宽度 |
| height | int | 图片高度 |
| format | string | 图片格式 |
| source | string | 图片来源 |
| message | string | 状态信息 |
返回示例
{
"code": 200,
"data": {
"url": "https://picsum.photos/seed/123456/800.jpg",
"width": 800,
"height": 600,
"format": "jpg"
},
"message": "success"
}
调用示例
curl "https://api.tinyaii.cn/v1/random/image?width=800&height=600" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch("https://api.tinyaii.cn/v1/random/image?width=800&height=600", {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
console.log(await res.json());import requests
resp = requests.get(
"https://api.tinyaii.cn/v1/random/image",
params={"width": "800", "height": "600"},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=10,
)
print(resp.json())把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。