chatzzk
v0.1.5
Published
experimental chzzk chat r/o api
Downloads
101
Readme
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/[email protected]/src/index.mjs'
const chatzzk = new Chatzzk('a9ab391cdd3faef4ca2ee782e96e5c59', {
// timeout
rpcTimeout: 1_000,
// will log any message not handled by onmessage()
logUnhandledMessage: false,
// your own API proxy - required if CORS applied
api: {
liveStatus: uid => `https://example.com/live-status/${uid}`,
accessToken: cid => `https://example.com/access-token/${cid}`
}
})
c.on('message', payload => {
// name color parsed & provided in paylaod.color
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