All Projects → twitch-js → Twitch Js

twitch-js / Twitch Js

Licence: mit
A community-centric, community-supported version of tmi.js

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Twitch Js

Bigq
Messaging platform in C# for TCP and Websockets, with or without SSL
Stars: ✭ 18 (-92%)
Mutual labels:  broadcast, messaging, message, websocket
Discord4j
Discord4J is a fast, powerful, unopinionated, reactive library to enable quick and easy development of Discord bots for Java, Kotlin, and other JVM languages using the official Discord Bot API.
Stars: ✭ 973 (+332.44%)
Mutual labels:  api, bot, websocket
Broid Kit
Bot framework powered by Broid
Stars: ✭ 58 (-74.22%)
Mutual labels:  api, bot, messaging
Twitchlib
C# Twitch Chat, Whisper, API and PubSub Library. Allows for chatting, whispering, stream event subscription and channel/account modification. Supports .NET Core 2.0
Stars: ✭ 519 (+130.67%)
Mutual labels:  api, bot, twitch
Jda
Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Stars: ✭ 2,598 (+1054.67%)
Mutual labels:  api, bot, websocket
Actionhero
Actionhero is a realtime multi-transport nodejs API Server with integrated cluster capabilities and delayed tasks
Stars: ✭ 2,280 (+913.33%)
Mutual labels:  api, websocket
Mellow
Mellow can communicate with several APIs like Ombi, Sonarr, Radarr and Tautulli which are related to home streaming to use those services directly in your Discord client.
Stars: ✭ 193 (-14.22%)
Mutual labels:  api, bot
Aegis.cpp
Discord C++ library for interfacing with the API. Join our server:
Stars: ✭ 198 (-12%)
Mutual labels:  api, bot
Venom
Venom is the most complete javascript library for Whatsapp, 100% Open Source.
Stars: ✭ 3,457 (+1436.44%)
Mutual labels:  bot, message
Linebot
🤖 SDK for the LINE Messaging API for Node.js
Stars: ✭ 184 (-18.22%)
Mutual labels:  api, messaging
Messenger4j
A Java library for building Chatbots on the Facebook Messenger Platform - easy and fast.
Stars: ✭ 199 (-11.56%)
Mutual labels:  api, bot
Node Fb Messenger
✉️ Facebook Messenger Platform Node.js API Wrapper
Stars: ✭ 206 (-8.44%)
Mutual labels:  api, bot
Sogebot
sogeBot - Free Twitch Bot built on Node.js
Stars: ✭ 190 (-15.56%)
Mutual labels:  bot, twitch
Node Instagram
Instagram api client for node that support promises.
Stars: ✭ 185 (-17.78%)
Mutual labels:  api, stream
Node Vk Bot Api
🤖 VK bot framework for Node.js, based on Bots Long Poll API and Callback API.
Stars: ✭ 195 (-13.33%)
Mutual labels:  api, bot
Bot Connector
Bot Connector allows you to connect your bot to multiple messaging channels.
Stars: ✭ 185 (-17.78%)
Mutual labels:  api, bot
Pajbot
Twitch moderation bot
Stars: ✭ 198 (-12%)
Mutual labels:  bot, twitch
Mercure
Server-sent live updates: protocol and reference implementation
Stars: ✭ 2,608 (+1059.11%)
Mutual labels:  api, websocket
Watsontcp
WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
Stars: ✭ 209 (-7.11%)
Mutual labels:  api, messaging
Twitch4j
Modular Async/Sync/Reactive Twitch API Client / IRC Client
Stars: ✭ 209 (-7.11%)
Mutual labels:  api, twitch

TwitchJS

Build status Coverage status NPM version NPM downloads GitHub issues GitHub bug issues

A community-centric, community-supported Twitch JavaScript SDK.

Features

  • Aligns with official Twitch IRC documentation
  • Forward-compatible, low-level, minimally-assertive architecture
  • Supports Node environments
  • Supports Browsers
  • Supports TypeScript
  • Connect to multiple channels
  • Chat commands
  • Rate limiter

In progress...

Here are the planned features. If you feel something is missing, create an issue or submit a PR against the next branch.

Documentation

  1. Getting started
  2. Authentication
  3. Examples
  4. Interacting with Twitch chat
  5. Making requests to Twitch API
  6. Reference

Getting started

Module bundler (CJS/ESM)

If you are using a module bundler, such Webpack, Browserify, or a in a Node environment:

  1. Add TwitchJS to your project:

    npm install --save twitch-js
    
  2. Import TwitchJS

    // ES2015 syntax
    import TwitchJs from 'twitch-js'
    
    // OR ES5 syntax
    var TwitchJs = require('twitch-js')
    
    const twitchJs = new TwitchJs({ username, token })
    

Browser (IIFE)

If you are not using a module bundler, precompiled builds are available in the dist folder:

  1. Include a script tag in your HTML:
    <script src="//unpkg.com/[email protected]>2.0.0-beta.31"></script>
    
  2. Consume the library:
    <script type="javascript">
      const twitchJs = new window.TwitchJs({ username, token })
    </script>
    

Authentication

Obtaining a client ID

To obtain a client ID, follow the instructions found in the Twitch Developers documentation.

Obtaining a token

With a client ID, tokens may be generated on behalf of your users.

To quickly get started without a client ID, you may generate token using the following, community-maintained, sites:

  1. Twitch Chat OAuth Password Generator (Kraken/v5)
  2. Twitch Token Generator (Helix)

Refreshing tokens

While, Kraken/v5 tokens currently do not expire, Helix tokens expire and will need to be refreshed.

To help with refreshing tokens, an onAuthenticationFailure function may be provided to the Messaging and API clients. onAuthenticationFailure() must return a Promise that resolves with the refreshed token. Upon resolution, any actions that yielded a an expired token response will be retried with the new, refreshed token.

Handling token refresh example

// Optionally, use fetchUtil to help.
import fetchUtil from 'twitch-js/lib/utils/fetch'

const refreshToken = 'eyJfaWQmNzMtNGCJ9%6VFV5LNrZFUj8oU231/3Aj'
const clientId = 'fooid'
const secret = 'barbazsecret'

const onAuthenticationFailure = () =>
  fetchUtil('https://id.twitch.tv/oauth2/token', {
    method: 'post',
    search: {
      grant_type: 'refresh_token',
      refresh_token: refreshToken,
      client_id: clientId,
      client_secret: clientSecret,
    },
  }).then((response) => response.accessToken)

const token = 'cfabdegwdoklmawdzdo98xt2fo512y'
const username = 'ronni'
const twitchJs = new TwitchJs({ token, username, onAuthenticationFailure })

twitchJs.chat.connect().then((globalUserState) => {
  // Do stuff ...
})

See Refreshing access tokens for more information.

More information

See the Twitch Developers documentation for more information on authentication.

Examples

Examples are provided via CodeSandbox:

Contribution guidelines

If you wish to contribute, please see the CONTRIBUTING doc.

Special thanks

Schmoopiie and all the original contributors of tmi.js.

License

MIT

TwitchJS is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Twitch, or any of its subsidiaries or its affiliates. The name "Twitch" as well as related names, marks, emblems and images are registered trademarks of Twitch.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].