npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twitch-helper

v1.1.7

Published

A simple twitch api library that makes it easy to interact with kraken, helix, and other endpoints

Downloads

18

Readme

twitch-helper

downloads npm size License: MIT GitHub Stars

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


import TwitchHelper from "twich-helper";

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

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

Functions that require authentication

import TwitchHelper from "twich-helper";

const AuthenticatedApiHelper = new TwitchHelper({
    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

import TwitchHelper from "twich-helper";

const UnAuthenticatedApiHelper = new TwitchHelper({});

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")

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

  1. clone the repo with git clone https://github.com/DisStreamChat/twitch-helper.git
  2. cd into the repo with cd twitch-helper
  3. install dependencies with npm i
  4. create a .env file and add in the variables from the .env.sample file
  5. 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