chatzzk - Chzzk Chat API
Currently read-only. quite unstable.
Usage
Please pin a major version on your dependency, as API may change suddenly.
import Chzzk from 'https://unpkg.com/chatzzk@0.1/src/index.mjs'
const chatzzk = new Chatzzk('a9ab391cdd3faef4ca2ee782e96e5c59', {
rpcTimeout: 1_000,
logUnhandledMessage: false,
api: {
liveStatus: uid => `https://example.com/live-status/${uid}`,
accessToken: cid => `https://example.com/access-token/${cid}`
}
})
c.on('message', payload => {
console.log(chalk.hex(payload.color)(payload.profile.nickname), payload.msg)
})
Payload Types
See src/commands.mjs.
those types are called 'cmd' inside, and consist of 4+1-digit decimal numbers.
Notes about Closed API
API Proxies
Basically, on browser, Naver API will disallow your access with CORS policy.
you may provide your own API proxy against this situation, or wait until full API opens.
Specify a function under options.api
to return URL, that heads those endpoints:
liveStatus
: https://api.chzzk.naver.com/polling/v2/channels/${uid}/live-status
accessToken
: https://comm-api.game.naver.com/nng_main/v1/chats/access-token?channelId=${cid}&chatType=STREAMING