远道而来的你世界第一可爱!

铭心石刻 - 二次元随机图API食用说明

不来这里抽个卡嘛~( •̀ ω •́ )y → Gacha

本随机图API基于 Kouseki 自主上传的数据,图片绿色健康(不完全)

随机图API及图床均为保障使用体验和稳定性,API有一定的调用限制,具体见下文

食用方法

API地址:https://imgapi.kouseki.cn/random
调用方法:GET

速率和每日额度限制说明:

API限制:每IP每5秒内可以调用3次API,超出返回429

此外,请注意,每个IP每24小时内仅可通过API获取5000张图片
达到限度后将无法使用API,API地址返回状态码403并给出恢复时间

您可以 访问这里 以在不消耗额度的情况下查询您IP的剩余可用额度或可用额度恢复倒计时

传入参数说明:

键描述 值类型 可用的值 值描述
sort 索引的图片集
(可选,默认为approve)
Text random
approve
top
cat
yin
mp
pc
tuzi
索引全部图片
索引过审图片 (76268P) 暂时关闭
索引精选图片 (3945P) 暂时关闭
索引兽耳图片 (2510P) 暂时关闭
索引银发图片 (2060P) 暂时关闭
索引竖屏壁纸 (1813P)
索引横屏壁纸 (1770P)
索引点兔图片 (2384P) 暂时关闭
type 输出方法
(可选,默认为重定向)
Text text
json
输出文本
输出JSON格式
num 输出图片数量
(可选,当num大于1时type固定为json)
Integer 小于等于100的任意正整数
若不携带num则默认为1
thumbnail 使用缩略图(失效) Text large
medium
small
最长边重设为800px
最长边重设为176px
最长边重设为96px
only_check 检查可用额度
(可选,当此参数为任意真值时其它参数无效)
Any 任意真值,或不携带此参数

Note:
更新时间:2023年6月29日(UTC+0)
图片审核使用 阿里云内容安全API
图片均来自互联网,来源众多无法确认版权信息,侵删

Demo:

GET https://imgapi.kouseki.cn/random
GET https://imgapi.kouseki.cn/random?thumbnail=large
GET https://imgapi.kouseki.cn/random?sort=top
GET https://imgapi.kouseki.cn/random?sort=cat&type=text
GET https://imgapi.kouseki.cn/random?sort=yin&num=100
GET https://imgapi.kouseki.cn/random?only_check=true

返回参数说明:

注意:当携带num参数且num参数大于等于2时,API只会输出JSON格式

传入type 返回值 Demo
text 图片URL
https://gitcode.net/RedStone_Kun/apicx/raw/master/imgs/moe/52b698e4f4256d50bb8af7a0b90895207907806.webp
json pic: 图片URL(s)数组
remain_num: 剩余额度
{
    "pic": ["https://gitcode.net/RedStone_Kun/apicx/raw/master/imgs/moe/52b698e4f4256d50bb8af7a0b90895207907806.webp"],
    "remain_num": 2333
}
其它 重定向到图片URL

将随机图API设置为网页背景

Demo(CSS):

html:before {
    background: url(https://imgapi.kouseki.cn/random) no-repeat center 0/cover;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: -1;
    content: "";
}

为了避免页面加载被过大的背景图阻塞导致加载缓慢,也可换用下面的方法

Demo(HTML):

<style>
.withBg:before {
    background: url(https://imgapi.kouseki.cn/random) no-repeat center 0/cover;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: -1;
    content: "";
}
</style>
<script>window.onload = () => document.documentElement.classList.add("withBg");</script>

一个输出壁纸轮播HTML的API

API地址:https://imgapi.kouseki.cn/player
调用方法:GET

传入参数说明:

键描述 值类型 值描述
time 每张图片的持续时间,单位为秒
(可选,默认为10)
Integer 大于等于5的任意正整数
若不携带time则默认为5

以下是在网页中插入随机轮播背景的使用例

Demo(HTML):

<iframe src="https://imgapi.kouseki.cn/player?time=10" style="position:fixed;top:0;left:0;width:100%;height:100%;z-index:-1;border:none;overflow:hidden;"></iframe>