# 随机动漫图片


接口地址

所有图片(包含横屏竖屏)

https://api.moelm.cn/api/random

4K(横屏图片)

https://api.moelm.cn/api/random/4K

魔女之旅-伊蕾娜(竖屏图片)

https://api.moelm.cn/api/random/yln

PC(横屏图片)

https://api.moelm.cn/api/random/PC

接口统计

详细统计

--
总调用次数
--
今日调用次数
--
昨日调用次数
--
图片资源总数
--
🟢 当前在线
接口 资源数 今日 昨日 累计 占比
加载中…

默认调用(302 跳转)

返回格式

image/webp

服务器返回 302 跳转,浏览器直接加载图片。

请求方式

GET

请求参数

可选 size 指定图片尺寸,0-7,数字越大尺寸越小,0=原图。

请求示例

https://api.moelm.cn/api/random

https://api.moelm.cn/api/random?size=3

https://api.moelm.cn/api/random?size=6

调用实例

<img src="https://api.moelm.cn/api/random" alt="萌陌API">
<img src="https://api.moelm.cn/api/random?size=4" alt="指定尺寸">

在线测试


JSON 调用

添加 ?type=json 参数即可获得结构化数据,适合前端/后端程序对接。

返回格式

application/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
}

请求方式

GET

请求参数

参数 别名 必填 默认值 说明
type format 是 — 设为 json 启用 JSON 响应
size — 否 0 图片尺寸 0-7,0=原图,数字越大尺寸越小
0:原图 1:3840 2:2560 3:1920 4:1280 5:960 6:640 7:320

请求示例

https://api.moelm.cn/api/random?type=json

https://api.moelm.cn/api/random?type=json&size=3

https://api.moelm.cn/api/random?type=json&size=6

调用实例

// 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'])  # 图片地址

在线测试