1.2.0 • Published 5 years ago

wallhaven-client v1.2.0

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

wallhaven-client

npm-version

wallhaven.cc HTTP Client

Table of Contents

API

NameArgumentsReturnsDescription
search{q, categories, purity, resolutions, atleast, ratios, colors, sorting, topRange, order, page, ...options}{Object}Filter wallpapers
wallpaper{id, ...options}{Object}Get full meta data about wallpaper
image{id, size, ext, location, ...options}writes to fileDownload single image
login{user, pass, ...options}cookie stringLogin to Wallhaven
favorites{id, page, cookie, ...options}{Object}Get meta data about user's collections and the wallpapers in them
var wh = require('wallhaven-client')

;(async () => {
  var {count, total, pages, tags, wallpapers} = await wh.search({q: 'steampunk'})
  var meta = await wh.wallpaper({id: '527712'})
  await wh.image({id: '527712'})
  var cookie = await wh.login({user, pass})
  var {collections, wallpapers, pages} = await wh.favorites({cookie})
})()
{
  count: 24,
  total: 144,
  pages: 6,
  tags: [ { id: '874', name: 'steampunk', purity: 'sfw' } ],
  wallpapers: [
    { id: '102569',
      purity: 'sfw',
      category: 'general',
      resolution: '1920x1080',
      favorites: 243,
      urls:
       { page: 'https://alpha.wallhaven.cc/wallpaper/102569',
         thumb: 'https://alpha.wallhaven.cc/wallpapers/thumb/small/th-102569.jpg',
         full: 'https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-102569.jpg',
         short: 'https://whvn.cc/102569' } },
    { id: '1182',
      purity: 'sfw',
      category: 'general',
      resolution: '2560x1600',
      favorites: 123,
      urls:
       { page: 'https://alpha.wallhaven.cc/wallpaper/1182',
         thumb: 'https://alpha.wallhaven.cc/wallpapers/thumb/small/th-1182.jpg',
         full: 'https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-1182.jpg',
         short: 'https://whvn.cc/1182' } }
  ]
}
{
  id: '651423',
  resolution: '2000 x 1285',
  ratio: undefined,
  category: 'Anime',
  purity: 'sfw',
  size: '5.1 MiB',
  views: '700',
  favorites: '6',
  tags:
   [ { id: '1', name: 'anime', purity: 'sfw' },
     { id: '45595', name: 'Macross Delta', purity: 'sfw' },
     { id: '54814', name: 'Kaname Buccaneer', purity: 'sfw' },
     { id: '45559', name: 'Mikumo Guynemer', purity: 'sfw' },
     { id: '74518', name: 'Makina Nakajima', purity: 'sfw' },
     { id: '49846', name: 'Freyja Wion', purity: 'sfw' },
     { id: '74689', name: 'Reina Prowler', purity: 'sfw' },
     { id: '5063', name: 'Macross', purity: 'sfw' } ],
  colors: [ 'abbcda', 'cccccc', 'ffffff', '66cccc', '999999' ],
  source: 'https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65239432',
  uploader:
   { username: 'AksumkA',
     avatar: 'https://static.wallhaven.cc/images/user/avatar/32/2_82aff6c49745ac98ef5dda356aabed354de0f398c783ef8e9d4d8b734c283074.png',
     group: 'owner',
     profile: 'https://alpha.wallhaven.cc/user/AksumkA' },
  date: '2018-05-06T21:11:47+00:00',
  urls:
   { page: 'https://alpha.wallhaven.cc/wallpaper/651423',
     thumb: 'https://alpha.wallhaven.cc/wallpapers/thumb/small/th-651423.jpg',
     full: 'https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-651423.png',
     short: 'https://whvn.cc/651423' },
  ext: 'png'
}
{
  collections: [
    { id: '121373', name: 'Default', private: true, total: 40 },
    { id: '308194', name: 'Science', public: true, total: 9 } ],
  wallpapers: [
    { id: '703709',
      purity: 'sfw',
      category: 'general',
      resolution: '3353x1588',
      favorites: 129,
      urls:
       { page: 'https://alpha.wallhaven.cc/wallpaper/703709',
         thumb: 'https://alpha.wallhaven.cc/wallpapers/thumb/small/th-703709.jpg',
         full: 'https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-703709.jpg',
         short: 'https://whvn.cc/703709' } }
  ],
  pages: 2
}

Arguments

search

ParameterValue
qany search term, or tag id id:853, @username, type:{png/jpg/jpeg}
categoriessee below
puritysee below
resolutions1920x1080 or 1920x1080,1920x1200
atleast1920x1080
ratios16x9 or 16x9,16x10
colors660000, 990000, cc0000, cc3333, ea4c88, 993399, 663399, 333399, 0066cc, 0099cc, 66cccc, 77cc33, 669900, 336600, 666600, 999900, cccc33, ffff00, ffcc33, ff9900, ff6600, cc6633, 996633, 663300, 000000, 999999, cccccc, ffffff, 424153
sortingrelevance, random, date_added, views, favorites, toplist
topRange1d, 3d, 1w, 1M, 3M, 6M, 1y, only available for sorting=toplist
orderdesc, asc
pageany number
...optionsagent, timeout (any request-compose option)

Parameter / Value000100010001111
categoriesnonegeneralanimepeopleall
puritynonesfwsketchynsfwall

+ any combination


Note that currently there is no information on the search page about the actual file extension of the wallpaper. The urls.full key will always point to an image with .jpg file extension. The image download API however will retry to download the image with .png file extension if it fails with .jpg.

The search returns up to 24 wallpapers.


wallpaper

ParameterValue
idWallpaper ID
...optionsagent, timeout (any request-compose option)

image

ParameterValue
idWallpaper ID
size'thumb' or 'full' (defaults to thumb)
ext'jpg' or 'png' (defaults to jpg)
locationDownload location (defaults to process.cwd)
...optionsagent, timeout (any request-compose option)

login

ParameterValue
userUsername
passPassword
...optionsagent, timeout (any request-compose option)

favorites

ParameterValue
idCollection ID
pageany number
cookieSession cookie
...optionsagent, timeout (any request-compose option)

Examples

search / wallpaper / image / favorites

node examples/search.js [example index]
node examples/wallpaper.js [example index]
node examples/image.js [example index]
node examples/favorites.js [example index]
1.2.0

5 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago