Skip to content

Latest commit

 

History

History
112 lines (80 loc) · 2.72 KB

DOCUMENTATION.md

File metadata and controls

112 lines (80 loc) · 2.72 KB

Documentation

basic usage

const TwitchIO = require('twitchio-js');

const TwitchApi = new TwitchIO({
    clientId: process.env.client_id,
    authorizationKey: process.env.authorization_key
})

const cheerMotes = await TwitchApi.getCheerMotes()
const userInfo = await TwitchApi.getUserInfo("codinggarden")
// do something with the cheermotes and user info

Functions that require authentication

const TwitchIO = require('twitchio-js');

const AuthenticatedApiHelper = new TwitchIO({
    clientId: process.env.client_id,
    authorizationKey: process.env.authorization_key
})

get moderators for a channel

const moderators = await AuthenticatedApiHelper.getUserModerators("alca")

get user info from helix

// get user info by username
const userInfo = await AuthenticatedApiHelper.getUserInfo("codinggarden");

// get user info by id
const userInfo = await AuthenticatedApiHelper.getUserInfo("413856795");

get user info from kraken

coming soon

get custom channel badges by username

const channelBadges = await AuthenticatedApiHelper.getBadgesByUsername("instafluff");

refresh a refresh token

  1. set the client secret on the helper

const copiedAuthenticatedApiHelper = AuthenticatedApiHelper.copy;
copiedAuthenticatedApiHelper.clientSecret = process.env.client_secret;
const refreshData = await copiedAuthenticatedApiHelper.refreshToken("refresh token");
  1. input the client secret in the function call

const refreshData = await AuthenticatedApiHelper.refreshToken("refresh token", process.env.client_secret);

get cheermotes

// get global cheermotes
const cheermotes = await copiedAuthenticatedApiHelper.getCheerMotes();

// get global cheermotes along with custom channel cheermotes
const customCheermotes = await copiedAuthenticatedApiHelper.getCheerMotes("413856795");

Functions that do not require authentication

const TwitchIO = require('twitchio-js');

const UnAuthenticatedApiHelper = new TwitchIO({});

get channel badges by id

const channelBadges = await UnAuthenticatedApiHelper.getBadgesById("413856795");

get global message badges

const globalBadges = await UnAuthenticatedApiHelper.getGlobalBadges()

get bttv emotes for a channel (includes global bttv emotes)

const {bttvEmotes, bttvRegex} = await UnAuthenticatedApiHelper.getBttvEmotes("codinggarden")

get ffz emotes for a channel (includes global ffz emotes)

const { ffzEmotes, ffzRegex } = await UnAuthenticatedApiHelper.getFfzEmotes("codinggarden")

get the channels a user moderates for

const channelsIModerate = await UnAuthenticatedApiHelper.getUserModerationChannels("dav1dsnyder404")