{"id":19517485,"url":"https://github.com/ivkos/wallhaven4j","last_synced_at":"2025-04-26T06:31:22.537Z","repository":{"id":11771239,"uuid":"64857526","full_name":"ivkos/wallhaven4j","owner":"ivkos","description":"Wallhaven API for Java","archived":false,"fork":false,"pushed_at":"2022-09-01T22:20:32.000Z","size":255,"stargazers_count":18,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T09:11:18.595Z","etag":null,"topics":["android","java","jitpack","parsing","wallhaven","wallpaper"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivkos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-03T15:33:47.000Z","updated_at":"2024-05-31T16:08:34.000Z","dependencies_parsed_at":"2022-09-19T22:13:15.053Z","dependency_job_id":null,"html_url":"https://github.com/ivkos/wallhaven4j","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkos%2Fwallhaven4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkos%2Fwallhaven4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkos%2Fwallhaven4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkos%2Fwallhaven4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivkos","download_url":"https://codeload.github.com/ivkos/wallhaven4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250944121,"owners_count":21511697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","java","jitpack","parsing","wallhaven","wallpaper"],"created_at":"2024-11-11T00:03:57.778Z","updated_at":"2025-04-26T06:31:21.119Z","avatar_url":"https://github.com/ivkos.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wallhaven4j\n\n[![Release](https://jitpack.io/v/com.ivkos/wallhaven4j.svg)](https://jitpack.io/#com.ivkos/wallhaven4j)\n[![Build Status](https://travis-ci.org/ivkos/wallhaven4j.svg?branch=master)](https://travis-ci.org/ivkos/wallhaven4j)\n[![codecov](https://codecov.io/gh/ivkos/wallhaven4j/branch/master/graph/badge.svg)](https://codecov.io/gh/ivkos/wallhaven4j)\n\n**wallhaven4j** is a Java library that allows you to search for wallpapers on [Wallhaven](https://alpha.wallhaven.cc) and access its resources - wallpapers, collections, tags, and users.\n\n## Requirements\n* JRE 7 or higher at runtime\n* JDK 8 or higher to compile the library from source\n\n## Installation\n### Gradle\n**Step 1.** Add the JitPack repository to your root `build.gradle` at the end of repositories:\n```\nallprojects {\n    repositories {\n      ...\n      maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\n**Step 2.** Add the dependency:\n```\ndependencies {\n    compile 'com.ivkos:wallhaven4j:1.3.0'\n}\n```\n\n### Maven\n**Step 1.** Add the JitPack repository to your `pom.xml` file:\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n**Step 2.** Add the dependency:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.ivkos\u003c/groupId\u003e\n    \u003cartifactId\u003ewallhaven4j\u003c/artifactId\u003e\n    \u003cversion\u003e1.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Documentation\n\nJavadocs can be found [here](https://jitpack.io/com/ivkos/wallhaven4j/1.3.0/javadoc/).\n\n## Quick Start\n\n**Important note:** This library works by parsing the HTML of Wallhaven. Site design can change unexpectedly and potentially break the library, so until a fix is pushed you are advised to handle `ParseException`s gracefully at any Wallhaven operation. See *Exception Handling* below for more information.\n\n### Creating a Wallhaven session\n```java\n// anonymous session\nWallhaven wh = new Wallhaven();\n\n// log in with your wallhaven account\nWallhaven wh = new Wallhaven(\"USERNAME\", \"PASSWORD\");\n\n// log in with account and save session cookies to reuse later\nWallhaven wh = new Wallhaven(\"USERNAME\", \"PASSWORD\", new File(\"/path/to/cookies.json\"));\n```\n\n### Searching\nTo search for wallpapers you need to first build a `SearchQuery` like so, and then use the `search(...)` methods of the `Wallhaven` object:\n```java\nSearchQuery query = new SearchQueryBuilder()\n            .keywords(\"cars\", \"bmw\")\n            .categories(Category.GENERAL)\n            .purity(Purity.SFW)\n            .sorting(Sorting.VIEWS)\n            .order(Order.DESC)\n            .resolutions(new Resolution(1920, 1080), new Resolution(1280, 720))\n            .ratios(new Ratio(16, 9))\n            .pages(3)\n            .build();\n    \nList\u003cWallpaper\u003e carWallpapers = wh.search(query);\n```\n\nIf a filter is omitted, its default value will be used. Default values are defined in `SearchQueryDefaults`.\n```java\nSearchQuery query = new SearchQueryBuilder()\n            .keywords(\"minimal\")\n            .categories(Category.GENERAL)\n            .ratios(new Ratio(9, 16))\n            .pages(3)\n            .build();\n            \nList\u003cWallpaper\u003e minimalWallpapers = wh.search(query);\n```\n\nIf your application needs to fetch individual pages on demand, for example when doing lazy loading, you can do this like so:\n```java\nSearchQuery query = new SearchQueryBuilder()\n            .keywords(\"face\")\n            .categories(Category.PEOPLE)\n            .sorting(Sorting.FAVORITES)\n            .build();\n\n// fetch individual pages\nList\u003cWallpaper\u003e page1 = wh.search(query, 1);\nList\u003cWallpaper\u003e page3 = wh.search(query, 3);\n```\n\n### Getting Resources by ID\nGetting resources by their IDs is easy with the methods of the `Wallhaven` object:\n\n```java\nTag nature = wh.getTag(37);\n```\n\n```java\nUser gandalf = wh.getUser(\"Gandalf\");\n```\n\n```java\nWallpaper doggo = wh.getWallpaper(254637);\n```\n\n```java\nWallpaperCollection wc = wh.getWallpaperCollection(\"Gandalf\", 2);\n```\n\n### Exception Handling\n**wallhaven4j** parses Wallhaven's HTML. As a consequence, parsing may break if Wallhaven changes its design. It is recommended to be prepared to handle gracefully such cases. wallhaven4j has the following exception hierarchy:\n\n* `WallhavenException`\n    - `ConnectionException` - problem with the HTTP connection to Wallhaven\n    - `LoginException` - logging in to Wallhaven was unsuccessful due to incorrect credentials\n    - `ParseException` - problem parsing Wallhaven's HTML\n    - `ResourceNotAccessibleException` - the requested resource cannot be accessed due to privacy or purity restrictions\n    - `ResourceNotFoundException` - the requested resource cannot be found\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivkos%2Fwallhaven4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivkos%2Fwallhaven4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivkos%2Fwallhaven4j/lists"}