所有图片
包含横屏与竖屏图片
累计调用 — 次
加载中…
加载失败,请确认当前域名已加入接口白名单。
包含横屏与竖屏图片
累计调用 — 次
横屏高清图片
累计调用 — 次
竖屏图片
累计调用 — 次
横屏电脑壁纸
累计调用 — 次
服务器返回 302 跳转,浏览器直接加载图片。
可选 size 指定图片尺寸:0-7 预设,数字越大尺寸越小,0=原图;也可直接传像素宽度(100-3840,如 1920)。
<img src="https://api.moelm.cn/api/random" alt="萌陌API">
<img src="https://api.moelm.cn/api/random?size=4" alt="指定尺寸">
选择尺寸后获取一张随机图片。
添加 ?type=json 参数即可获得结构化数据,适合前端/后端程序对接。
{
"code": 200,
"url": "https://img.moelm.cn/i/2025/07/13/xxx.webp"
}
若传了 size 参数,响应中会额外包含 size / width 字段:
{
"code": 200,
"url": "https://img.moelm.cn/i/2025/07/13/xxx.webp",
"size": 3,
"width": 1920
}
| 参数 | 别名 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
type |
format |
是 | — | 设为 json 启用 JSON 响应 |
size |
— | 否 | 0 | 图片尺寸 0-7,0=原图,数字越大尺寸越小 0:原图 1:3840 2:2560 3:1920 4:1280 5:960 6:640 7:320 也支持直接传像素宽度:100-3840(如 1920) |
// JavaScript fetch
fetch('https://api.moelm.cn/api/random?type=json')
.then(res => res.json())
.then(data => {
console.log(data.url); // 图片地址
// 设置到 img 标签
document.getElementById('myImg').src = data.url;
});
// JavaScript async/await
async function getRandomImage() {
const res = await fetch('https://api.moelm.cn/api/random?type=json');
const data = await res.json();
return data.url;
}
# PHP 调用
$json = file_get_contents('https://api.moelm.cn/api/random?type=json');
$data = json_decode($json, true);
echo $data['url']; // 图片地址
# Python 调用
import requests
data = requests.get('https://api.moelm.cn/api/random?type=json').json()
print(data['url']) # 图片地址
发送 JSON 请求并查看返回内容。