Minimal Java wrapper for waifu.pics, nekos.life, hmtai and custom services.
For Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.eme22</groupId>
<artifactId>anime-image-api</artifactId>
<version>0.9.4</version>
</dependency>
For Gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.eme22:anime-image-api:0.9.4'
}
Get a random image from waifu endpoint in sfw
category
AnimeImageClient client = new AnimeImageClient();
return client.getWaifuEndPoint(Endpoints.WAIFU_SFW.WAIFU);
Get a random image from neko endpoint
AnimeImageClient client = new AnimeImageClient();
return client.getNekosEndPoint(Endpoints.NEKO.WAIFU);
Get a random image from hmtai endpoint
AnimeImageClient client = new AnimeImageClient();
return client.getHMEndPoint(Endpoints.HM_SFW.NEKO);
try {
AnimeImageClient client = new AnimeImageClient();
Image image = client.downloadWaifuImage(Endpoints.WAIFU_SFW.WAIFU);
OutputStream os = new FileOutputStream(image.filename);
os.write(image.buffer);
os.close();
} catch (Exception ignored) {}
try {
AnimeImageClient client = new AnimeImageClient();
Image image = client.downloadNekosImage(Endpoints.NEKO.WAIFU);
OutputStream os = new FileOutputStream(image.filename);
os.write(image.buffer);
os.close();
} catch (Exception ignored) {}
try {
AnimeImageClient client = new AnimeImageClient();
Image image = client.downloadHMImage(Endpoints.HM_SFW.NEKO);
OutputStream os = new FileOutputStream(image.filename);
os.write(image.buffer);
os.close();
} catch (Exception ignored) {}
Register a random image endpoint with custom url and json path
AnimeImageClient AnimeImageClient = new AnimeImageClient();
Endpoint endpoint = new Endpoint();
endpoint.setName("custom");
endpoint.setBaseUrl("http://localhost:8080/api/v1/image?type=%s&category=%s");
endpoint.setResponseJsonPath("$.data.url");
endpoint.setResponseJsonPathRegex(true);
Category category = new Category();
category.setName("waifu");
category.setNsfw(false);
category.setPaths(Arrays.asList("sfw","waifu"));
endpoint.setCategories(Collections.singleton(category));
AnimeImageClient.registerEndPoint(endpoint);
Get a random image from custom endpoint in waifu
category
AnimeImageClient client = new AnimeImageClient();
return client.getImage("custom", "waifu");