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

simple-helix-api

v4.1.7

Published

The Simple Helix API allows developers to easily develop applications for Twitch

Downloads

178

Readme

About

simple-helix-api is a package needed to simplify working with the Twitch API.

The library was created following the Twitch API documentation as much as possible. All requests are divided into categories for ease of use. Below is a list of current categories supported by package.

analytics, automod, channel, chat, clips, commercial, events, games, markers, moderation, other, polls, predictions, rewards, schedule, search, streams, subscriptions, tags, teams, users, videos

In addition, some requests that are associated with a list of something (a list of users, categories, clips, etc.) have one request in order to get a complete list.

Navigation

Installation

npm:

npm install simple-helix-api

or using yarn:

yarn add simple-helix-api

Usage

Before we starting, be sure you have client_id registered in Dev Dashboard on Twitch.

Access Token

First, you need for Access Token provided by Twitch. With this package you can generate link to the endpoint that returns Access Token to you. If you already have, then skip this step.

const HelixAPI = require("simple-helix-api"); // you can use import

// Create client
const Helix = new HelixAPI({
    client_id: "xxxxxxx" // client_id from Twitch Dev Dashboard
});

// List of scopes you need for your application. Left it empty to request all scopes. See scopes list: https://dev.twitch.tv/docs/authentication#scopes
const scopes = ["chat:read", "channel:manage:predictions", "moderation:read"];

// Redirect uri must match to specified in Twitch Dev Dashboard
const redirect_uri = "http://localhost...";

// Generate auth link
const link = Helix.getAuthLink(scopes, redirect_uri);
console.log(link);

Now you can use this package on full power.

Example

Let's look at a basic example of working with package. In this example, we will get and output user information to the console.

Almost all requests requires an user ID. Get yours, store it and use everywhere.

Attetion! All requests and categories names matches with Twitch API documentation, but recommended to use autocomplete of your favorite code editor to see all categories and requests.

const HelixAPI = require("simple-helix-api");

const Helix = new HelixAPI({
    access_token: "xxxxxxx", // Your personal Access Token provided by Twitch. If you don't have one, see step above.
    client_id: "xxxxxxx" // Client ID from Twitch Dev Dashboard
});

(async () => {
    const user = await Helix.users.get("InfiniteHorror"); // Also you can specify user ID instead of user login
    console.log(user);
})();

More examples

There is a several examples of requests you can use with this package. Be aware that some requests requires additional parameters, so check the official documentation on the Twitch Dev Portal.

Update stream title and category

const game = await Helix.games.get("League of Legends");
const updated = await Helix.channel.modify(user_id, game.id, "en", "Title has been changed with simple-helix-api");

Start commercial

await Helix.commercial.start(user_id, 30);

Update chat settings

await Helix.chat.updateSettings(user_id, {
    follower_mode: true,
    follower_mode_duration: 10
});

Ban user

const user = await Helix.users.get("anyToxicPerson");
await Helix.moderation.ban(user_id, {
    user_id: user.id,
    reason: "Friendship is Magic"
});

Get all followers of channel

const followers = await Helix.users.allFollows(user_id);
console.log(followers);

Get all clips of channel

The time of response depends on count of clips of your channel.

const clips = await Helix.clips.all(user_id);
console.log(clips);

Contribution

Sometimes I may miss some changes in the Twitch API, so I will be glad of any help. Feel free to fork and share PR's.

You can report of any issues here.