npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wallhaven-client

v1.2.0

Published

wallhaven.cc HTTP Client

Downloads

7

Readme

wallhaven-client

npm-version

wallhaven.cc HTTP Client

Table of Contents

API

Name | Arguments | Returns | Description :--- | :--- | :--- | :--- 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 file | Download single image login | {user, pass, ...options} | cookie string | Login 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

Parameter | Value :- | :- q | any search term, or tag id id:853, @username, type:{png/jpg/jpeg} categories | see below purity | see below resolutions | 1920x1080 or 1920x1080,1920x1200 atleast | 1920x1080 ratios | 16x9 or 16x9,16x10 colors | 660000, 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 sorting | relevance, random, date_added, views, favorites, toplist topRange | 1d, 3d, 1w, 1M, 3M, 6M, 1y, only available for sorting=toplist order | desc, asc page | any number ...options | agent, timeout (any request-compose option)


Parameter / Value | 000 | 100 | 010 | 001 | 111 :- | :-: | :-: | :-: | :-: | :-: categories | none | general | anime | people | all purity | none | sfw | sketchy | nsfw | all

+ 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

Parameter | Value :- | :- id | Wallpaper ID ...options | agent, timeout (any request-compose option)


image

Parameter | Value :- | :- id | Wallpaper ID size | 'thumb' or 'full' (defaults to thumb) ext | 'jpg' or 'png' (defaults to jpg) location | Download location (defaults to process.cwd) ...options | agent, timeout (any request-compose option)


login

Parameter | Value :- | :- user | Username pass | Password ...options | agent, timeout (any request-compose option)


favorites

Parameter | Value :- | :- id | Collection ID page | any number cookie | Session cookie ...options | agent, 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]