Skip to content

Modular Java wrapper for the BetterTTV API and WebSocket.

License

Notifications You must be signed in to change notification settings

iProdigy/bttv4j

Repository files navigation

BTTV4J

Latest Javadoc

Modular Java wrapper for BetterTTV's REST API and WebSocket interface.

REST API

BetterTTV api = BttvApiFactory.build();

// Obtain the global emotes
Collection<Emote> emotes = api.getGlobalEmotes();

// Query the emotes for a given channel
User user = api.getUser(Provider.TWITCH, "11785491");

// Query which users have BTTV badges for a given platform
Collection<BadgedUser> badges = api.getBadges(Provider.TWITCH);

WebSocket

// Establish websocket connection
BttvSocket ws = new BttvSocket();

// Prepare event handlers
ws.getEventManager().onEvent(EmoteCreateEvent.class, System.out::println);
ws.getEventManager().onEvent(EmoteUpdateEvent.class, System.out::println);
ws.getEventManager().onEvent(EmoteDeleteEvent.class, System.out::println);
ws.getEventManager().onEvent(UserUpdateEvent.class, System.out::println);

// Join channels
String channelId = "53888434", userId = "149223493";
ws.joinChannel(Provider.TWITCH, channelId);
ws.broadcastMe(Provider.TWITCH, channelId, userId);

Installation

This library is published to Maven Central in a modular format, so you can decide to only pull the REST API component or only pull the WebSocket component, depending on your use case.

<!-- For REST API -->
<dependency>
    <groupId>io.github.iprodigy.bttv</groupId>
    <artifactId>bttv4j-api</artifactId>
    <version>1.0.0</version>
</dependency>

<!-- For WebSocket Events -->
<dependency>
    <groupId>io.github.iprodigy.bttv</groupId>
    <artifactId>bttv4j-ws</artifactId>
    <version>1.0.0</version>
</dependency>

Notice

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with BetterTTV or NightDev, LLC. or Twitch Interactive.

All trademarks are property of their respective owners, and this project does not grant any rights to any trademarks.