2.0.4 • Published 6 years ago

twitch-api-v5 v2.0.4

Weekly downloads
228
License
MIT
Repository
github
Last release
6 years ago

Twitch_API_v5

Simple module to use Twitch's API v5 for all endpoints. For details on optional parameters or required authentication scopes please follow the links to the Twitch docs.

This module also includes undocumented endpoints (such as the chatters endpoint to view which users are currently in a channels chat), these should be used at your own risk and are should be expected to change or be removed at any time.

Contents


Getting Started

Install

npm install twitch-api-v5 --save

Examples

var api = require('twitch-api-v5');

api.clientID = 'Twitch app client-id';

api.user.getByID({ userID: '12826' }, (err, res) => {
    if(err) {
        console.log(err);
    } else {
        console.log(res);
        /* Example response
        {
            display_name: 'Twitch',
            _id: '12826',
            name: 'twitch',
            type: 'user',
            ...
        }
        */
    }
});

api.feed.createPost({ auth: 'OAuth ...', channelID: '12826', post: 'New Post!' }, (err, res) => {
    ...
});

To enable debugging of the HTTP requests, use api.debug = true;


Authentication

Twitch Doc

Note: The authorization code needed for getAccessToken is obtained by steps 1 and 2 of the Authorization Code Flow described in the Twitch Docs.

FunctionAuth ScopeRequired Parameters
api.auth.getAccessTokennoneclientSecret, redirectURI, code
api.auth.checkTokenanyauth
api.auth.refreshTokennoneclientSecret, refreshToken

Bits

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.bits.cheermotesnonenone

Feed

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.feed.getPostsany (optional)channelID
api.feed.getPostany (optional)postID
api.feed.createPostchannel_feed_editauth, channelID, post
api.feed.deletePostchannel_feed_editauth, channelID, postID
api.feed.createReactionchannel_feed_editauth, channelID, postID, emoteID
api.feed.deleteReactionchannel_feed_editauth, channelID, postID, emoteID
api.feed.getCommentsany (optional)channelID, postID
api.feed.createCommentchannel_feed_editauth, channelID, postID, comment
api.feed.deleteCommentchannel_feed_editauth, channelID, postID, commentID
api.feed.createCommentReactionchannel_feed_editauth, channelID, postID, commentID, emoteID
api.feed.deleteCommentReactionchannel_feed_editauth, channelID, postID, commentID, emoteID

Channels

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.channels.channelchannel_readauth
api.channels.channelByIDnonechannelID
api.channels.updateChannelchannel_editorchannelID, and at least one of status, game, delay or channel_feed_enabled
api.channels.editorschannel_readauth, channelID
api.channels.followersnonechannelID
api.channels.teamsnonechannelID
api.channels.subschannel_subscriptionsauth, channelID
api.channels.checkSubchannel_check_subscriptionauth, channelID, userID
api.channels.videosnonechannelID
api.channels.startAdchannel_commercialauth, channelID, duration
api.channels.resetStreamKeychannel_streamauth, channelID
api.channels.getCommunitynonechannelID
api.channels.setCommunitychannel_editorauth, channelID, communityID
api.channels.leaveCommunitychannel_editorauth, channelID

Chat

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.chat.badgesnonechannelID
api.chat.emoteSetnonenone
api.chat.emotesnonenone

Clips

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.clips.getClipnoneslug
api.clips.topnonenone
api.clips.followeduser_readauth

Collections

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.collections.getMetadatanonecollectionID
api.collections.getCollectionnonecollectionID
api.collections.getByChannelnonechannelID
api.collections.createcollections_editauth, channelID, title
api.collections.updatecollections_editauth, collectionID, title
api.collections.createThumbnailcollections_editauth, collectionID, itemID
api.collections.deletecollections_editauth, collectionID
api.collections.addItemcollections_editauth, collectionID, videoID
api.collections.delItemcollections_editauth, collectionID, itemID
api.collections.moveItemcollections_editauth, collectionID, itemID, position

Communities

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.communities.getByNamenonename
api.communities.getByIDnonecommunityID
api.communities.updatecommunities_editauth, communityID
api.communities.topnonenone
api.communities.banscommunities_moderateauth, communityID
api.communities.addBancommunities_moderateauth, communityID, userID
api.communities.unBancommunities_moderateauth, communityID, userID
api.communities.createAvatarcommunities_editauth, communityID, avatar_image
api.communities.deleteAvatarcommunities_editauth, communityID
api.communities.createCovercommunities_editauth, communityID, cover_image
api.communities.deleteCovercommunities_editauth, communityID
api.communities.modscommunities_editauth, communityID
api.communities.addModcommunities_editauth, communityID, userID
api.communities.delModcommunities_editauth, communityID, userID
api.communities.getPermissionsanyauth, communityID
api.communities.reportnonechannelID, communityID
api.communities.timeoutscommunities_moderateauth, communityID
api.communities.addTimeoutcommunities_moderateauth, communityID, userID, duration
api.communities.delTimeoutcommunities_moderateauth, communityID, userID

Games

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.games.topnonenone

Ingests

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.ingests.serverListnonenone

Search

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.search.channelsnonequery
api.search.gamesnonequery
api.search.streamsnonequery

Streams

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.streams.channelnonechannelID
api.streams.livenonenone
api.streams.summarynonenone
api.streams.featurednonenone
api.streams.followeduser_readauth

Teams

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.teams.getAllnonenone
api.teams.getTeamnoneteam

Users

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.users.useruser_readauth
api.users.userByIDnoneuserID
api.users.usersByNamenoneusers
api.users.userEmotesuser_subscriptionsauth, userID
api.users.checkSubuser_subscriptionsauth, userID, channelID
api.users.followsnoneuserID
api.users.checkFollownoneuserID, channelID
api.users.followChanneluser_follows_editauth, userID, channelID
api.users.unfollowChanneluser_follows_editauth, userID, channelID
api.users.blockListuser_blocks_readauth, userID
api.users.blockUseruser_blocks_editauth, sourceUserID, targetUserID
api.users.unblockUseruser_blocks_editauth, sourceUserID, targetUserID
api.users.createVHSviewing_activity_readauth, identifier
api.users.checkVHSuser_readauth
api.users.deleteVHSviewing_activity_readauth

Videos

Twitch Doc

FunctionAuth ScopeRequired Parameters
api.videos.getVideononevideoID
api.videos.topnonenone
api.videos.followednonenone
api.videos.createchannel_editorauth, channelID, title
api.videos.uploadnonecontent-length, videoData, videoID, part, token
api.videos.completenonevideoID, token
api.videos.updatechannel_editorauth, videoID
api.videos.deletechannel_editorauth, videoID

Other

Warning: These endpoints are undocumented and should be expected to change or cease to function at any point!

FunctionAuth ScopeRequired ParametersDescription
api.other.chattersnonechannelNameUsernames of people in chat in the specified channel
api.other.hostsnonechannelIDChannels that are hosting the specified channelID
api.other.hostingnonechannelIDWho the specified channelID is hosting
api.other.subsTouser_subscriptionsauth, channelNameWho a user is subbed to
api.other.randomStreamnonenoneRandom stream
api.other.getUsernonechannelNameProvides user data not returned in the documented endpoint
api.other.chatPropertiesnonechannelNameChat properties, such as subs only, rules etc...
api.other.productnonechannelNameChannels subscription program details
api.other.panelsnonechannelNameInfo on each of a channels panels
api.other.playlistnonechannelIDInfo on a currently running playlist
api.other.followedHostingnonechannelNameFollowed channels that are hosting someone else
api.other.followedGamesnonechannelNameGames that a user follows
api.other.followedGamesLivenonechannelNameLive games that a user follows
api.other.checkFollowGamenonechannelName, gameCheck if a user follows a game
api.other.badgesnonenoneAll chat badges
api.other.subBadgesnonechannelIDA channels sub badges
api.other.recentChatnonechannelIDRecent chat in the specified channel
api.other.csnonenoneList of CS streams with extra details
api.other.csMapsnonenoneList of CS maps and their viewers
2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago