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

icehawk

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icehawk

Twitch API Helper

  • 1.0.9
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Twitch API Helper

The goal of Icehawk is to simplify calls to the Twitch.tv API. The public repo for this project can be found at GitLab.

Two API calls are needed to know if a stream is online and for gathering channel information. This module allows you to use a .twitch() method - passing in an array of twitch user names - and returns all the data you would get had you made API calls to the streams and channels endpoints.

Additionally, the returned data object contains named, streamer objects for easy access to a streamer's data.

// example
{
  monstercat: {
    channel: { ... },
    stream: { ... },
    status: 'online'
  }
}

Installation

npm install --save icehawk

Usage

// app.js
const Icehawk = require('icehawk')

// 24/7 music streamers
const streamers = [
  'monstercat',
  'nocopyrightsounds'
]

Icehawk.twitch(streamers)
  .then(data => {
    // see how the data is structured
    console.dir(data)

    // iterate over each streamer and get their data
    streamers.forEach(streamer => {

      // data contains named objects matching streamer's name
      const { channel, stream, status } = data[streamer]
    })
  })

I recommend setting up webpack to create a bundle.js file as the entry point into your app.

Simple Webpack Setup

npm install -g webpack webpack-dev-server

In the project's root folder, create webpack.config.js and index.html

// webpack.config.js
module.exports = {
  entry: './app.js',
  output: {
    path: __dirname,
    filename: 'bundle.js'
  }
}
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <p>Open the developer's console and reload this page to see the output.</p>
  <script src="bundle.js"></script>
</body>
</html>

At the prompt in a terminal of the project's root folder, type

$ webpack-dev-server --inline

This will start a local web server at http://localhost:8080 that will auto reload the page when app.js is saved with changes.

FAQs

Package last updated on 24 Apr 2016

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