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.
MyWaifuWrapper/README.md

142 lines
5.4 KiB
Markdown

3 years ago
[maven-central]: https://img.shields.io/maven-central/v/me.goudham/MyWaifuWrapper
[build-status]: https://img.shields.io/github/checks-status/sgoudham/MyWaifuWrapper/main
[codecov]: https://codecov.io/gh/sgoudham/MyWaifuWrapper/branch/main/graph/badge.svg?token=RxUDnCWnF0
3 years ago
3 years ago
![maven-central]
![build-status]
![codecov]
3 years ago
<h1 align="center">MyWaifuWrapper</h1>
<h2 align="center">An Unofficial Asynchronous Java API Wrapper for MyWaifuList</h2>
3 years ago
3 years ago
# Summary
3 years ago
This is an Unofficial Asynchronous API Wrapper for [MyWaifuList](https://mywaifulist.moe/dash)
3 years ago
3 years ago
# Disclaimer
3 years ago
3 years ago
Given that MyWaifuList is a primarily user-driven website and this API is currently in an Alpha state,
3 years ago
the data returned **may not be** fully complete and at its best quality
3 years ago
3 years ago
# Configuration
3 years ago
There are 2 ways to create and configure the [MyWaifuClient](https://github.com/sgoudham/MyWaifuWrapper/blob/main/src/main/java/me/goudham/MyWaifuClient.java)
3 years ago
+ `createDefault(apiKey)`
+ `build()`
3 years ago
## createDefault()
3 years ago
3 years ago
`createDefault(apiKey)` will provide a default implementation and return a MyWaifuClient ready to be used. Only
the `apiKey` is required to instantiate MyWaifuClient.
3 years ago
```java
public class Main {
private static void main(String[] args) {
MyWaifuClient myWaifuClient = MyWaifuClient.createDefault("apiKey");
}
}
```
3 years ago
## build()
3 years ago
`build()` is used to build the object from the ground up, allowing for the fine-tuning of properties within the
3 years ago
MyWaifuClient. Not all the additional properties need to specified within the builder. However, the bare minimum would be
3 years ago
the `apiKey` within the Builder constructor and then `.build()`
3 years ago
```java
import me.goudham.MyWaifuClient;
import java.net.http.HttpClient;
import java.time.Duration;
public class Main {
private static void main(String[] args) {
3 years ago
// Bare Minimum Config
// (Would recommend using createDefault())
3 years ago
MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey").build();
3 years ago
// Creation Through Builder
3 years ago
MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey")
.withVersion(HttpClient.Version.HTTP_2)
.withConnectTimeout(Duration.ofMinutes(10))
.build();
}
}
```
# Usage
3 years ago
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](https://mywaifulist.docs.stoplight.io/api-reference)
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:
```java
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();
3 years ago
FilteredWaifu randomWaifu = randomWaifuResponse.getModel();
3 years ago
// 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();
}
}
```
3 years ago
3 years ago
# Installation
3 years ago
3 years ago
Latest Stable Version: ![maven-central]
<p>Be sure to replace the <b>VERSION</b> key below with the one of the versions shown above!</p>
3 years ago
**Maven**
```xml
<!-- https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper -->
<dependency>
<groupId>me.goudham</groupId>
<artifactId>MyWaifuWrapper</artifactId>
<version>VERSION</version>
</dependency>
```
**Gradle**
```gradle
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper
implementation group: 'me.goudham', name: 'MyWaifuWrapper', version: 'VERSION'
}
```
3 years ago
## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_large)