| Crates.io | wallhaven-rs |
| lib.rs | wallhaven-rs |
| version | 0.2.3 |
| created_at | 2025-11-23 13:57:01.406404+00 |
| updated_at | 2026-01-06 17:29:50.981792+00 |
| description | An api wrapper for wallhaven.cc |
| homepage | https://github.com/im-trisha/wallhaven-rs |
| repository | https://github.com/im-trisha/wallhaven-rs |
| max_upload_size | |
| id | 1946590 |
| size | 117,982 |
A wallhaven api wrapper. I found just CLIs and such on cargo, so I might as well create one for my project
This crate was for a short period known as wallhaven-api, I then did a complete overhaul and now the code is actually nice!
First, you must create a WallhavenClient:
let api_key = std::env::var("WALLHAVEN_API_KEY").unwrap();
let client = WallhavenClient::with_key(api_key)?;
This will create a WallhavenClient that will either run with or without api key. You could as well just:
let client = WallhavenClient::new();
// Or
let client = WallhavenClient::with_key("SomeApiKeyIDoNotSuggestHardcoding");
The client has the following functions, and for more details you may check out the documentation of that function/returned model:
wallpaper(id: impl AsRef<str>) - Fetches a wallpaper by idsearch(params: Option<SearchRequest>) - Searches for wallpapers, using the specific SearchRequestcollections(username: Option<String>) - Searches for the collections of either the current user if the api key is provided (None), or some user (Some("username"))collection_items(username: impl AsRef<str>, id: u64, params: Option<CollectionItemsRequest>) - Gets the collection items for a certain user/collection, with optional search querytag(id: u64) - Fetches a tag's detailsuser_settings(&self) - Fetches the current user's settingsdownload_wallpaper(&WallpaperDetails|&Wallpaper) - Gets a stream of bytes to download that wallpaperdownload_thumbnail(thumbnail: &Thumbnails, resolution: ThumbnailResolution) - Gets a stream of bytes to download a thumbnail with a certain resolution