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-rank

v1.0.4

Published

A Node JS library to get the most viewed Twitch streams sorted by viewers, category, country or language

Downloads

10

Readme

Twitch Rank :rocket:

A Node JS library to get the most viewed Twitch streams sorted by viewers, category, country or language :bar_chart:

Quick Links

Prerequisites

  1. Register an app on Twitch Developers and get the Client Id and Client secret.

  2. To initialize Twitch Rank you need the Client Id and App Access Token.

  3. To get the App Access Token you must make a POST request using the Client Id and Client Secret like here.

Getting Started

Install twitch-rank using npm:

$ npm install twitch-rank

Example Usage

const TwitchRank = require('twitch-rank');

// Initialize Twitch Rank with your credentials

const Twitch = new TwitchRank({
    clientId: "wbmytr93xzw8zbg0p1izqyzzc5mbiz",
    appAccessToken: "2gbdx6oar67tqtcmt49t3wpcgycthx"
});

// Search for streams based on your search filters

Twitch.rank({top: 3, language: "es", category: "Just Chatting"})
.then(streams => {
    console.log(streams) // {data: [{...},{...},{...}], length: 3}
    // The result will return an object with the 3 most viewed streams in descending order in Spanish with the Just Chatting category on Twitch.
});

Methods

rank ({ country, language, category, top })

Warning: You can add/remove any variable according to your preferences to get the streams you want, however you cannot declare "country" and "language" at the same time.

country (optional): String

Currently only 4 countries are available (Peru, Argentina, Colombia, Mexico) more countries will be added to the list weekly such as the USA, England, Brazil, Spain.

You can search for Twitch streams from each country using its two-letter code, see the list of countries with their respective standard code here.

Example

const TwitchRank = require('twitch-rank');

...

// Search for Twitch streams based on the country code that is available ("pe" = Peru)

Twitch.rank({country: "pe"})
.then(streams => {
    console.log(streams) // {data: [{...},{...},{...}]}
    // The result will return an object with the most popular broadcasts of Peruvian streamers on Twitch.
});

language (optional): String

...

Example

const TwitchRank = require('twitch-rank');

...

// Search Twitch streams based on the English language.

Twitch.rank({language: "en"})
.then(streams => {
    console.log(streams) // {data: [{...},{...},{...}]}
    // The result will return an object with the most popular broadcasts that Twitch has in the English language. 
});

category (optional): String

Categories are used to separate the content that is made during broadcasts on Twitch, each category is mostly separated into video games and you can filter your search for broadcasts simply by searching for the category you want.

Example

const TwitchRank = require('twitch-rank');

...

// Search for streams based on Twitch category (Valorant).

Twitch.rank({category: "Valorant"})
.then(streams => {
    console.log(streams) // {data: [{...},{...},{...}]}
    // The result will return an object with the most popular streams that have the "Valorant" category on Twitch.
});

top (optional): Int

You can also set the limit of Twitch streams you want to receive based on the number of viewers in descending order. The minimum value is 1 and the maximum value is 100.

Example

const TwitchRank = require('twitch-rank');

...

// Search the 25 most viewed streams on Twitch.

Twitch.rank({top: 25})
.then(streams => {
    console.log(streams) // {data: [{...},{...},{...}]}
    // The result will return an object with the 25 most viewed streams on Twitch.
});

Disclaimer

The list of streams you get are in descending order based on the current number of viewers. Because viewers come and go during a stream, it is possible to encounter duplicate or missing streams when returning a result. (Twitch Developers).

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Twitch or any of its subsidiaries or its affiliates. The official Twitch website can be found at https://www.twitch.tv/. "Twitch" as well as related names, marks, emblems and images are registered trademarks of their respective owners.

Feedback

I am new to developing libraries for npm, so the internal logic of the library will be updated with good practices and optimizations in the code.

Any ideas to improve Twitch Rank and implement new features will be accepted and if you want to contact me my personal email is available to everyone.

License

ISC