Registry / messaging / bilibili-websocket

bilibili-websocket

JSON →
library0.0.3jsnpmunverified

A lightweight WebSocket client for connecting to Bilibili live danmaku (bullet comments) streams. Version 0.0.3, early-stage release with no regular update cadence. Provides three public APIs ($start, $destroy, $subscribe) to manage the WebSocket connection and subscribe to messages. Intended for browser use (Chrome recommended) with native WebSocket. No TypeScript typings included. Users must configure their own nginx proxy to relay Bilibili's danmaku WebSocket service, as the author's hosted proxy has expired.

npm install bilibili-websocket
INSTALL
IMPORT
SIG · BILIBILI-WEBSOCKET
B
bilibili-websocket
messagingjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (BILIWS)
import BILIWS from 'bilibili-websocket';
const BILIWS = require('bilibili-websocket');
CJS require may not work in browser; the package likely expects ESM or global use.
$start
BILIWS.$start(roomId);
BILIWS.start(roomId);
The API uses $start (with dollar sign), not start.
$subscribe
BILIWS.$subscribe(callback);
BILIWS.subscribe(callback);
Same naming convention with dollar sign.

Connects to a Bilibili live room and logs incoming danmaku messages.

import BILIWS from 'bilibili-websocket'; const roomId = 7623885; // a room with active danmaku BILIWS.$start(roomId); const unsubscribe = BILIWS.$subscribe((msg) => { console.log('Danmaku:', msg); }); // Later to stop: // unsubscribe(); // BILIWS.$destroy();
Debug
Known issues
breakingAuthor's proxy service for WebSocket relay has expired and will no longer work. Users must set up their own nginx proxy.
fix
Configure your own nginx reverse proxy to wss://broadcastlv.chat.bilibili.com/sub or use a direct WebSocket connection if allowed.
affects: =0.0.3
gotchaRoom may have no danmaku if unpopular; demo uses 7623885 which is active.
fix
Pick a popular live room ID (e.g., 7623885) for testing.
affects: >=0.0.0
Errors
Common errors & fixes
BILIWS.$start is not a function
Incorrect import or the library not loaded properly.
fix
Ensure you import BILIWS correctly (import BILIWS from 'bilibili-websocket') and that the script is loaded as a module.
WebSocket connection to 'wss://...' failed
Missing or misconfigured proxy; the default proxy endpoint may be down.
fix
Set up your own nginx proxy or provide a direct WebSocket URL to Bilibili's danmaku server.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
35
OpenAI (training)
1
Resources
bilibili-websocket — npm install bilibili-websocket · libregistry