streamlabs-ws-client
v1.0.0
Published
Unofficial Streamlabs Sockets API client library
Downloads
3
Maintainers
Readme
streamlabs-ws-client
Unofficial Streamlabs WebSocket API Client
- 🎉 First class Typescript support
- 📡 Real-time via socket.io-client
- 👌 Simple un-opinionated API
Table of Contents
Installation
$ npm install --save streamlabs-ws-client
...
$ yarn add streamlabs-ws-client
...
Usage
const { StreamlabsClient } = require("../lib/index");
const debugEvents = [
"connect",
"connect_error",
"connect_timeout",
"disconnect",
"error"
];
const streamlabsEvents = [
"follow",
"bits",
"host",
"raid",
"merch",
"subscription",
"resubscription",
"donation"
];
const token = "<INSERT STREAMLABS WS TOKEN>";
const client = new StreamlabsClient({
token,
emitTests: true,
rawEvents: debugEvents
});
for (const debugEvent of debugEvents) {
client.on(debugEvent, (data) => {
console.debug(`[STREAMLABS-EVENT] Event: ${debugEvent}`, data);
});
}
for (const streamEvent of streamlabsEvents) {
client.on(streamEvent, async (data) => {
console.info(`[STREAMLABS-EVENT] Event: ${streamEvent}`, JSON.stringify(data, null, 4));
});
}
client.connect();
API
connect()
client.connect();
disconnect()
client.disconnect();
on()
client.on("event", (data: IStreamlabsWSEventMessage) => {
// Do something
});
emit()
client.on("event", (data: IStreamlabsWSEventMessage) => {
// TBC
});
Examples
TBC
Support
Please open an issue for support.
Contributing
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
License
MIT : http://opensource.org/licenses/MIT
Author
Jarvis Prestidge | [email protected]