Skip to content

随机图片 API

TIP

  • 本服务采用自动监控、故障切换策略,因此单 IP 故障可能导致最多 7 分钟无法访问。
  • 本服务无任何 SLA 保证,但是根据 30 天监控数据,可用性一般不低于 99.9%,你可以查看历史数据
  • 若刷新 DNS 缓存后,确认出现了单 IP 超过 7 分钟无法访问并且未自动切换的异常情况,你可以联系 ADMIN [AT] CDN [DOT] QA;如发现有违反版权、涉及政治敏感、暴力恐怖、色情等违法违规内容,请及时联系 ADMIN [AT] TSINBEI [DOT] COM。

方便快捷地在前端引用随机图片服务。

1/ 必应每日一图

1.1/ JSON API

获取随机图片:

html
https://api.tsinbei.com/bing/
https://api.tsinbei.com/bing/

图片示例

返回示例:

json
{
    "code": 200, 
    "msg": "获取成功", 
    "data": {
        "date": "20220409", 
        "url": "https://cn.bing.com/th?id=OHR.Caracal_ZH-CN7086185498_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp", 
        "copyright": "三只狞猫宝宝 (© Marion Vollborn/Minden Pictures)", 
        "title": "没错,我们看到了基因遗传的力量……",
        "id": 22,
        "local": "https://cdn.tsinbei.com/site/api/bing/22.jpg"
    }
}
{
    "code": 200, 
    "msg": "获取成功", 
    "data": {
        "date": "20220409", 
        "url": "https://cn.bing.com/th?id=OHR.Caracal_ZH-CN7086185498_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp", 
        "copyright": "三只狞猫宝宝 (© Marion Vollborn/Minden Pictures)", 
        "title": "没错,我们看到了基因遗传的力量……",
        "id": 22,
        "local": "https://cdn.tsinbei.com/site/api/bing/22.jpg"
    }
}

获取所有包含图片的日期:

html
https://api.tsinbei.com/bing/?date=all
https://api.tsinbei.com/bing/?date=all

返回示例:

json
{
	"code": 200,
	"msg": "获取成功",
	"data": [20220319,20220320]
}
{
	"code": 200,
	"msg": "获取成功",
	"data": [20220319,20220320]
}

WARNING

必应周日似乎没有每日一图,因此如果遍历本 API 会发现返回大量 404 结果,如果你没有被封 IP 的话。为了防止出现愚蠢的此类行为,请直接调用本 API 接口获取所有存在每日一图的日期。

获取指定日期的图片:

html
https://api.tsinbei.com/bing/?date=2022-08-06
https://api.tsinbei.com/bing/?date=2022-08-06

返回示例:

json
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"date": "20220806",
		"url": "https://cn.bing.com/th?id=OHR.theBeginningofAutumn2022_ZH-CN9413449297_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
		"copyright": "杭州西湖的古典中国园林 (© DANNY HU/Getty Images)",
		"title": "贴秋膘了吗?",
		"id": 140,
		"local": "https://cdn.tsinbei.com/site/api/bing/140.jpg"
	}
}
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"date": "20220806",
		"url": "https://cn.bing.com/th?id=OHR.theBeginningofAutumn2022_ZH-CN9413449297_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
		"copyright": "杭州西湖的古典中国园林 (© DANNY HU/Getty Images)",
		"title": "贴秋膘了吗?",
		"id": 140,
		"local": "https://cdn.tsinbei.com/site/api/bing/140.jpg"
	}
}

获取指定月份的图片:

html
https://api.tsinbei.com/bing/?date=2023-04
https://api.tsinbei.com/bing/?date=2023-04

正确参数返回示例:

json
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"images": [{
			"date": "20230401",
			"url": "https://cn.bing.com/th?id=OHR.JavaBromo_ZH-CN2744043733_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
			"copyright": "爪哇岛东部的婆罗摩火山,印度尼西亚 (© Bento Fotography/Getty Images)",
			"title": "这座缥缈的山在哪里?",
			"id": 365
		}, {
			"date": "20230402",
			"url": "https://cn.bing.com/th?id=OHR.HonaunauNP_ZH-CN4491662962_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
			"copyright": "大岛上的霍瑙瑙国家历史公园,夏威夷 (© Westend61/Getty Images)",
			"title": "追逐彩虹",
			"id": 366
		}, {
			"date": "20230403",
			"url": "https://cn.bing.com/th?id=OHR.RomanBridge_ZH-CN4699931052_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
			"copyright": "科尔多瓦的古罗马桥,西班牙 (© Jeremy Woodhouse/Getty Images)",
			"title": "这座古桥在哪呢?",
			"id": 367
		}]
	}
}
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"images": [{
			"date": "20230401",
			"url": "https://cn.bing.com/th?id=OHR.JavaBromo_ZH-CN2744043733_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
			"copyright": "爪哇岛东部的婆罗摩火山,印度尼西亚 (© Bento Fotography/Getty Images)",
			"title": "这座缥缈的山在哪里?",
			"id": 365
		}, {
			"date": "20230402",
			"url": "https://cn.bing.com/th?id=OHR.HonaunauNP_ZH-CN4491662962_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
			"copyright": "大岛上的霍瑙瑙国家历史公园,夏威夷 (© Westend61/Getty Images)",
			"title": "追逐彩虹",
			"id": 366
		}, {
			"date": "20230403",
			"url": "https://cn.bing.com/th?id=OHR.RomanBridge_ZH-CN4699931052_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
			"copyright": "科尔多瓦的古罗马桥,西班牙 (© Jeremy Woodhouse/Getty Images)",
			"title": "这座古桥在哪呢?",
			"id": 367
		}]
	}
}

空返回示例:

json
{
	"code": 404,
	"msg": "不存在此段时间内的图片",
	"data": null
}
{
	"code": 404,
	"msg": "不存在此段时间内的图片",
	"data": null
}

错误返回示例:

json
{
	"code": 500,
	"msg": "年份错误",
	"data": null
}
{
	"code": 500,
	"msg": "年份错误",
	"data": null
}

json
{
	"code": 500,
	"msg": "月份错误",
	"data": null
}
{
	"code": 500,
	"msg": "月份错误",
	"data": null
}

TIP

本服务为本站从 2022 年起每天收集当天 1 张每日一图而成,并且在持续更新,如果需要自己搭建,欢迎发邮件到 Bing [AT] TSINBEI [DOT] COM,我愿意直接将所有文件打包发给你,附带 cron 任务配置,配置完成后即可自行每日更新 1 张。

容易看出,本站的图片格式都是<ID>.jpg,我知道爬虫很容易全部爬走,但没必要爬来爬去,像小孩子一样,有必要吗?

1.2/ 直接引用

在 HTML 的<img>标签引用时,可以传入display参数(默认为false),如果为true则会重定向到图片地址:

html
https://api.tsinbei.com/bing/?display=1
https://api.tsinbei.com/bing/?display=1

图片示例

众所周知,浏览器会对同一页面中 URL 相同的资源进行缓存,因此在同一个页面中,可以在参数中再加上随机参数random:

html
https://api.tsinbei.com/bing/?display=1&random=114
https://api.tsinbei.com/bing/?display=1&random=514
https://api.tsinbei.com/bing/?display=1&random=1919
https://api.tsinbei.com/bing/?display=1&random=810
https://api.tsinbei.com/bing/?display=1&random=114
https://api.tsinbei.com/bing/?display=1&random=514
https://api.tsinbei.com/bing/?display=1&random=1919
https://api.tsinbei.com/bing/?display=1&random=810

2/ 随机图片

2.1/ 二次元头像

JSONAPI:

html
https://api.tsinbei.com/v2/image/acg/
https://api.tsinbei.com/v2/image/acg/

返回示例:

json
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"url": "https://cdn.tsinbei.com/img/avatar/acg/54.webp"
	}
}
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"url": "https://cdn.tsinbei.com/img/avatar/acg/54.webp"
	}
}

直接显示:

html
https://api.tsinbei.com/v2/image/acg/?display=1
https://api.tsinbei.com/v2/image/acg/?display=1

2.2/ 正方形随机图片

来自 Lorem Picsum,图片尺寸600x600,适合做博客文章的头图。

JSONAPI:

html
https://api.tsinbei.com/v2/image/gallery/
https://api.tsinbei.com/v2/image/gallery/

返回示例:

json
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"url": "https://cdn.tsinbei.com/img/thumbnail/6666.webp"
	}
}
{
	"code": 200,
	"msg": "获取成功",
	"data": {
		"url": "https://cdn.tsinbei.com/img/thumbnail/6666.webp"
	}
}

直接显示:

html
https://api.tsinbei.com/v2/image/gallery/?display=1
https://api.tsinbei.com/v2/image/gallery/?display=1

3/ 更多

服务申请😉

如需清北 API 提供更多 API 服务,可前往 爱发电 赞助,附上联系方式,方便后续沟通。 在使用过程中出现任何问题均可至 GitHub 反馈。