REST & Chat client for wasd.tv
Installation
npm i wasdtv
yarn add wasdtv
Usage
Obtaining token
To use REST api you should get token in account setting area
REST requests
Http requests to api endpoints
import { WasdTv } from 'wasdtv'
const wasd = new WasdTv('YOUR_API_TOKEN')
const run = async () => {
const channel_info = await wasd.getChannelInfo('emeraldgp')
const chat_messages = await wasd.getStreamChatMessages(1016377, 501)
const chat_stickers = await wasd.getStreamChatStickers(1015200)
// ... other rest methods
}
run()
Chat
Connecting to chat socket.io server
import { WasdTv } from 'wasdtv'
const wasd = new WasdTv('YOUR_API_TOKEN')
wasd.joinToChat(1016842, 68523)
wasd.on('event', (ctx) => {
console.log('event', ctx)
})
wasd.on('subscribe', (ctx) => {
console.log('subscribe', ctx)
})
wasd.on('connect', () => {
console.log('connect')
})
wasd.on('viewers', (ctx) => {
console.log('viewers', ctx)
})
wasd.on('system_message', (ctx) => {
console.log('system_message', ctx)
})
wasd.on('giftsV1', (ctx) => {
console.log('giftsV1', ctx)
})
wasd.on('message', (ctx) => {
console.log('message', ctx)
})
Capturing Stream
Yes! You can capture stream (for example, into file)
import { WasdTv } from 'wasdtv'
import fs from 'fs'
const wasd = new WasdTv('YOUR_API_TOKEN')
// Get stream metadata
wasd.getMediaStreamMetadata(1328329).then((data) => {
console.log(data)
})
const media = wasd.getMediaStream(1328329)
media.pipe(fs.createWriteStream('video.mp4'))
// Capture 20s of stream and close connection
setTimeout(() => {
media.end()
}, 20 * 1000)
Warning
Due to the fact that Wasd has almost no adequate api documentation, typing was done by reversing responses. For this reason types can be incorrect and incomplete.
If you notice an error, please make a pull request or at least an issue.
Contributing
Pull requests are welcome. Please use prettier format for your code.
License
Distributed under the MIT License.