API 调用文档
接口列表和参数详见 API 页面,本页介绍如何使用
返回格式
302 重定向(默认)
GET https://api.yppp.net/pc.php
→ 302 Found
→ Location: https://list.yppp.net/d/image/xxx.jpg
JSON 格式
GET https://api.yppp.net/pc.php?return=json
{
"code": "200",
"acgurl": "https://list.yppp.net/d/image/xxx.png",
"width": "2290",
"height": "1200",
"size": "png"
}
使用示例
HTML 直接展示
<img src="https://api.yppp.net/pc.php" alt="随机图片">
简单场景下直接用 img 标签即可,每次刷新页面都会返回不同图片
JavaScript 获取
// 获取 JSON 格式
const res = await fetch('https://api.yppp.net/pc.php?return=json');
const data = await res.json();
console.log(data.acgurl);
// 同一页面多次调用需加时间戳避免缓存
const res2 = await fetch(`https://api.yppp.net/pc.php?return=json&t=${Date.now()}`);
Python 请求
import requests
# JSON 格式
res = requests.get('https://api.yppp.net/pc.php?return=json')
print(res.json()['acgurl'])
# 直接下载图片
res = requests.get('https://api.yppp.net/pc.php')
with open('random.jpg', 'wb') as f:
f.write(res.content)
cURL
# 获取 JSON
curl https://api.yppp.net/pc.php?return=json
# 直接下载
curl -L https://api.yppp.net/pc.php -o random.jpg
注意事项
- API 无需认证,可直接调用
- 速率限制:10 秒内超过 20 次请求将触发 30 秒限制
- 同一页面多次调用需添加随机参数(如时间戳)避免缓存
- 自适应接口
api.php根据 User-Agent 自动选择横图或竖图 - 图片仅供学习交流使用