跳至正文

【持续更新】二次元api接口汇总


1. 韩小韩API

1.1. 接口文档

https://api.vvhan.com/dongman.html

1.2. 请求地址

https://api.vvhan.com/api/acgimg

1.3. 请求示例

GET https://api.vvhan.com/api/acgimg
GET https://api.vvhan.com/api/acgimg?type=json
字段类型描述
returnstr响应数据格式,可选json
请求参数

1.4. 响应预览

HTTP/1.1 200 OK
Date: Sun, 26 Jun 2022 11:56:32 GMT
Content-Type: image/jpg
Content-Length: 1045510
Connection: close
CF-Ray: 7215c29b6b01e386-SEA
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Last-Modified: Sun, 26 Jun 2022 11:56:32 GMT
Vary: Accept-Encoding
Via: cache38.l2ot7[0,1,200-0,H], cache18.l2ot7[4,0], cache5.us16[0,16,200-0,H], cache2.us16[20,0]
CF-Cache-Status: MISS
Ali-Swift-Global-Savetime: 1655891484
EagleId: 0819529616562445920493299e
Han-I-To-You-Msg: Hello My Name's Han; Welcome to Han Xiaohan CDN acceleration
Han-Mine-Api-web: Api.Vvhan.Com
Han-Mine-Blog-web: Www.Vvhan.Com
Han-Mine-Msg: Give a rose and leave a fragrance in your hand
Rose: fms-3874999083-214xr
Timing-Allow-Origin: *
X-Cache: HIT TCP_HIT dirn:0:1101561469
X-Swift-CacheTime: 31017191
X-Swift-SaveTime: Thu, 23 Jun 2022 09:58:13 GMT
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=U4JhZiXzyxhMaR0ZOKWQpkB%2FFix7sU0VN9%2F6SNzRX5J4KMDNq6YV2In1KSVWQ1kNdX524GhNQeXwvZT%2FTrSSG66YXjsRAduI3ZCb7Q5W02z5s9mBmsBUid50am4DLQtJ"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

# 下方包含二进制数据
在这里插入图片描述
HTTP/1.1 200 OK
Server: CWAP-waf
Date: Sun, 26 Jun 2022 11:59:26 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000
WZWS-RAY: 1129-1656273566.367-s7jhg
X-Powered-By: wangzhan.qianxin.com

{
  "success": true,
  "imgurl": "https:\/\/static.4ce.cn\/star3\/origin\/c0266b562663f10e314f15618bbfa04c.jpg?rw=5120&rh=3200&_fileSize=566&_orientation=1",
  "info": {
    "width": 1920,
    "height": 1080,
    "type": "img"
  }
}

1.5. 温馨提示

注意:该方法已过时,目前返回的地址均已重定向至https://static.4ce.cn/star3/origin/*.jpg

调用多次发现,该接口返回的图片尺寸大多是1920x1800,且图片url地址中只有最后[ ]里面的数值在变化,截止目前该变化范围是0-696,也就是该接口是从697张二次元图片中随机返回一张。如果你想下载该接口所有的697张图片,可以使用下方代码:

# https://www.cnblogs.com/ghgxj/p/14219047.html
'''依赖模块
pip install requests
'''
import concurrent.futures as cf
import os, time, requests

# 单张图片下载函数
def down(fname, url):
    res = requests.get(url)
    with open(fname, 'wb') as f:
        f.write(res.content)

# 进度条打印函数
def show(num, _sum,  runTime):
    barLen = 20
    perFin = num/_sum
    numFin = round(barLen*perFin)
    numNon = barLen-numFin
    leftTime = (1-perFin)*(runTime/perFin)
    print(
        f"{num:0>{len(str(_sum))}}/{_sum}",
        f"|{'█'*numFin}{' '*numNon}|",
        f"PROCESS: {perFin*100:.0f}%",
        f"RUN: {runTime:.0f}S",
        f"ETA: {leftTime:.0f}S",
        end='\r'
    )
    if num == _sum:
        print()

# 主函数(多线程)
def main():                  
    floder = './img/'
    os.makedirs(floder, exist_ok=True)
    fmt = 'https://cdn.jsdelivr.net/gh/uxiaohan/GitImgTypecho/Acg/api.vvhan.com[{}].jpg'
    total = 697
    with cf.ThreadPoolExecutor() as tp:
        t1 = time.time()
        futures = []
        for i in range(total):
            url = fmt.format(i)
            fname = floder+os.path.basename(url)
            future = tp.submit(down, fname, url)
            futures.append(future)
        count = 0
        for future in cf.as_completed(futures):
            count += 1
            t2 = time.time()
            show(count, total, t2-t1)
    os.system('pause')


main()

2. 樱花API

2.1. 接口文档

http://www.dmoe.cc/

2.2. 请求地址

http://www.dmoe.cc/random.php

2.3. 请求示例

GET http://www.dmoe.cc/random.php
GET http://www.dmoe.cc/random.php?type=json
字段类型描述
returnstr响应数据格式,可选json
请求参数

2.4. 响应预览

HTTP/1.1 200 OK
Server: nginx
Date: Sun, 26 Jun 2022 12:13:07 GMT
Content-Type: text/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Strict-Transport-Security: max-age=31536000

{
  "code": "200",
  "imgurl": "https:\/\/tva3.sinaimg.cn\/large\/0072Vf1pgy1fodqnbricvj31kw0vk7wh.jpg",
  "width": "2048",
  "height": "1136"
}

3. 岁月小筑API

3.1. 接口文档

http://img.xjh.me/

3.2. 请求地址

3.3. 请求示例

GET https://img.xjh.me/random_img.php
GET http://img.xjh.me/random_img.php
GET https://img.xjh.me/random_img.php?return=302
GET https://img.xjh.me/random_img.php?return=json
字段类型描述
returnstr响应数据格式,可选json或302
typestr返回图片类型,可选bg即背景图
ctypestr背景图类型,可选acg或nature
请求参数

2.4 响应预览

HTTP/1.1 200 OK
Date: Tue, 09 Aug 2022 00:28:15 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 240
Connection: close
X-Request-Id: c521417f10b24b4714f024acb8502fb0
Server: WAF

<title>岁月小筑随机图片API接口-随机背景图片-随机图片API</title><img alt="//img.xjh.me/img/62522848_p0.jpg" src="//img.xjh.me/img/62522848_p0.jpg" /><script type="text/javascript" src="https://img.xjh.me/img.js"></script>
HTTP/1.1 200 OK
Date: Tue, 09 Aug 2022 00:28:44 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 262
Connection: close
X-Request-Id: 8c9980be178b4d6e96c90ec01890b75b
Server: WAF

<title>岁月小筑随机图片API接口-随机背景图片-随机图片API</title><img alt="//img.xjh.me/img/61528955_p1_master1200.jpg" src="//img.xjh.me/img/61528955_p1_master1200.jpg" /><script type="text/javascript" src="https://img.xjh.me/img.js"></script>
https://img.xjh.me/random_img.php?return=302
HTTP/1.1 200 OK
Date: Tue, 09 Aug 2022 00:30:03 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 76
Connection: close
X-Request-Id: e824d2d25a1280ecf6e9a8bc5863577d
Server: WAF

{
  "error": 0,
  "img": "//img.xjh.me/img/59143379_p1_master1200.jpg",
  "result": 200
}

3.5. 示例代码

import json, requests
url = 'https://img.xjh.me/random_img.php'
params = {
    'return': 'json',
    'type': 'bg',
    'cytpe': 'acg'
}
res = requests.get(url, params=params).json()
print(json.dumps(res, indent=2))

4. Lucky小站API

注意!我不确定该接口是否可用,因为该接口目前已经报522错误,故使用旧文档

4.1. 接口文档

https://www.nck.cc/index.php/archives/3/

4.2. 请求地址

https://www.rrll.cc/tuceng/ecy.php

4.3. 请求示例

字段类型描述
returnstr响应数据格式,可选json
请求参数

4.5. 示例代码

url = 'https://www.rrll.cc/tuceng/ecy.php'
params = {
    'return': 'json'
}
res = requests.get(url, params=params).json()
print(json.dumps(res, indent=2))

4.6. 响应数据

{
  "code": "200",
  "acgurl": "https://tva4.sinaimg.cn/large/0072Vf1pgy1foxkgc5msdj31hc0u01cv.jpg",
  "width": "1920",
  "height": "1080",
  "size": "jpg"
}

4.7. 图片预览

在这里插入图片描述

5. 三秋API

5.1. 接口文档

https://api.ghser.com/acg.html

5.2. 请求地址

https://api.ghser.com/random/api.php

5.3. 请求示例

自判断二次元API基本调用格式

GET https://api.ghser.com/random/api.php

PC随机二次元API

GET https://api.ghser.com/random/pc.php

PE随机二次元API

GET https://api.ghser.com/random/pe.php

PC随机二次元风景API

GET https://api.ghser.com/random/bg.php

5.4 响应预览

自判断二次元API
PC随机二次元API
PE随机二次元API
PC随机二次元风景API

5.5. 示例代码

import json, requests
url = 'https://api.ghser.com/random/api.php'
res = requests.get(url)
print(res.url)

5.6. 小提示

返回302重定向后的图片url

https://tva1.sinaimg.cn/large/006gkh44ly1fz1kddbampj31hc0u0tyb.jpg

6. 汐岑API

注意!该域名似乎已经到期被注销了,目前还没有找到原作者的新站

6.1. 接口文档

https://acg.yanwz.cn/

6.2. 请求地址

https://acg.yanwz.cn/wallpaper/api.php

6.3. 请求示例

6.4. 响应预览

6.5. 示例代码

import json, requests
url = 'https://acg.yanwz.cn/wallpaper/api.php'
res = requests.get(url)
with open('test.jpg', 'wb') as f:
    f.write(res.content)

6.6. 响应数据

二进制流图片

6.7. 图片预览

在这里插入图片描述

7. 呓喵酱API

本API默认显示R18图片,若无特殊需求,记得使用以下参数关闭R18功能

GET https://api.yimian.xyz/img?R18=false&foo=bar

7.1. 接口文档

https://www.eee.dog/tech/rand-pic-api.html

7.2. 请求地址

https://api.yimian.xyz/img

7.3. 请求示例

根api地址

GET https://api.yimian.xyz/img

随机二次元图片

GET https://api.yimian.xyz/img?type=moe

随机Bing壁纸

GET https://api.yimian.xyz/img?type=wallpaper

随机二次元头像

GET https://api.yimian.xyz/img?type=head

随机图床图片

GET https://api.yimian.xyz/img?type=imgbed

随机1920×1080尺寸二次元图片

GET https://api.yimian.xyz/img?type=moe&size=1920x1080

7.4. 请求参数

字段类型描述
typestr图片类型,可选moe为二次元图
sizestr图片大小,可选1920×1080
请求参数

7.5. 示例代码

import json, requests
url = 'https://api.yimian.xyz/img'
params = {
    'type': 'moe',
    'size': '1920x1080'
}
res = requests.get(url, params=params)
print(res.url)

7.6. 响应数据

返回302重定向后的图片url

https://yimian-image.obs.cn-east-2.myhuaweicloud.com/moe/img_865_2048x1152_96.5199966430664_null_normal.jpg?AWSAccessKeyId=6LJRZC0YN3MQXXFOWMIH&Expires=1608815304&Signature=C5BWWC/r1/o230t1VVLHHmH0kF4%3D

7.7. 图片预览

在这里插入图片描述

8. Lolicon API

8.1. 接口文档

https://api.lolicon.app/

8.2. 请求地址

https://api.lolicon.app/setu/v2

8.3. 请求示例

GET https://api.lolicon.app/setu/v2
POST https://api.lolicon.app/setu/v2
Content-Type: application/json
参数名数据类型默认值说明
r18int00为非 R18,1为 R18,2为混合(在库中的分类,不等同于作品本身的 R18 标识)
numint1一次返回的结果数量,范围为120;在指定关键字或标签的情况下,结果数量可能会不足指定的数量
uidint[]返回指定uid作者的作品,最多20
keywordstring返回从标题、作者、标签中按指定关键字模糊匹配的结果,大小写不敏感,性能和准度较差且功能单一,建议使用tag代替
tagstring[]返回匹配指定标签的作品
sizestring[]["original"]返回指定图片规格的地址
proxystringi.pixiv.re设置图片地址所使用的在线反代服务
dateAfterint返回在这个时间及以后上传的作品;时间戳,单位为毫秒
dateBeforeint返回在这个时间及以前上传的作品;时间戳,单位为毫秒
dscbooleanfalse设置为任意真值以禁用对某些缩写keywordtag的自动转换
请求参数

8.4. 响应预览

HTTP/1.1 200 OK
Date: Wed, 10 Aug 2022 07:50:45 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Via: 1.1 vegur
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=zpA7dWNNmFz%2FtvYUSKnSxWy7bN8QRCj4evfmjFAmtAtljxORSHTAfqLypFNq7Rft8lLK5u4y3s4CZxwv%2BVcFi8%2Fx3Gpq7PXdrcMEYy2LNOMK1b565XH0VAeSUog4o2stdxc%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 738724724cf9c493-SEA
Content-Encoding: gzip
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

{
  "error": "",
  "data": [
    {
      "pid": 97665095,
      "p": 0,
      "uid": 9374007,
      "title": "神里綾華",
      "author": "matrix16",
      "r18": false,
      "width": 1007,
      "height": 1600,
      "tags": [
        "おっぱい",
        "欧派",
        "神里綾華",
        "Ayaka Kamisato",
        "神里凌华",
        "Kamisato Ayaka",
        "原神",
        "Genshin Impact",
        "GenshinImpact",
        "競泳水着",
        "竞技泳装",
        "ハイレグ",
        "高叉",
        "腋",
        "腋下",
        "揉みしだきたい乳",
        "诱人把玩的乳房"
      ],
      "ext": "jpg",
      "uploadDate": 1650103183000,
      "urls": {
        "original": "https://i.pixiv.re/img-original/img/2022/04/16/18/59/43/97665095_p0.jpg"
      }
    }
  ]
}
HTTP/1.1 200 OK
Date: Wed, 10 Aug 2022 07:51:28 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Via: 1.1 vegur
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=fWXAhbH3UYVUabL07EQiARvZ%2B2Z8XBp99bib64AbTZTwpNbgYzMEsJQ1BjWxXzqUYEhe7V%2FoZjeQTPPCpht665MCAx6t8295Y%2F%2BGLWupZ6ZPiIe1q2i3FgOv0OaIc1MxXW0%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 73872584596bc541-SEA
Content-Encoding: gzip
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

{
  "error": "",
  "data": [
    {
      "pid": 98348484,
      "p": 1,
      "uid": 68508563,
      "title": "鲨鲨和小鸟",
      "author": "七榴nana",
      "r18": false,
      "width": 4769,
      "height": 6642,
      "tags": [
        "明日方舟",
        "Arknights",
        "归溟幽灵鲨",
        "Specter the Unchained",
        "幽灵鲨",
        "Specter (Arknights)",
        "Specter",
        "艾丽妮",
        "Elini",
        "Irene",
        "黒スト",
        "黑丝袜",
        "白タイツ",
        "白裤袜",
        "スペクター(アークナイツ)",
        "幽灵鲨(明日方舟)",
        "アイリーニ(アークナイツ)",
        "Irene (Arknights)"
      ],
      "ext": "jpg",
      "uploadDate": 1652541168000,
      "urls": {
        "original": "https://i.pixiv.re/img-original/img/2022/05/15/00/12/48/98348484_p1.jpg"
      }
    }
  ]
}

9. 梓宸随机图片API

9.1. 接口文档

https://zichen.zone/archives/225/(介绍和源码)

https://app.zichen.zone/api/(文档)

9.2. 请求地址

https://app.zichen.zone/api/acg.php

9.3. 请求示例

GET https://app.zichen.zone/api/acg.php
GET https://app.zichen.zone/api/acg.php?json=1
参数名数据类型默认值描述
json 可选int0返回json格式,0 为关闭,1 为启用
type 未开放intnull图片类型,对应不同图库
请求参数

9.4. 响应预览

HTTP/1.1 200 OK
Date: Sat, 10 Sep 2022 05:07:55 GMT
Content-Type: text/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
X-Cache: MISS from kangle web server
Server: cdn
Strict-Transport-Security: max-age=31536000;
X-Cache-Status: MISS

{
  "API_name": "ZiChen ACG API",
  "type": "Normal",
  "id": 339,
  "imgurl": "https:\/\/tvax1.sinaimg.cn\/large\/008o9gdqly1h5xr90uk40j335s1s0x6p.jpg",
  "width": "4096",
  "height": "2304",
  "client_ip": "111.16.90.13"
}

9.5. 图片预览

网页调用示例

樱花API为例

  • 插入图片
<img src="http://www.dmoe.cc/random.php"/>
  • 背景图片(嵌入式CSS)
<body style="background: url(http://www.dmoe.cc/random.php);"></body>
  • CSS
#background {
  background-image: url(http://www.dmoe.cc/random.php);
}

其它API只需要替换srcurl属性值为以下值

1. 韩小韩API
https://api.vvhan.com/api/acgimg
2. 樱花API
http://www.dmoe.cc/random.php
3. 岁月小筑API
https://img.xjh.me/random_img.php?return=302
4. Lucky小站API
https://www.rrll.cc/tuceng/ecy.php
5. 一叶三秋API
https://api.ghser.com/random/api.php
6. 汐岑API
https://acg.yanwz.cn/wallpaper/api.php
7. 呓喵酱API
https://api.yimian.xyz/img

感谢

感谢以下博主搜集/提供的API接口,如果没有这些大佬,这篇文章也就不会出现了

4
为博客质量打分

给我的博客打个分吧,喜欢的话还请多多支持!

Please add vote reason

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注