A JavaScript/TypeScript library for connecting to Bilibili Live WebSocket and TCP APIs. Version 6.3.1 is the latest stable release. It provides four main classes (LiveWS, LiveTCP, KeepLiveWS, KeepLiveTCP) for real-time room events like danmaku, gifts, and heartbeats. Supports browser environment with experimental browser build. Includes TypeScript type definitions. Features automatic heartbeats, custom auth for Bilibili Open Live platform, and multiple protocol versions (1, 2, 3) for compression.
npm install bilibili-live-wsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to a Bilibili live room via WebSocket, listens for open, live, heartbeat, and message events.
Use `import { LiveWS } from 'bilibili-live-ws'` or `const { LiveWS } = require('bilibili-live-ws')`.Consider using LiveWS/KeepLiveWS instead.
Use `import { LiveWS } from 'bilibili-live-ws/browser'` in browser environments.Pass authBody as object (not pre-encoded) for automatic encoding.
Ensure runtime supports brotli or use protover=2 (zlib).
Verify room ID via Bilibili API before connecting.
Run `npm install bilibili-live-ws`.
Use `import { LiveWS } from 'bilibili-live-ws'`.Install peer dependencies: `npm install pako buffer events`.
Ensure room ID is correct and network allows WebSocket connections to bilibili.com.