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

twitchrequest

v1.4.9

Published

Get Twitch requests for streams, especially when a stream goes live or stops streaming

Downloads

1,382

Readme

What is Twitch Requests?

Twitch Requests is basically an advanced EventEmitter which adds a 'live' listener and 'unlive' listener. It can be used to detect if a streamer has gone live

Installation

npm install twitchrequest

const { Client } = require('twitchrequest');

const options = {
    // The channels you are listening to (all in lowercase)
    channels: ["destiall"],

    // Your client ID
    client_id: "your client id",

    // Your client secret
    client_secret: "your client secret",

    // The interval it will check (in seconds)
    interval: 3
};
const client = new Client(options);

client.on('live', (data) => {
    console.log(`${data.name} is now live! Streaming ${data.title} on ${data.game}! Started at ${data.date}`);
});

Events

This event is called when a channel included in the options goes live.

client.on('live', (streamData) => {
    // Do stuff
});

This event is called when a channel included in the options stops streaming.

client.on('unlive', (streamData) => {
    // Do stuff
});

This event is called when a user follows a channel EXPERIMENTAL.

client.on('follow', (userData, streamData) => {
    // userData is the user that followed
    // streamData is the StreamData that the user followed to
});

This event is called every interval set in the options.

client.on('debug', (streamData) => {
    // Do stuff
});

If you want subscription events or chat events, use npm i tmi.js instead!

Methods

This method can be used to get a specific StreamData of a channel.

const streamData = await client.getStream('username');
// Do stuff

This method can be used to get a specific UserData of a channel.

const userData = await client.getUser('username');
// Do stuff

This method can be used to add a channel to the list of channels to listen to.

client.addChannel('username');

This method can be used to remove a channel from the list of channels to listen to.

client.removeChannel('username');

This method can be used check if that channel is already in the list of channels to listen to.

client.includesChannel('username');

Types

// Example StreamData
StreamData {
  raw: {
    broadcaster_language: 'en',
    display_name: 'destiall',
    game_id: '509658',
    id: '142326619',
    is_live: true,
    tag_ids: [ '6ea6bca4-4712-4ab9-a906-e3336a9d8039' ],
    thumbnail_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/d555c2b8-fe43-4863-9e6f-78f5052eef41-profile_image-300x300.png',
    title: 'coding stream',
    started_at: '2020-12-22T08:29:53Z'
  },
  name: 'destiall',
  title: 'coding stream',
  game: 'Just Chatting',
  thumbnail: 'https://static-cdn.jtvnw.net/previews-ttv/live_user_destiall-320x180.jpg',
  profile: 'https://static-cdn.jtvnw.net/jtv_user_pictures/d555c2b8-fe43-4863-9e6f-78f5052eef41-profile_image-300x300.png',
  date: 2020-12-22T08:29:53.000Z,
  viewers: 1
}

// Example UserData
UserData {
  raw: {
    id: '47454325',
    login: 'dextimo',
    display_name: 'Dextimo',
    type: '',
    broadcaster_type: 'affiliate',
    description: "Hi i'm Dextimo, I love pandas, Formula 1 and  occasionally cod zombies.Btw tomatoes are disgusting :)",
    profile_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/8d9dd056-177f-43f2-966d-5c83d09a0e88-profile_image-300x300.png',
    offline_image_url: '',
    view_count: 977,
    created_at: '2013-08-11T20:17:02.073455Z'
  },
  name: 'dextimo',
  description: "Hi i'm Dextimo, I love pandas, Formula 1 and  occasionally cod zombies.Btw tomatoes are disgusting :)",
  id: '47454325',
  profile: 'https://static-cdn.jtvnw.net/jtv_user_pictures/8d9dd056-177f-43f2-966d-5c83d09a0e88-profile_image-300x300.png',
  views: 977,
  type: 'affiliate',
  created: 2013-08-11T20:17:02.073Z
}