UNPKG

twitch-toolkit

Version:

A set of tools to integrate with Twitch API, Twitch Chat and Twitch WebHooks.

1,535 lines (467 loc) β€’ 23.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>TwitchApi - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TwitchApi.html">TwitchApi</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#auth">auth</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#getGames">getGames</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#getStreams">getStreams</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#getStreamsMetadata">getStreamsMetadata</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#getUsers">getUsers</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#getUsersFollows">getUsersFollows</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#getVideos">getVideos</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchApi.html#updateUser">updateUser</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TwitchChatEmitter.html">TwitchChatEmitter</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchChatEmitter.html#connect">connect</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TwitchWebSub.html">TwitchWebSub</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchWebSub.html#destroy">destroy</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchWebSub.html#subscribe">subscribe</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchWebSub.html#topicStreamUpDownSubscribe">topicStreamUpDownSubscribe</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchWebSub.html#topicUserFollowsSubscribe">topicUserFollowsSubscribe</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="TwitchWebSub.html#unsubscribe">unsubscribe</a></span></li><li class="nav-heading">Events</li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="TwitchChatEmitter.html#event:Chat:chat_cmd_COMMAND">Chat:chat_cmd_COMMAND</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="TwitchChatEmitter.html#event:Chat:chat_parsed">Chat:chat_parsed</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="TwitchChatEmitter.html#event:Chat:whisper_cmd_COMMAND">Chat:whisper_cmd_COMMAND</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="TwitchWebSub.html#event:WebSub:stream_up_down">WebSub:stream_up_down</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="TwitchWebSub.html#event:WebSub:user_follows">WebSub:user_follows</a></span></li> </nav> <div id="main"> <h1 class="page-title">TwitchApi</h1> <section> <header> <h2> TwitchApi </h2> </header> <article> <div class="container-overview"> <div class="section-method"> <h4 class="name" id="TwitchApi"><span class="type-signature"></span>new TwitchApi<span class="signature">(config)</span><span class="type-signature"></span></h4> <div class="description"> <p>Twitch API</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line12">line 12</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>config</code></td> <td class="type"> <span class="param-type"><code>object</code></span> </td> <td class="description last"> <p>The configuration object to access the API.</p> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>client_id</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="description last"> <p>The client_id to be used to access the API.</p> </td> </tr> <tr> <td class="name"><code>client_secret</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="description last"> <p>The secret to be used to access the API that requires login. If this is not provided, the restricted methods will thrown an error.</p> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> </div> <h3 class="subsection-title">Methods</h3> <div class="section-method"> <h4 class="name" id="auth"><span class="type-signature"></span>auth<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>Authenticate the current user and get the access token to be used in the private calls.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line173">line 173</a> </li></ul></dd> </dl> <div class="section-returns"> <h5>Returns:</h5> <div class="param-desc"> <p>The access token.</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="getGames"><span class="type-signature"></span>getGames<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Gets a Twitch game information by game ID or name. For a query to be valid, name and/or id must be specified. This method requires no authentication.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line41">line 41</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><code>object</code></span> </td> <td class="description last"> <p>The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-games</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-games</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="getStreams"><span class="type-signature"></span>getStreams<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Gets information about active streams. Streams are returned sorted by number of current viewers, in descending order. Across multiple pages of results, there may be duplicate or missing streams, as viewers join and leave streams. This method requires no authentication.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line60">line 60</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><code>object</code></span> </td> <td class="description last"> <p>The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="getStreamsMetadata"><span class="type-signature"></span>getStreamsMetadata<span class="signature">(token)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Gets metadata information about active streams playing Overwatch or Hearthstone. Streams are sorted by number of current viewers, in descending order. Across multiple pages of results, there may be duplicate or missing streams, as viewers join and leave streams.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line78">line 78</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>token</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="description last"> <p>The users token.</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams-metadata</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="getUsers"><span class="type-signature"></span>getUsers<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Gets information about one or more specified Twitch users. Users are identified by optional user IDs and/or login name. If neither a user ID nor a login name is specified, the user is looked up by Bearer token.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line100">line 100</a> </li></ul></dd> <dt class="tag-todo">To Do:</dt> <dd class="tag-todo"> <ul> <li>add optional scope</li> </ul> </dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><code>object</code></span> </td> <td class="description last"> <p>The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="getUsersFollows"><span class="type-signature"></span>getUsersFollows<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Gets information on follow relationships between two Twitch users. Information returned is sorted in order, most recent follow first. This can return information like &quot;who is lirik following,&quot; &quot;who is following lirik,” or β€œis user X following user Y.” This method requires no authentication.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line119">line 119</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><code>object</code></span> </td> <td class="description last"> <p>The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users-follows</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users-follows</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="getVideos"><span class="type-signature"></span>getVideos<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Gets video information by video ID (one or more), user ID (one only), or game ID (one only). This method requires no authentication.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line138">line 138</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><code>object</code></span> </td> <td class="description last"> <p>The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-videos</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-videos</p> </div> </div> </div> <div class="section-method"> <h4 class="name" id="updateUser"><span class="type-signature"></span>updateUser<span class="signature">(description)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;Object>>}</span></h4> <div class="description"> <p>Updates the description of the authenticated user. This method requires authentication.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="twitchApi.js.html">twitchApi.js</a>, <a href="twitchApi.js.html#line157">line 157</a> </li></ul></dd> </dl> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>description</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="description last"> <p>The description to be added to the channel.</p> </td> </tr> </tbody> </table> <div class="section-returns"> <h5>Returns:</h5> <dl class="param-type"> <dt> Type: </dt> <dd> <span class="param-type"><code>Promise.&lt;Array.&lt;Object>></code></span> </dd> </dl> <div class="param-desc"> <p>The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-videos</p> </div> </div> </div> </article> </section> </div> <br class="clear"> <footer> Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 05 2018 22:52:28 GMT-0300 (E. South America Standard Time) using the Minami theme. </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>