├── .gitignore ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ryan Barr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-streamelements 2 | An unofficial wrapper for the StreamElements API. 3 | 4 | **[Official StreamElements API Documentation](https://dev.streamelements.com)** 5 | 6 | ## Install 7 | Install the `node-streamelements` package from the NPM repository, using `--save` to update your `package.json`: 8 | 9 | ```bash 10 | npm install node-streamelements --save 11 | ``` 12 | 13 | ## API Reference 14 | Some calls require few, specific options and are required method arguments. More complex calls, such as `create` or `update` operations require more detailed options. Reference the official documentation for type requirements and object structure. 15 | 16 | ## Usage 17 | Import the package, create a new instance using your Account ID and JWT Token (found in your account profile), and call methods which return promises. 18 | 19 | ```javascript 20 | const StreamElements = require('node-streamelements'); 21 | 22 | const myInstance = new StreamElements({ 23 | token: 'YourJWTToken', 24 | accountId: 'YourAccountID' 25 | }); 26 | 27 | // Get current song in queue. 28 | myInstance 29 | .getCurrentSong() 30 | .then((response) => { 31 | console.log(`Current song is ${response.title}.`); 32 | }) 33 | .catch((error) => { 34 | console.log(error); 35 | }); 36 | ``` 37 | 38 | ## Using Unimplemented Endpoints 39 | In the event the API sees a non-major version bump which introduces new functionality, you may call `makeRequest()` directly until a new `node-streamelements` package version is available. 40 | 41 | ### Updating Third-party Channels 42 | Even though your current instance may be tied to a specific channel, you may optionally override the channel being requested upon by passing its ID into methods. For example: 43 | 44 | ```javascript 45 | myInstance 46 | .getCurrentSong('CHANNELID') 47 | .then((response) => { 48 | console.log(`Current song is ${response.title}.`); 49 | }) 50 | .catch((error) => { 51 | console.log(error); 52 | }); 53 | ``` 54 | 55 | **NOTE:** In order for this to work, you must be given Manager permissions for the target channel. 56 | 57 | ## Contributing 58 | To contribute to the package, please follow the forking model: 59 | 60 | 1. Fork the repository to your own account. 61 | 1. Create a branch off `master`. 62 | 1. Apply your changes and commit to your branch. 63 | 1. Open a pull request against the central `develop` branch. 64 | 65 | Your pull request will be reviewed by Maintainers, feedback will be provided if necessary, and then merged. Please, do not bump the package version in your pull request. 66 | 67 | ## Disclaimer 68 | This package was created to help reduce the amount of code manually written for each project wishing to work with the StreamElements API. In no way is this project officially endorsed, maintained, or approved by StreamElements. -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const request = require('request'); 2 | const HTTP = { GET: 'GET', POST: 'POST', PUT: 'PUT', DELETE: 'DELETE' }; 3 | 4 | class StreamElements { 5 | 6 | constructor(options) { 7 | 8 | // Establish the base URL for the API. 9 | this.base = options.base || 'https://api.streamelements.com/kappa/v2'; 10 | 11 | // Store the user's access token in the instance. 12 | this.jwt = options.token; 13 | 14 | // Store the account ID of the channel we're accessing. 15 | this.accountId = options.accountId; 16 | 17 | } 18 | 19 | // Create a generic request wrapper. 20 | makeRequest(method, path, body, qs) { 21 | 22 | // Return a promise to allow developers to appropriately handle API responses. 23 | return new Promise((resolve, reject) => { 24 | 25 | request({ 26 | method, 27 | qs, 28 | body, 29 | json: true, 30 | url: `${this.base}/${path}`, 31 | headers: { 32 | 'Authorization': `Bearer ${this.jwt}` 33 | } 34 | }, (error, response, responseBody) => { 35 | 36 | // If there is a request error, reject the Promise. 37 | if (error) { 38 | return reject(error); 39 | } 40 | 41 | // If there is an error on the response body, reject the Promise. 42 | if (responseBody && responseBody.error) { 43 | return reject(responseBody.error); 44 | } 45 | 46 | // If we receive a status code other than 2XX range, reject the Promise. 47 | if (response.statusCode < 200 || response.statusCode > 299) { 48 | return reject(`Error encountered during request to StreamElements. Status Code: ${response.statusCode}`); 49 | } 50 | 51 | // If no errors have been encountered, resolve the Promise with the response body. 52 | return resolve(responseBody); 53 | 54 | }); 55 | 56 | }); 57 | 58 | } 59 | 60 | // /activities 61 | getActivities(channel = this.accountId) { 62 | return this.makeRequest(HTTP.GET, `activities/${channel}`); 63 | } 64 | getActivity(activityId, channel = this.accountId) { 65 | return this.makeRequest(HTTP.GET, `activities/${channel}/${activityId}`); 66 | } 67 | replayActivity(activityId, channel = this.accountId) { 68 | return this.makeRequest(HTTP.POST, `activities/${channel}/${activityId}/replay`); 69 | } 70 | 71 | // /bot 72 | getBotStatus(channel = this.accountId) { 73 | return this.makeRequest(HTTP.GET, `bot/${channel}`); 74 | } 75 | botPartChannel(channel = this.accountId) { 76 | return this.makeRequest(HTTP.POST, `bot/${channel}/part`); 77 | } 78 | botSay(message, channel = this.accountId) { 79 | return this.makeRequest(HTTP.POST, `bot/${channel}/say`, { message }); 80 | } 81 | botJoinChannel(channel = this.accountId) { 82 | return this.makeRequest(HTTP.POST, `bot/${channel}/join`); 83 | } 84 | botMute(channel = this.accountId) { 85 | return this.makeRequest(HTTP.POST, `bot/${channel}/mute`); 86 | } 87 | botUnmute(channel = this.accountId) { 88 | return this.makeRequest(HTTP.POST, `bot/${channel}/unmute`); 89 | } 90 | getBotUserLevels(channel = this.accountId) { 91 | return this.makeRequest(HTTP.GET, `bot/${channel}/levels`); 92 | } 93 | setBotUserLevel(username, level, channel = this.accountId) { 94 | return this.makeRequest(HTTP.POST, `bot/${channel}/levels`, { username, level }); 95 | } 96 | deleteBotUserLevel(username, channel = this.accountId) { 97 | return this.makeRequest(HTTP.DELETE, `bot/${channel}/levels/${username}`, { id: 'levels' }); 98 | } 99 | 100 | // /bot/commands 101 | getBotCommands(channel = this.accountId) { 102 | return this.makeRequest(HTTP.GET, `bot/commands/${channel}`); 103 | } 104 | createBotCommand(options, channel = this.accountId) { 105 | return this.makeRequest(HTTP.POST, `bot/commands/${channel}`, options); 106 | } 107 | getDefaultBotCommands(channel = this.accountId) { 108 | return this.makeRequest(HTTP.GET, `bot/commands/${channel}/default`); 109 | } 110 | updateDefaultBotCommand(commandId, options, channel = this.accountId) { 111 | return this.makeRequest(HTTP.PUT, `bot/commands/${channel}/default/${commandId}`, options); 112 | } 113 | getBotCommand(commandId, channel = this.accountId) { 114 | return this.makeRequest(HTTP.GET, `bot/commands/${channel}/${commandId}`); 115 | } 116 | updateBotCommand(commandId, options, channel = this.accountId) { 117 | return this.makeRequest(HTTP.PUT, `bot/commands/${channel}/${commandId}`, options); 118 | } 119 | deleteBotCommand(command, channel = this.accountId) { 120 | return this.makeRequest(HTTP.DELETE, `bot/commands/${channel}/${commandId}`); 121 | } 122 | 123 | // /bot/timers 124 | getBotTimers(channel = this.accountId) { 125 | return this.makeRequest(HTTP.GET, `bot/timers/${channel}`); 126 | } 127 | createBotTimer(options, channel = this.accountId) { 128 | return this.makeRequest(HTTP.POST, `bot/timers/${channel}`, options); 129 | } 130 | getBotTimer(timerId, channel = this.accountId) { 131 | return this.makeRequest(HTTP.GET, `bot/timers/${channel}/${timerId}`); 132 | } 133 | updateBotTimer(timerId, options, channel = this.accountId) { 134 | return this.makeRequest(HTTP.PUT, `bot/timers/${channel}/${timerId}`, options); 135 | } 136 | deleteBotTimer(timerId, channel = this.accountId) { 137 | return this.makeRequest(HTTP.DELETE, `bot/timers/${channel}/${timerId}`); 138 | } 139 | 140 | // /changelogs 141 | getLatestChangelog() { 142 | return this.makeRequest(HTTP.GET, `changelogs/latest`); 143 | } 144 | getFirstChangelog() { 145 | return this.makeRequest(HTTP.GET, `changelogs/first`); 146 | } 147 | 148 | // /channels 149 | getCurrentChannel() { 150 | return this.makeRequest(HTTP.GET, `channels/me`); 151 | } 152 | getChannel(channel = this.accountId) { 153 | return this.makeRequest(HTTP.GET, `channels/${channel}`); 154 | } 155 | getChannelEmotes(channel = this.accountId) { 156 | return this.makeRequest(HTTP.GET, `channels/${channel}/emotes`); 157 | } 158 | getChannelDetails(channel = this.accountId) { 159 | return this.makeRequest(HTTP.GET, `channels/${channel}/details`); 160 | } 161 | updateChannelProfile(options, channel = this.accountId) { 162 | return this.makeRequest(HTTP.PUT, `channels/${channel}/profile`, options); 163 | } 164 | getChannelUsers(channel = this.accountId) { 165 | return this.makeRequest(HTTP.GET, `channels/${channel}/users`); 166 | } 167 | updateUserAccessLevel(userId, role, channel = this.accountId) { 168 | return this.makeRequest(HTTP.PUT, `channels/${channel}/users/${userId}`, { role }) 169 | } 170 | deleteUserAccess(userId, channel = this.accountId) { 171 | return this.makeRequest(HTTP.DELETE, `channels/${channel}/users/${userId}`); 172 | } 173 | roleplayAsUser(channel = this.accountId) { 174 | return this.makeRequest(HTTP.POST, `channels/${channel}/roleplay`); 175 | } 176 | 177 | // /contests 178 | getContests(channel = this.accountId) { 179 | return this.makeRequest(HTTP.GET, `contests/${channel}`); 180 | } 181 | createContest(options, channel = this.accountId) { 182 | return this.makeRequest(HTTP.POST, `contests/${channel}`, options); 183 | } 184 | getCompletedContests(channel = this.accountId) { 185 | return this.makeRequest(HTTP.GET, `contests/${channel}/history`); 186 | } 187 | getContest(contestId, channel = this.accountId) { 188 | return this.makeRequest(HTTP.GET, `contests/${channel}/${contestId}`); 189 | } 190 | updateContest(contestId, options, channel = this.accountId) { 191 | return this.makeRequest(HTTP.PUT, `contests/${channel}/${contestId}`, options); 192 | } 193 | deleteContest(contestId, channel = this.accountId) { 194 | return this.makeRequest(HTTP.DELETE, `contests/${channel}/${contestId}`); 195 | } 196 | createContestBet(contestId, optionId, amount, channel = this.accountId) { 197 | return this.makeRequest(HTTP.POST, `contests/${channel}/${contestId}/bet`, { optionId, amount }); 198 | } 199 | getContestBet(contestId, channel = this.accountId) { 200 | return this.makeRequest(HTTP.GET, `contests/${channel}/${contestId}/bet`); 201 | } 202 | startContest(contestId, channel = this.accountId) { 203 | return this.makeRequest(HTTP.PUT, `contests/${channel}/${contestId}/start`); 204 | } 205 | setContestWinner(contestId, winnerId, channel = this.accountId) { 206 | return this.makeRequest(HTTP.PUT, `contests/${channel}/${contestId}/winner`, { winnerId }); 207 | } 208 | refundContest(contestId, channel = this.accountId) { 209 | return this.makeRequest(HTTP.DELETE, `contests/${channel}/${contestId}/refund`); 210 | } 211 | closeContest(contestId, channel = this.accountId) { 212 | return this.makeRequest(HTTP.DELETE, `contests/${channel}/${contestId}/stop`); 213 | } 214 | 215 | // /giveaways 216 | getGiveaways(channel = this.accountId) { 217 | return this.makeRequest(HTTP.GET, `giveaways/${channel}`); 218 | } 219 | createGiveaway(options, channel = this.accountId) { 220 | return this.makeRequest(HTTP.POST, `giveaways/${channel}`); 221 | } 222 | getPastGiveaways(channel = this.accountId) { 223 | return this.makeRequest(HTTP.GET, `giveaways/${channel}/history`); 224 | } 225 | getGiveaway(giveawayId, channel = this.accountId) { 226 | return this.makeRequest(HTTP.GET, `giveaways/${channel}/${giveawayId}`); 227 | } 228 | buyGiveawayTickets(giveawayId, tickets, channel = this.accountId) { 229 | return this.makeRequest(HTTP.POST, `giveaways/${channel}/${giveawayId}`, { tickets }); 230 | } 231 | updateGiveaway(giveawayId, options, channel = this.accountId) { 232 | return this.makeRequest(HTTP.PUT, `giveaways/${channel}/${giveawayId}`, options); 233 | } 234 | deleteGiveaway(giveawayId, channel = this.accountId) { 235 | return this.makeRequest(HTTP.DELETE, `giveaways/${channel}/${giveawayId}`); 236 | } 237 | getUserGiveawayStatus(giveawayId, channel = this.accountId) { 238 | return this.makeRequest(HTTP.GET, `giveaways/${channel}/${giveawayId}/joined`); 239 | } 240 | completeGiveaway(giveawayId, channel = this.accountId) { 241 | return this.makeRequest(HTTP.PUT, `giveaways/${channel}/${giveawayId}/complete`); 242 | } 243 | refundGiveaway(giveawayId, channel = this.accountId) { 244 | return this.makeRequest(HTTP.DELETE, `giveaways/${channel}/${giveawayId}/refund`); 245 | } 246 | closeGiveaway(giveawayId, channel = this.accountId) { 247 | return this.makeRequest(HTTP.DELETE, `giveaways/${channel}/${giveawayId}/close`); 248 | } 249 | 250 | // /logs 251 | getLogs(channel = this.accountId) { 252 | return this.makeRequest(HTTP.GET, `logs/${channel}`); 253 | } 254 | 255 | // /loyalty 256 | getLoyaltySettings(channel = this.accountId) { 257 | return this.makeRequest(HTTP.GET, `loyalty/${channel}`); 258 | } 259 | updateLoyaltySettings(options, channel = this.accountId) { 260 | return this.makeRequest(HTTP.PUT, `loyalty/${channel}`, options); 261 | } 262 | 263 | // /overlays 264 | getOverlays(channel = this.accountId) { 265 | return this.makeRequest(HTTP.GET, `overlays/${channel}`); 266 | } 267 | createOverlay(options, channel = this.accountId) { 268 | return this.makeRequest(HTTP.POST, `overlays/${channel}`, options); 269 | } 270 | getOverlay(overlayId, channel = this.accountId) { 271 | return this.makeRequest(HTTP.GET, `overlays/${channel}/${overlayId}`); 272 | } 273 | updateOverlay(overlayId, options, channel = this.accountId) { 274 | return this.makeRequest(HTTP.PUT, `overlays/${channel}/${overlayId}`, options); 275 | } 276 | deleteOverlay(overlayId, channel = this.accountId) { 277 | return this.makeRequest(HTTP.DELETE, `overlays/${channel}/${overlayId}`); 278 | } 279 | 280 | // /points 281 | updatePoints(options, channel = this.accountId) { 282 | return this.makeRequest(HTTP.PUT, `points/${channel}`, options); 283 | } 284 | getUserPoints(userId, channel = this.accountId) { 285 | return this.makeRequest(HTTP.GET, `points/${channel}/${userId}`); 286 | } 287 | deleteUserPoints(userId, channel = this.accountId) { 288 | return this.makeRequest(HTTP.DELETE, `points/${channel}/${userId}`); 289 | } 290 | addUserPoints(userId, amount, channel = this.accountId) { 291 | return this.makeRequest(HTTP.PUT, `points/${channel}/${userId}/${Math.abs(amount)}`); 292 | } 293 | removeUserPoints(userId, amount, channel = this.accountId) { 294 | return this.makeRequest(HTTP.PUT, `points/${channel}/${userId}/${-Math.abs(amount)}`); 295 | } 296 | getUserRank(userId, channel = this.accountId) { 297 | return this.makeRequest(HTTP.GET, `points/${channel}/${userId}/rank`); 298 | } 299 | resetPointsLeaderboard(channel = this.accountId) { 300 | return this.makeRequest(HTTP.DELETE, `points/${channel}/reset/current`); 301 | } 302 | resetAlltimePointsLeaderboard(channel = this.accountId) { 303 | return this.makeRequest(HTTP.DELETE, `points/${channel}/reset/alltime`); 304 | } 305 | getTopPointsUsersAlltime(limit, offset, channel = this.accountId) { 306 | return this.makeRequest(HTTP.GET, `points/${channel}/alltime`, {}, { limit, offset }); 307 | } 308 | getTopPointsUsers(limit, offset, channel = this.accountId) { 309 | return this.makeRequest(HTTP.GET, `points/${channel}/top`, {}, { limit, offset }); 310 | } 311 | 312 | // /sessions 313 | getUserSessionData(channel = this.accountId) { 314 | return this.makeRequest(HTTP.GET, `sessions/${channel}`); 315 | } 316 | updateUserSessionData(options, channel = this.accountId) { 317 | return this.makeRequest(HTTP.PUT, `sessions/${channel}`, options); 318 | } 319 | resetUserSessionData(channel = this.accountId) { 320 | return this.makeRequest(HTTP.PUT, `sessions/${channel}/reset`); 321 | } 322 | reloadUserSessionData(channel = this.accountId) { 323 | return this.makeRequest(HTTP.PUT, `sessions/${channel}/reload`); 324 | } 325 | 326 | // /songrequest 327 | getSongRequestSettings(channel = this.accountId) { 328 | return this.makeRequest(HTTP.GET, `songrequest/${channel}/settings`); 329 | } 330 | updateSongRequestSettings(options, channel = this.accountId) { 331 | return this.makeRequest(HTTP.PUT, `songrequest/${channel}/settings`, options); 332 | } 333 | getPublicSongRequestSettings(channel = this.accountId) { 334 | return this.makeRequest(HTTP.GET, `songrequest/${channel}/public`); 335 | } 336 | getSongRequestQueue(channel = this.accountId) { 337 | return this.makeRequest(HTTP.GET, `songrequest/${channel}/queue`); 338 | } 339 | createSongRequest(song, channel = this.accountId) { 340 | return this.makeRequest(HTTP.POST, `songrequest/${channel}/queue`, { song }); 341 | } 342 | getSongRequestHistory(channel = this.accountId) { 343 | return this.makeRequest(HTTP.GET, `songrequest/${channel}/queue/history`); 344 | } 345 | skipCurrentSong(channel = this.accountId) { 346 | return this.makeRequest(HTTP.DELETE, `songrequest/${channel}/queue/skip`); 347 | } 348 | deleteSongRequest(songId, channel = this.accountId) { 349 | return this.makeRequest(HTTP.DELETE, `songrequest/${channel}/queue/${songId}`); 350 | } 351 | clearSongRequestQueue(channel = this.accountId) { 352 | return this.makeRequest(HTTP.DELETE, `songrequest/${channel}/clear`); 353 | } 354 | getCurrentSong(channel = this.accountId) { 355 | return this.makeRequest(HTTP.GET, `songrequest/${channel}/playing`); 356 | } 357 | setSongRequestVolume(volumeAmount, channel = this.accountId) { 358 | const volume = parseInt(volumeAmount, 10); 359 | if (isNaN(volume) || volume < 0 || volume > 100) { 360 | throw new Error('volumeAmount should be a number between 0 and 100.'); 361 | } 362 | return this.makeRequest(HTTP.POST, `songrequest/${channel}/player/volume`, { volume }); 363 | } 364 | 365 | // /speech 366 | generateSpeech(text, voice = 'Joanna') { 367 | return this.makeRequest(HTTP.GET, `speech`, {}, { text, voice }); 368 | } 369 | getSpeechVoices() { 370 | return this.makeRequest(HTTP.GET, `speech/voices`); 371 | } 372 | 373 | // /stats 374 | getDailyStats(channel = this.accountId) { 375 | return this.makeRequest(HTTP.GET, `stats/${channel}/daily`); 376 | } 377 | getMonthlyStats(channel = this.accountId) { 378 | return this.makeRequest(HTTP.GET, `stats/${channel}/monthly`); 379 | } 380 | 381 | // /store 382 | getStoreItems(channel = this.accountId) { 383 | return this.makeRequest(HTTP.GET, `store/${channel}/items`); 384 | } 385 | createStoreItem(options, channel = this.accountId) { 386 | return this.makeRequest(HTTP.POST, `store/${channel}/items`, options); 387 | } 388 | getStoreItem(itemId, channel = this.accountId) { 389 | return this.makeRequest(HTTP.GET, `store/${channel}/items/${itemId}`); 390 | } 391 | updateStoreItem(itemId, options, channel = this.accountId) { 392 | return this.makeRequest(HTTP.PUT, `store/${channel}/items/${itemId}`); 393 | } 394 | deleteStoreItem(itemId, channel = this.accountId) { 395 | return this.makeRequest(HTTP.DELETE, `store/${channel}/items/${itemId}`); 396 | } 397 | getStoreRedemptions(limit, offset, pending, channel = this.accountId) { 398 | return this.makeRequest(HTTP.GET, `store/${channel}/redemptions`, {}, { limit, offset, pending }); 399 | } 400 | getStoreRedemption(redemptionId, channel = this.accountId) { 401 | return this.makeRequest(HTTP.GET, `store/${channel}/redemptions/${redemptionId}`); 402 | } 403 | updateStoreRedemption(redemptionId, options, channel = this.accountId) { 404 | return this.makeRequest(HTTP.PUT, `store/${channel}/redemptions/${redemptionId}`, options); 405 | } 406 | deleteStoreRedemption(redemptionId, options, channel = this.accountId) { 407 | return this.makeRequest(HTTP.DELETE, `store/${channel}/redemptions/${redemptionId}`); 408 | } 409 | createStoreRedemption(itemId, channel = this.accountId) { 410 | return this.makeRequest(HTTP.POST, `store/${channel}/redemptions/${itemId}`); 411 | } 412 | 413 | // /streams 414 | getStreams(channel = this.accountId) { 415 | return this.makeRequest(HTTP.GET, `streams/${channel}`); 416 | } 417 | getStreamStatus(channel = this.accountId) { 418 | return this.makeRequest(HTTP.GET, `streams/${channel}/live`); 419 | } 420 | getStreamDetails(streamId, channel = this.accountId) { 421 | return this.makeRequest(HTTP.GET, `streams/${channel}/${streamId}`); 422 | } 423 | 424 | // /themes 425 | getThemes() { 426 | return this.makeRequest(HTTP.GET, `themes`); 427 | } 428 | getTheme(themeId) { 429 | return this.makeRequest(HTTP.GET, `themes/${themeId}`); 430 | } 431 | createOverlayFromTheme(themeId, options) { 432 | return this.makeRequest(HTTP.POST, `themes/${themeId}`, options); 433 | } 434 | rateTheme(themeId, rating) { 435 | return this.makeRequest(HTTP.POST, `themes/${themeId}/rate`, { rating }); 436 | } 437 | getThemeRatingForChannel(themeId, channel = this.accountId) { 438 | return this.makeRequest(HTTP.GET, `themes/${themeId}/${channel}/rating`); 439 | } 440 | 441 | // /tipping 442 | getTippingExchangeRates() { 443 | return this.makeRequest(HTTP.GET, `tipping/rates`); 444 | } 445 | getTippingSettings(channel = this.accountId) { 446 | return this.makeRequest(HTTP.GET, `tipping/${channel}`); 447 | } 448 | updateTippingSettings(options, channel = this.accountId) { 449 | return this.makeRequest(HTTP.PUT, `tipping/${channel}`, options); 450 | } 451 | 452 | // /tips 453 | getTips(channel = this.accountId) { 454 | return this.makeRequest(HTTP.GET, `tips/${channel}`); 455 | } 456 | createTip(options, channel = this.accountId) { 457 | return this.makeRequest(HTTP.POST, `tips/${channel}`, options); 458 | } 459 | getTopTippers(channel = this.accountId) { 460 | return this.makeRequest(HTTP.GET, `tips/${channel}/top`); 461 | } 462 | getTipLeaderboard(channel = this.accountId) { 463 | return this.makeRequest(HTTP.GET, `tips/${channel}/leaderboard`); 464 | } 465 | getRecentTips(channel = this.accountId) { 466 | return this.makeRequest(HTTP.GET, `tips/${channel}/moderation`); 467 | } 468 | getTip(tipId, channel = this.accountId) { 469 | return this.makeRequest(HTTP.GET, `tips/${channel}/${tipId}`); 470 | } 471 | updateTip(tipId, options, channel = this.accountId) { 472 | return this.makeRequest(HTTP.PUT, `tips/${channel}/${tipId}`, options); 473 | } 474 | deleteTip(tipId, channel = this.accountId) { 475 | return this.makeRequest(HTTP.DELETE, `tips/${channel}/${tipId}`); 476 | } 477 | 478 | // /uploads 479 | getAssets(channel = this.accountId) { 480 | return this.makeRequest(HTTP.GET, `uploads/${channel}`); 481 | } 482 | deleteAsset(assetId, channel = this.accountId) { 483 | return this.makeRequest(HTTP.DELETE, `uploads/${channel}/${assetId}`); 484 | } 485 | 486 | // /users 487 | getCurrentUser() { 488 | return this.makeRequest(HTTP.GET, `users/current`); 489 | } 490 | getUserChannels() { 491 | return this.makeRequest(HTTP.GET, `users/channels`); 492 | } 493 | getChannelAccess() { 494 | return this.makeRequest(HTTP.GET, `users/access`); 495 | } 496 | 497 | } 498 | 499 | module.exports = StreamElements; 500 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-streamelements", 3 | "version": "0.1.3", 4 | "description": "An unofficial wrapper for the StreamElements API.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/ryanbarr/node-streamelements.git" 12 | }, 13 | "keywords": [ 14 | "streamelements" 15 | ], 16 | "author": "Ryan Barr (http://spooky.gg)", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/ryanbarr/node-streamelements/issues" 20 | }, 21 | "homepage": "https://github.com/ryanbarr/node-streamelements#readme", 22 | "dependencies": { 23 | "request": "^2.83.0" 24 | } 25 | } 26 | --------------------------------------------------------------------------------