Skip to content

swanis/builtbybit-java-api-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

builtbybit logo

jitpack

builtbybit-java-api-wrapper

This is a complete and easy-to-use Java wrapper for the BuiltByBit Ultimate API built with Java SE Development Kit 17.0.1.

Sending a request

Client client = new Client(new Token("TOKEN STRING", Token.Type.PRIVATE));
Response<Member> response = client.sendOrWait(new RetrieveYourselfRequest());

//client.send(new RetrieveYourselfRequest()) also works, but in that case you'd have to handle eventual ratelimits yourself with the help of our built-in methods (response.isRatelimited() and response.getMillisecondsToWait()).

if (response.getError() == null) {
    Member member = response.getValue();
    System.out.println(member.getUsername());
} else {
    Error error = response.getError();
    System.out.println(error.getCode() + ": " + error.getMessage());
}

A list of requests along with their expected response types can be found here.

Sorting

Sorting is possible by passing a SortOptions object into the constructor of supported requests (simply pass null if you don't care about sorting).

//Example printing the 20 top-purchased resources.
Client client = new Client(new Token("TOKEN STRING", Token.Type.PRIVATE));
Response<BasicResource[]> response = client.sendOrWait(new ListPublicResourcesRequest(new SortOptions("purchase_count", Order.DESCENDING, 1)));

if (response.getError() == null) {
    BasicResource[] resources = response.getValue();

    for (BasicResource resource : resources) {
        System.out.println(resource.getTitle());
    }
} else {
    Error error = response.getError();
    System.out.println(error.getCode() + ": " + error.getMessage());
}

Sortable fields can be found at the official API documentation here.

Jitpack Installation

Gradle

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.swanis:builtbybit-java-api-wrapper:VERSION'
}

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.swanis</groupId>
    <artifactId>builtbybit-java-api-wrapper</artifactId>
    <version>VERSION</version>
</dependency>