Skip to content

An asynchronous java wrapper for interaction with the Twitch New API - Helix

License

Notifications You must be signed in to change notification settings

Mirimas/Java-Twitch-Api-Helix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Async Twitch New API Wrapper

Build Status Codacy Badge Download

Async Twitch New API Wrapper is a asynchronous java wrapper for interaction with API of the Twitch New API.

Currently support:

  • users
  • users follows
  • streams
  • games

Please feel free to report any issues or contribute code.

Basics

Using the wrapper is as simple as instantiating the Twitch object and then calling the appropriate endpoint functions.

For example, a GET /streams/featured request would map to the twitch.streams().getFeatured() function; and GET /users/mirrobot would map to twitch.users().get("mirrobot").

Responses are handled via callbacks passed via a handler with each function call. This process is outlined in the following examples.

Basic Example

Twitch twitch = new Twitch();
twitch.setClientId(clientId);
twitch.auth().setAccessToken(accessToken);

twitch.users().get(new UsersResponseHandler() {
    @Override
    public void onSuccess(final Users users) {
        User user = users.getData().get(0);
        System.out.println("User: " + user.getLogin());
    }

    @Override
    public void onFailure(int statusCode, String statusMessage, String errorMessage) {
        /* Twitch API responded with an error message */
    }

    @Override
    public void onFailure(Throwable e) {
        /* Unable to access Twitch, or error parsing the response */
    }
});

Explicitly Setting Access Token

If you already have an access token, you can explicitly set it. This should not be done prior to an application being distributed as the access token is directly linked to a single Twitch account.

twitch.auth().setAccessToken("my-access-token");

Documentation

  • The Twitch API documentation will best explain the functionality of each endpoint.

Dependencies

Thanks

Inspired by Java-Twitch-Api-Wrapper.