接口地址
https://www.vxras.com/api/v1/bing
请求方式
GET接口描述
此API接口支持获取必应搜索首页的每日精美图片,可指定获取天数范围、图片分辨率,并返回完整的图片信息(包括版权说明、故事背景等)。
请求参数
| 参数名 | 类型 | 必填 | 位置 | 默认值 | 示例值 | 说明 |
|---|---|---|---|---|---|---|
format | string | 否 | 自动 | img | - | 输出格式img:直接返回图片 json:返回JSON数据 |
time | string | 否 | 自动 | - | - | 指定日期 格式:YYYY-MM-DD(如:2023-11-10) |
num | integer | 否 | 自动 | 1 | - | 获取数量 1-8(必应接口限制最多8张) |
请求头
| Header名 | 值 | 必填 | 说明 |
|---|
返回示例
{
"code": 200,
"message": "success",
"data": {
"count": 1,
"images": [
{
"url": "https:\/\/cn.bing.com\/th?id=OHR.AloeDichotoma_ZH-CN4432972312_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
"copyright": "夜晚的箭袋树与银河,基特曼斯胡普,纳米比亚 (© Wim van den Heever\/naturepl.com)",
"copyrightlink": "https:\/\/www.bing.com\/search?q=%E7%AE%AD%E8%A2%8B%E6%A0%91&form=hpcapt&mkt=zh-cn",
"title": "星光下的颤动之树",
"startdate": "20251112",
"enddate": "20251113"
}
]
}
}在线测试
代码示例
curl -X GET "https://www.vxras.com/api/v1/bing"?format=img&time=&num=1<?php
$url = "https://www.vxras.com/api/v1/bing";
$data = array(
"format" => "img",
"time" => "",
"num" => "1"
);
$headers = array(
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>// 使用 Fetch API
const url = "https://www.vxras.com/api/v1/bing";
const data = {
"format": "img",
"time": "",
"num": "1"
};
const options = {
method: "GET",
headers: {
},
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));# 使用 requests 库
import requests
url = "https://www.vxras.com/api/v1/bing"
data = {
"format": "img",
"time": "",
"num": "1"
}
headers = {
}
response = requests.get(url, params=data, headers=headers)
print(response.json())响应码
| 响应码 | 说明 |
|---|---|
data.images | 图片信息 |
data.images.url | 图片链接 |
data.images.copyright | 版权信息 |
data.images.copyrightlink | 版权跳转地址 |
data.images.title | 标题 |
data.images.startdate | 开始时间 |
data.images.enddate | 结束时间 |
错误码
| 错误码 | 说明 |
|---|---|
200 | 成功 |
400 | 参数错误 |
404 | 未找到图片 |
500 | 服务器错误 |