The Base Class, Functions and Exceptions¶
Below you can find an information about the base class.
- class aiowallhaven.api.WallHavenAPI(api_key)¶
API key is a key given to you by https://wallhaven.cc.
HTTP Method “GET”¶
- async aiowallhaven.api.WallHavenAPI._get_method(self, url) Dict¶
Make an async GET request to https://wallhaven.cc
- Parameters
url – URL for the new
aiohttp.ClientSessionobject.- Returns
- class
JSON object
Functions¶
- async aiowallhaven.api.WallHavenAPI.get_wallpaper(self, wallpaper_id: str)¶
Get the details about wallpaper with given id.
- Parameters
wallpaper_id – a string representing a unique id assigned to the wallpaper.
- Returns
- class
JSON object
- async aiowallhaven.api.WallHavenAPI.search(self, q=None, categories: Optional[list] = None, purity: Optional[list] = None, sorting: Optional[str] = None, order: Optional[str] = None, toprange: Optional[str] = None, atleast: Optional[str] = None, resolutions: Optional[Union[str, list]] = None, ratios: Optional[Union[str, list]] = None, colors: Optional[Union[str, int, list]] = None, page: Optional[str] = None, seed: Optional[str] = None)¶
- Perform search through Wallhaven. If no additional parameters are set the search will display the latest SFW wallpapers.
- param q
Search query. Your main way of finding what you’re looking for.
- param categories
(optional) Turn categories on(1) or off(0).
- param purity
(optional) Turn purities on(1) or off(0).
- param sorting
(optional) Method of sorting results.
- param order
(optional) Sorting order. Default order is desc.
- param toprange
(optional) Sorting MUST be set to ‘toplist’.
- param atleast
(optional) Minimum resolution allowed.
- param resolution
(optional) List of exact wallpaper resolutions. Single resolution is allowed.
- param color
(optional) Search by color.
- param page
(optional) Pagination. Not actually infinite
- param seed
(optional) seed for random results. Example: [a-zA-Z0-9]{6}.
- Returns
- class
JSON object
- async aiowallhaven.api.WallHavenAPI.get_tag(self, tag: int)¶
Return the information about a specific tag.
- Parameters
tag – an integer associated with with a tag.
- Returns
- class
JSON object
- async aiowallhaven.api.WallHavenAPI.my_settings(self)¶
Return the user’s settings. No arguments are accepted.
- Returns
- class
JSON object
- async aiowallhaven.api.WallHavenAPI.get_collections(self, username: Optional[str] = None, collection_id: Optional[int] = None, purity: Optional[list] = None)¶
- Allows the user to see their own or public collection.
- param username
an optional argument allowing the user to check other users’ public collections.
- param collection_id
an optional argument to parse through user collection having the indicated ID.
- param purity
an optional argument to choose purity of returned results (i.e. sfw, sketchy, nsfw).
- Returns
- class
JSON object
Exceptions¶
- aiowallhaven.api_exception_reasons.TooManyRequests¶
alias of Too many requests to the server, please try again later
- aiowallhaven.api_exception_reasons.Unauthorized¶
alias of Invalid API key. Please provide a valid API key. You can regenerate your API key at https://wallhaven.cc/settings/account
- aiowallhaven.api_exception_reasons.GeneralError¶
alias of The request to open {session} failed with the following HTTP code: {status_code}
- aiowallhaven.api_exception_reasons.ValueErrorPurity¶
alias of No valid purity filter found. Only ‘sfw’, ‘sketchy’, and ‘nsfw’ are considered to be valid purity filters.
- aiowallhaven.api_exception_reasons.ValueErrorCategory¶
alias of No valid category filter found. Only ‘general’, ‘anime’, and ‘people’ are considered to be valid category filters.
- aiowallhaven.api_exception_reasons.ValueErrorSorting¶
alias of Invalid parameter was provided. Only “date_added”, “relevance”, “random”, “favorites”, “toplist” are considered to be valid arguments.
- aiowallhaven.api_exception_reasons.ValueErrorOrder¶
alias of Invalid order method was provided. Only ‘desc’ and ‘asc’ are considered to be valid arguments.
- aiowallhaven.api_exception_reasons.ValueErrorToprange¶
alias of Invalid parameter was provided. Only “1d”, “3d”, “1w”, “1M”, “3M”, “6M”, “1y” are considered to be valid arguments.
- aiowallhaven.api_exception_reasons.ValueErrorAtleast¶
alias of Invalid screen resolution was provided. Valid formats: “1920x1080”, “3080x2140” eg.