Skip to content

Latest commit

 

History

History
95 lines (63 loc) · 3.72 KB

readme.md

File metadata and controls

95 lines (63 loc) · 3.72 KB

Wallhaven API for Python

pipeline status Coverage Status codecov Scrutinizer Code Quality Dependency Status

Feel free to add an issue.

Description

Implementation of https://wallhaven.cc/help/api (the official one)

Dependencies

# pip install -r requirements.txt

Quick Documentation

Import WallhavenApi package:

import wallhavenapi

Initialize WallhavenApi:

wallhaven_api= wallhavenapi.WallhavenApiV1()

If you have an account on Wallhaven, you can use api key to access all available wallpapers:

wallhaven_api = wallhavenapi.WallhavenApiV1(api_key="some_api_key")

Methods

WallhavenApiV1

  • api_key {String} - your Wallhaven api key
  • verify_connection {Bool} - check ssl cert
  • base_url {String} - Wallhaven base api url
  • timeout {Tuple(Int, Int)} - http request timeout
  • requestslimit_timeout {Tuple(Int, Int)} - try to handle 429 http error. The first Int - how many times to do request, the second - delay (in seconds) between requests.

WallhavenApiV1.search - Accessing Wallpaper information

  • q {String} - query (used to filter by user, tags, ids and so on...)
  • categories {String|List[String]} - walpaper category (located in wallhavenapi.Category)
  • purities {String|List[String]} - walpaper purity (located in wallhavenapi.Purity)
  • sorting {String} - how to sort results (located in wallhavenapi.Sorting)
  • order {String} - sort order (located in wallhavenapi.Order)
  • top_range {String} - sorting MUST be set to 'toplist' (located in wallhavenapi.TopRange)
  • atleast {Typle(Int,Int)} - minimum resolution
  • resolutions {Typle(Int,Int)|List[Typle(Int,Int)]} - exact wallpaper resolutions
  • ratios {Typle(Int,Int)|List[Typle(Int,Int)]} - aspect ratios
  • colors {String} - color to search (located in wallhavenapi.Color)
  • page {Int} - page for pagination

WallhavenApiV1.is_walpaper_exists - Check wallpaper existence by id

  • wallpaper_id {String} - wallpaper id (can be obtained by WallhavenApiV1.search)

WallhavenApiV1.download_wallpaper - Download wallpaper to file (or get data) by id

  • wallpaper_id {String} - wallpaper id (WallhavenApiV1.search)
  • file_path {String} - path to file
  • chunk_size {Int} - chunked buffer for downloading

WallhavenApiV1.tag - Get tag information

  • tag_id {String} - tag id (can be obtained by WallhavenApiV1.search)

WallhavenApiV1.settings - Get user settings

It works only if api_key is set

WallhavenApiV1.collections - get collections by user name

  • user_name {String} - user name

WallhavenApiV1.collection_wallpapers - get wallpapers by user collection id

  • user_name {String} - user name
  • collection_id {Int} - user collection id (can obtained by WallhavenApiV1.collections)
  • page {Int} - page

WallhavenApiV1.my_collections - get collections of api_key user

It works only if api_key is set