twitch-helper
This library provides function that make it easy to do things related to the twitch api including but not limited to the helix api, the kraken api, the bttv api, and the ffz api. at its most basic this library wraps twitch api credentials with the fetch function so you don't have to pass them in everytime, but it also has functions that get data from different api endpoints for you with basic inputs.
Support
This project is a part of DisStreamChat. Whether you use this project, another DisStreamChat project, have learned something from it, or just like it, please consider supporting it by becoming a patreon, so we can dedicate more time on more projects like this 😀.
Documentation
basic usage
; const ApiHelper = clientId: processenvclient_id authorizationKey: processenvauthorization_key const cheerMotes = await ApiHelperconst userInfo = await ApiHelper// do something with the cheermotes and user info
Functions that require authentication
; const AuthenticatedApiHelper = clientId: processenvclient_id authorizationKey: processenvauthorization_key
get moderators for a channel
const moderators = await AuthenticatedApiHelper
get user info from helix
// get user info by usernameconst userInfo = await AuthenticatedApiHelper; // get user info by idconst userInfo = await AuthenticatedApiHelper;
get user info from kraken
coming soon
get custom channel badges by username
const channelBadges = await AuthenticatedApiHelper;
refresh a refresh token
- #### set the client secret on the helper
const copiedAuthenticatedApiHelper = AuthenticatedApiHelpercopy;copiedAuthenticatedApiHelperclientSecret = processenvclient_secret;const refreshData = await copiedAuthenticatedApiHelper;
- #### input the client secret in the function call
const refreshData = await AuthenticatedApiHelper;
get cheermotes
// get global cheermotesconst cheermotes = await copiedAuthenticatedApiHelper; // get global cheermotes along with custom channel cheermotesconst customCheermotes = await copiedAuthenticatedApiHelper;
Functions that do not require authentication
; const UnAuthenticatedApiHelper = {};
get channel badges by id
const channelBadges = await UnAuthenticatedApiHelper;
get global message badges
const globalBadges = await UnAuthenticatedApiHelper
get bttv emotes for a channel (includes global bttv emotes)
const bttvEmotes bttvRegex = await UnAuthenticatedApiHelper
get ffz emotes for a channel (includes global ffz emotes)
const ffzEmotes ffzRegex = await UnAuthenticatedApiHelper
get the channels a user moderates for
const channelsIModerate = await UnAuthenticatedApiHelper
Contributing
Found a bug? Want a new feature? Don't like the docs? Please create a pull request or raise an issue.
Raising issues
When raising an issue, please add as much details as possible. Screenshots, video recordings, or anything else that can make it easier to reproduce the bug you are reporting.
- A new option is to create a code pen with the code that causes the bug. Fork this example and add your code there, then fork and add the new link to the issue.
Installation
- clone the repo with
git clone https://github.com/DisStreamChat/twitch-helper.git
- cd into the repo with cd twitch-helper
- install dependencies with
npm i
- create a
.env
file and add in the variables from the.env.sample
file - run
npm run build-tests
in order to transpile the typescript and run tests
- run
npm build
to transpile the typescript - run
npm start
to execute the transpiled typescript - run
npm test
to run tests on the transpiled typescript