twitch-rank

1.0.4 • Public • Published

Twitch Rank 🚀

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

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

Package Sidebar

Install

npm i twitch-rank

Weekly Downloads

2

Version

1.0.4

License

ISC

Unpacked Size

12.7 kB

Total Files

6

Last publish

Collaborators

  • juliogarciape