跳到主要内容

必应每日壁纸 API

接口说明

获取必应搜索首页每日更新的精美壁纸,支持多种分辨率,图片质量优秀,每日更新。适用于桌面壁纸、网站背景、应用展示等场景。

接口概览

项目说明
接口地址/images/bing/getWallpaper
请求方式GET
认证方式无需认证
响应格式image/*
更新频率每日更新

在线调试

快速测试

👉 点击这里 在浏览器中直接查看今日壁纸

使用 curl 调试:

# 下载图片
curl -o wallpaper.jpg "https://api.oofo.cc/images/bing/getWallpaper"

# 仅查看响应头
curl -I "https://api.oofo.cc/images/bing/getWallpaper"

请求说明

请求参数

本接口支持以下可选参数:

参数名类型必选说明
resolutionstring图片分辨率,可选值:1920x1080(默认)、1366x7683840x2160
formatstring图片格式,可选值:jpg(默认)、pngwebp

请求示例

# 获取 4K 分辨率的壁纸
GET /images/bing/getWallpaper?resolution=3840x2160

# 获取 WebP 格式的壁纸
GET /images/bing/getWallpaper?format=webp

响应说明

成功响应

  • 状态码: 200 OK
  • Content-Type: image/jpeg(默认)或其他请求的图片格式
  • Content-Length: 图片实际大小
  • Cache-Control: public, max-age=86400(缓存 24 小时)

错误响应

状态码: 404 Not Found

{
"code": 404,
"msg": "今日壁纸尚未更新"
}

代码示例

// 在 img 标签中使用
const imgElement = document.createElement('img');
imgElement.src = 'https://api.oofo.cc/images/bing/getWallpaper';
document.body.appendChild(imgElement);

// 下载图片
async function downloadWallpaper() {
try {
const response = await fetch('https://api.oofo.cc/images/bing/getWallpaper');
if (!response.ok) throw new Error('获取壁纸失败');

const blob = await response.blob();
const url = window.URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = `bing-wallpaper-${new Date().toISOString().split('T')[0]}.jpg`;
a.click();

window.URL.revokeObjectURL(url);
} catch (error) {
console.error('下载失败:', error);
}
}

使用建议

注意事项
  1. 图片每日更新一次,建议做好缓存
  2. 选择合适的分辨率以平衡加载速度和显示效果
  3. 注意处理图片加载失败的情况

最佳实践

  1. 缓存策略

    • 使用浏览器缓存或本地存储
    • 遵循响应头中的缓存指令
    • 在凌晨定时更新缓存
  2. 性能优化

    • 选择合适的图片格式和分辨率
    • 使用渐进式加载
    • 实现图片预加载
  3. 错误处理

    • 准备默认的备用图片
    • 添加加载状态提示
    • 实现失败重试机制

更新日志

版本日期描述
1.0.02024-02-11接口首次发布
1.1.02024-02-12添加分辨率和格式选项