API 使用文档
RandomPics 提供了一个简单而强大的免费 API,用于获取高质量的随机图片和图片占位符,支持定制尺寸、灰度处理及模糊效果。
基础用法 (Basic Usage)
通过指定宽度和高度获取一张随机图片:
https://picsapi.syoe.cloud/api/image/200/300
如果需要获取正方形的图片,只需提供一个尺寸参数:
https://picsapi.syoe.cloud/api/image/200
高级用法 (Advanced Usage)
你可以组合使用以下各种参数和效果。例如,获取一张灰度且带有模糊效果的特定图片:
https://picsapi.syoe.cloud/api/image/id/870/200/300?grayscale&blur=2
避免缓存 (Random)
要在浏览器中请求多张相同尺寸的随机图片,可以添加 random 查询参数以防止图片被缓存:
<img src="https://picsapi.syoe.cloud/api/image/200/300?random=1">
<img src="https://picsapi.syoe.cloud/api/image/200/300?random=2">
<img src="https://picsapi.syoe.cloud/api/image/200/300?random=2">
文件后缀 (File Endings)
如果需要文件后缀,可以在 URL 末尾添加 .jpg:
https://picsapi.syoe.cloud/api/image/200/300.jpg
若要获取 WebP 格式的图片,可以在 URL 末尾添加 .webp:
https://picsapi.syoe.cloud/api/image/200/300.webp
图片列表 (List Images)
使用 /api/list 接口获取图片列表数据。
https://picsapi.syoe.cloud/api/list
API 默认每页返回 30 条数据。你可以使用 ?page 参数请求其他页,使用 ?limit 参数更改每页数量:
https://picsapi.syoe.cloud/api/list?page=2&limit=100
响应示例 JSON:
[
{
"id": "0",
"author": "Alejandro Escamilla",
"width": 5616,
"height": 3744,
"url": "https://picsapi.syoe.cloud/api/image/detail/0",
"download_url": "https://picsapi.syoe.cloud/api/image/id/0/5616/3744"
},
...
]