API 调用文档
随机二次元图片 API,共 1182 张图片(402 横图 + 780 竖图)
接口地址
https://tu.hakimi.de5.net/api/random.html
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | string | 否 | 设为 json 返回 JSON,否则 302 跳转 |
category | string | 否 | landscape 横图 / portrait 竖图 / 不填随机 |
返回示例
302 重定向(默认)
GET https://tu.hakimi.de5.net/api/random.html
→ 302 Found
→ Location: https://list.yppp.net/d/image/xxx.jpg
JSON 格式
GET https://tu.hakimi.de5.net/api/random.html?type=json
{
"code": 200,
"url": "https://list.yppp.net/d/image/xxx.jpg",
"type": "landscape"
}
使用示例
HTML img 标签
<img src="https://tu.hakimi.de5.net/api/random.html" alt="随机图片">
JavaScript 获取
fetch('https://tu.hakimi.de5.net/api/random.html?type=json')
.then(res => res.json())
.then(data => console.log(data.url));
Python 请求
import requests
res = requests.get('https://tu.hakimi.de5.net/api/random.html?type=json')
print(res.json()['url'])
cURL
# 获取 JSON
curl https://tu.hakimi.de5.net/api/random.html?type=json
# 直接下载
curl -L https://tu.hakimi.de5.net/api/random.html -o random.jpg
注意事项
- API 无需认证,可直接调用
- 图片来自第三方图床,请遵守相关使用规范
- 请勿高频调用,建议间隔 1 秒以上
- 仅供个人学习研究使用