An Unofficial Asynchronous Java API Wrapper for MyWaifuList
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Hammy 0f89db74da Update To Version 1.0.0 & Disable autoRelease 3 years ago
.github Create dependabot.yml 3 years ago
src Add sad path test for ObjectMapper & Add test for betaSearch 3 years ago
.gitignore Add .gitignore 4 years ago
Dockerfile Simplify Dockerfile 3 years ago
Jenkinsfile Update Stage Name 3 years ago
LICENSE Initial commit 4 years ago
README.md Update README.md 3 years ago
pom.xml Update To Version 1.0.0 & Disable autoRelease 3 years ago

README.md

fossa license maven-central build-status codecov issues pull-requests

MyWaifuWrapper

An Asynchronous Java API Wrapper for MyWaifuList

Summary

This is an Unofficial Asynchronous API Wrapper for MyWaifuList

Disclaimer

Given that MyWaifuList is a primarily user-driven website and this API is currently in an Alpha state, the data returned may not be fully complete and at its best quality

Configuration

There are 2 ways to create and configure the MyWaifuClient

  • createDefault(apiKey)
  • build()

createDefault()

createDefault(apiKey) will provide a default implementation and return a MyWaifuClient ready to be used. Only the apiKey is required to instantiate MyWaifuClient.

public class Main {
    private static void main(String[] args) {
        MyWaifuClient myWaifuClient = MyWaifuClient.createDefault("apiKey");
    }
}

build()

build() is used to build the object from the ground up, allowing for the fine-tuning of properties within the MyWaifuClient. Not all the additional properties need to specified within the builder. However, the bare minimum would be the apiKey within the Builder constructor and then .build()

import me.goudham.MyWaifuClient;

import java.net.http.HttpClient;
import java.time.Duration;

public class Main {
    private static void main(String[] args) {
        // Bare Minimum Config 
        // (Would recommend using createDefault())
        MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey").build();
        
        // Creation Through Builder
        MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey")
                .withVersion(HttpClient.Version.HTTP_2)
                .withConnectTimeout(Duration.ofMinutes(10))
                .build();
    }
}

Usage

Once MyWaifuClient has been configured properly, many methods are available for you to get the data that you wish. Each method links up to an endpoint that is listed within the MyWaifuList API Docs

With every method executed from the MyWaifuClient, a Response object will be returned. The object will house the type of entity, response status code, and the response body. This allows for extreme flexibility as the raw response and marshalled entity are available to the user.

The documentation for each method provides clear and detailed information on what arguments to pass in, please do also refer to that.

Shown below are some examples of how you can retrieve data:

public class Main {
    public static void main(String[] args) throws APIMapperException, APIResponseException {
        // ... myWaifuClient has been instantiated
        
        // getWaifu(Integer id) 
        Response<Waifu> waifuResponse = myWaifuClient.getWaifu(7);
        Integer waifuResponseCode = waifuResponse.getStatusCode();
        String waifuResponseBody = waifuResponse.getBody();
        Waifu waifu = waifuResponse.getModel();
        
        // getRandomWaifu()
        Response<FilteredWaifu> randomWaifuResponse = myWaifuClient.getRandomWaifu();
        Integer randomWaifuResponseCode = randomWaifuResponse.getStatusCode();
        String randomWaifuResponseBody = randomWaifuResponse.getBody();
        FilteredWaifu randomWaifu = randomWaifuResponse.getModel();
        
        // getSeasonalAnime()
        Response<List<FilteredSeries>> seasonalAnimeResponse = myWaifuClient.getSeasonalAnime();
        Integer seasonalAnimeResponseStatusCode = seasonalAnimeResponse.getStatusCode();
        String seasonalAnimeResponseBody = seasonalAnimeResponse.getBody();
        List<FilteredSeries> seasonalAnime = seasonalAnimeResponse.getModel();
    
        // getUserWaifus(Integer id, WaifuListType waifuListType, Integer pageNum)
        Response<PaginationData<FilteredWaifu>> userWaifusLikedResponse = myWaifuClient.getUserWaifus(1, WaifuListType.LIKED, 1);
        Integer userWaifusLikedResponseStatusCode = userWaifusLikedResponse.getStatusCode();
        String userWaifusLikedResponseBody = userWaifusLikedResponse.getBody();
        PaginationData<FilteredWaifu> userWaifusLiked = userWaifusLikedResponse.getModel();
    }
}

Installation

Latest Stable Version: maven-central

Be sure to replace the **VERSION** key below with the one of the versions shown above!

Maven

<!-- https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper -->
<dependency>
    <groupId>me.goudham</groupId>
    <artifactId>MyWaifuWrapper</artifactId>
    <version>VERSION</version>
</dependency>

Gradle

repositories {
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper
    implementation group: 'me.goudham', name: 'MyWaifuWrapper', version: 'VERSION'
}

License

FOSSA Status