@catalyst-workshop/streamlabs-ws-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-a • Public • Published

streamlabs-ws-client

Language Node Version Yarn Version Licence Info

Streamlabs Slack

Streamlabs Slack

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 | jarvisprestidge@gmail.com

Package Sidebar

Install

npm i @catalyst-workshop/streamlabs-ws-client

Weekly Downloads

0

Version

1.0.0-a

License

MIT

Unpacked Size

39.2 kB

Total Files

45

Last publish

Collaborators

  • sk115