Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twitchonlinetracker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitchonlinetracker

A library to help track streamers and fires an event if they go online.

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Track when Twitch streams go online

Quickstart

Install: npm install --save twitchonlinetracker

Get a Client ID. See Step 1 of the Twitch API Introduction on how to do this.

const { TwitchOnlineTracker } = require('twitchonlinetracker')
const tracker = new TwitchOnlineTracker({
  client_id: "your twitch app client id", // used for api requests
  track: ['channel1', 'channel2'], // all the channels you want to track
  pollInterval: 30, // how often in between polls in seconds. default 30
  debug: true, // whether to debug to console
  start: true // whether to start immediately. if you don't use this, you must call .start() later
})

// Listen to live event, it returns StreamData
tracker.on('live', streamData => {
  console.log(`${streamData.user_name} just went live!`)
})

// Make sure you listen for errors
tracker.on('error', error => console.error)

NOTE: If you don't pass start: true in the options, you must call tracker.start() to start polling.

TwitchOnlineTracker API

const tracker = new TwitchOnlineTracker(options: TwitchOnlineTrackerOptions)

Create a new TwitchOnlineTracker instance. It takes a TwitchOnlineTrackerOptions interface:

  • client_id string required Your Twitch app's client id
  • track string[] An array of the channels you wish to track on startup
  • pollInterval number The amount of time in seconds between polls
  • debug boolean If true, output debug information to console
  • start boolean If true, start polling immediately

tracker.start()

Starts polling the Twitch API for stream changes.

tracker.stop()

Stops polling the Twitch API for stream changes.

tracker.track(usernamesToTrack: string[])

Adds more streams to track. usernamesToTrack expects an array of strings.

tracker.untrack(usernamesToUntrack: string[])

Stops tracking streams. usernamesToTrack expects an array of strings.

tracker.on('live', function (streamData: StreamData) { })

When a stream is found to be live, fires this event. The callback function provides a StreamData parameter.

Example:

tracker.on('live', function (streamData) {
  console.log(`${streamData.user_name} has started streaming with the title ${streamData.title} at https://twitch.tv/${streamData.user_name} for ${streamData.viewer_count} viewers!`)
})

tracker.on('error', function (error) { })

Fires this event on error. Make sure you capture this event.

Example:

tracker.on('error', function (error) {
  throw Error(error)
})

Keywords

FAQs

Package last updated on 27 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc