Movatterモバイル変換


[0]ホーム

URL:


wonderful-bing-wallpaper
TypeScript icon, indicating that this package has built-in type declarations

0.3.4 • Public • Published

wonderful-bing-wallpaper

GitHub starsnpmGitHub issuesGitHub last commitlicense

NPM

🌅 Simple bing daily wallpaper API lib for Node.js. 极简的 Node.js 版必应壁纸 API 库。

  • 简单:1 个接口
  • 稳定:与 Bing 同在
  • 轻巧:不依赖任何第三方

Credit

stackoverflow - Is there a way to get Bing's photo of the day?

Example

Usage

npm i wonderful-bing-wallpaper --save
const WonderfulBingWallpaper = require('wonderful-bing-wallpaper')
 
// get support resolutions list
const resolutions = WonderfulBingWallpaper.getResolutions()
 
// instance
const wbw = new WonderfulBingWallpaper({ /* options */ })
 
// update default options
wbw.setOptions({ /* options */ })
 
// get daily wallpapers
wbw.getWallpapers({ /* params */ }).then(wallpaperJSON => {
  console.log('got wallpaperJSON data', wallpaperJSON)
  console.log('got humanizeWallpapers data - Array', wbw.humanizeWallpapers(wallpaperJSON))
  console.log('got humanizeWallpapers data - Object', wbw.humanizeWallpapers(wallpaperJSON[0]))
})

API

new WonderfulBingWallpaper(options?: object): instance

wbw.setOptions(options?: object)

@returnWonderfulBingWallpaper instance

recommended option field(推荐设置的字段)

paramstyperequireddefaultdesc
sizeNumberfalse1how many images - 几张图片size <= 8
dayNumberfalse0how days before - 往前推几天day <= 7
formatStringfalsejsresult data format - 返回数据的格式js/xml/rss
localStringfalseen-USyour location - 你想拿到什么语言的版本(国内zh-CN

not recommended option field(非必要情况不要设置的字段)

paramstyperequireddefaultdesc
ensearchnumberfalse00 / 1
1 则查询全量数据,包括如图片描述、故事、封面文字...开启后会被强制切换为全英文(实际 bing 拿的美版数据)
hostStringfalsewww.bing.combing wallpaper api host
你想在哪个服务器拿数据(国内cn.bing.com
wallpaperApiStringfalse/HPImageArchive.aspxbing wallpaper api path
如果哪天 Bing 改接口了你可以手动设置一下
resolutionStringfalse1920x1200humanizeWallpapers second param default resolution
使用humanizeWallpapers 方法时第二参数的默认值

wbw.getWallpapers(params?: object): array

@return wallpaper array

the same as option fields.


wbw.humanizeWallpapers(wallPapers: object | array, resolution?: string): object | array

@return humanized wallpaper data.

{
  ...wallpaper,
  humanizedCopyrightUrlstring,
  humanizedSearchUrlstring,
  humanizedImageUrlstring,
  humanizedResolutionUrlstring
}
paramstyperequireddefaultdesc
wallPapersArray/Objecttruenullwallpaper images
图片或多张图片
resolutionStringfalse{instance}.options.resolutionwallpaper resolution
要输出的图片地址里的分辨率

Dev

yarnyarn devyarn lintyarn testyarn buildnpm run test

License

MIT

Package Sidebar

Install

npm i wonderful-bing-wallpaper

Weekly Downloads

4

Version

0.3.4

License

MIT

Unpacked Size

27.7 kB

Total Files

9

Last publish

Collaborators

  • surmon

[8]ページ先頭

©2009-2025 Movatter.jp