Skip to main content

Welcome and thanks for using Twitch4J!

Please check out the Installation page to install the Twitch4J dependency.

After that the Client-Builder will show you how to create a Twitch4J Instance.

Now you'r ready to check out a few example projects:


Many modules can generate events which you can handle in some way, like PubSub, Chat, ...

For a list of available events / information on how to listen to events please check out: Events

API Calls

This API Client provides you 3 methods to handle / process the results of api calls.

Synchronous Execution

You can execute any api call synchronously with the execute() method, as shown in the following example:

UserList users = twitchClient.getHelix().getUsers(null, null, Arrays.asList("twitch4j")).execute();

Asynchronous Execution

You can execute any api call asynchronously with the queue() method, as shown in the following example:

Future<UserList> users = twitchClient.getHelix().getUsers(null, null, Arrays.asList("twitch4j")).queue();

You can retrieve the result of the async method at any time by calling .get() on the future, for example: users.get().

For more information on how you can work with Future please check out this guide:

Reactive Execution

You can also observe the results of any api call as an Observable by using one of the following methods:

  • observe() — returns a “hot” Observable that executes the command immediately, though because the Observable is filtered through a ReplaySubject you are not in danger of losing any items that it emits before you have a chance to subscribe
  • toObservable() — returns a “cold” Observable that won’t execute the command and begin emitting its results until you subscribe to the Observable
Observable<UserList> users = twitchClient.getKraken().getUsers(null, null, Arrays.asList("twitch4j")).observe();

You then retrieve the value of the command by subscribing to the Observable:

users.subscribe(data -> {
// your code to work with the result data