Skip to content

strangeglyph/reweave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reweave - Shardbound REST Api interface

This is a simple async rest library for shardbound for java and related JVM languages

Usage

To use the api, you'll need an application id (provided by the Spiritwalk team on request, as I've been told), and an access token. The access token can be retrieved via oauth, further information is again provided by the folks over at Spiritwalk.

Once you have these two bits of information, create a PublicApiConnection. Calls on this class are ratelimited to be nice to the shardbound servers (by default a rate of 10 requests/second with a 100 request burst). To implement this, the class has a backing thread pool. Remember to close this once you don't need to use it anymore (For this purpose, PublicApiConnection is auto-closeable)

Kotlin example:

PublicApiConnection(applicationId = myApplicationId, accessToken = myAccessToken).use {
    val future = it.oauth.verifyCredentials() // Wait for ratelimit
    val userId = future.get().userId!!
    println("User id: $userId")
    val matchHistory = it.user.getMatchHistory(userId).get()
    println("Match history: $matchHistory")
}

Java version:

try (PublicApiConnection conn = new PublicApiConnection(myApplicationId, myAccessToken)) {
    Future<LoginResult> future = conn.getOauth().verifyCredentials();
    String userId = future.get().getUserId();
    if (userId == null) throw new RuntimeException("No user id passed in login result");
    System.out.println("User id: " + userId);
    List<Game> matchHistory = conn.getUser().getMatchHistory(userId).get();
    System.out.println("Match history: " + matchHistory);
}

Maven

Coming soon, I hope

About

A shardbound rest api library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages