A lightweight, TypeScript-first WebSocket/TCP client for Bilibili live streaming API, supporting both Node.js and browser environments. Current stable version is 1.0.2, released in 2022. It provides an event-driven interface for receiving live room data like danmaku (DANMU_MSG), heartbeat, and other Bilibili live events. Unlike heavier alternatives, it is minimal and includes built-in TypeScript type definitions. Requires manual cookie/UID for anti-spoofing and extra key/url for browser usage due to CORS restrictions.
npm install tiny-bilibili-wsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to a Bilibili live room and logs danmaku messages and heartbeat online count.
Fetch the key and url from your own server or proxy and pass them as options: new KeepLiveWS(room, { url: 'wss://...', key: '...' })Provide a valid Bilibili Cookie and corresponding uid in the options object.
Use import syntax or configure your project for ESM.
Use live.on('open', () => {...}) as a more reliable alternative.Check typeof online === 'number' && !isNaN(online) before using.
Run 'npm install ws' if you encounter errors about missing 'ws'.
Install the package with 'npm install tiny-bilibili-ws' and use import syntax.
When using in browser, pass url and key options: new KeepLiveWS(room, { url: '...', key: '...' })Provide a valid Bilibili Cookie and uid in the KeepLiveWS options.