Tip: avoid reserved SDK types (subscribe | unsubscribe | channelMessage) for custom protocols.
For detailed option and event payloads, see the Markdown API reference.
const vdo = new VDONinjaSDK(options)
wss://wss.vdo.ninja)connect() → Promise<void>disconnect() → Promise<void>; await it until peer,
timer, and signaling cleanup genuinely finishesjoinRoom({ room, password }), leaveRoom()autoConnect(roomOrOptions, filter?) → { stop, streamID }publish(stream, { streamID, room?, label?, password? })announce({ streamID?, room?, label?, password? })stopPublishing()view(streamID, { audio=true, video=true, label?, downloads=true,
allowresources=false })stopViewing(streamID)quickPublish({ stream, room?, streamID?, label?, password? })quickView({ streamID, room?, audio?, video?, label?, password?, dataOnly? })quickSubscribe({ streamID, room?, ... }) (defaults to data-only)sendData(data, target?) — data-channel routing defaults to
publisher first, then viewer. WebSocket signaling fallback is separate, disabled by
default, and enabled with { allowFallback: true }.sendBinary(data, uuid, options?) — raw bytes on the reserved
x-bin lane, never the control channelopenChannel(uuid, label, options?),
getChannel(uuid, label)getBufferedAmount(uuid, label?),
getMaxMessageSize(uuid)sendPing(uuid?)request(type, data, targetUUID, timeout?), respond(id, data, targetUUID)onRequest(type, handler)hostFile(source, options?), unhostFile(id),
getHostedFiles()requestFile(uuid, fileId, options?) — receive bytes or stream
fileChunk eventssendResource(uuid, metadata, data) — requires the peer to advertise
allowresourcesfileList, fileTransferStart,
fileTransferProgress, fileChunk,
fileTransferComplete, fileTransferCancelled,
fileTransferError, resourceReceivedsubscribe(channels), unsubscribe(channels), getSubscriptions()publishToChannel(channel, data, target='all')getPeerSubscriptions(uuid)channelMessage, peerSubscribed, peerUnsubscribedgetStats(uuid?)getPeerQuality(uuid) — normalized RTT, loss, route, relay,
bitrate, and byte metricsplay|watch|startViewing → view, stream|broadcast|startPublishing|share → publish, quickStream|quickBroadcast|quickShare → quickPublish, stop|stopPlaying|stopWatching → stopViewing, stopStreaming|stopBroadcasting|stopSharing|unpublish → stopPublishing, join|enterRoom|enter → joinRoom, leave|exitRoom → leaveRoomBrowser and Node declarations ship with the package; no separate
@types package is required. The root, /browser, and
/node exports each resolve the matching declarations.
connected, disconnected,
teardownComplete, reconnecting, reconnected,
reconnectFailedconnectionRecovering, connectionRecovered, connectionFailed, relayEscalated, relayRestoredhss-connection, room-peer-listing, push-connection, view-connectionroomJoined, roomLeft, listing, peerListingpeerConnected, peerDisconnected, dataChannelOpen, dataChannelClose, peerInfo, peerLatencydataReceived (dataRecieved alias),
data, binaryReceived, channelOpen,
bufferedAmountLow, unsupportedChanneltrack, trackAdded, trackRemoved, trackReplacedpublishing, publishingStopped, viewingStopped, iceRestart, connectionFailed, alert, errorStandalone clients for standard WebRTC-HTTP streaming protocols. Works independently of the VDO.Ninja P2P system.
Publish media streams to WHIP-compatible endpoints (Twitch, Meshcast, Cloudflare, etc.)
const client = new WHIPClient(endpoint, options)
Methods:
publish(stream) — Publish a MediaStreamreplaceTrack(oldTrack, newTrack) — Replace a track mid-sessionstop() — Stop publishing and cleanupgetStats() — Get RTCStatsReportrestartIce() — Restart ICE connectionEvents: connecting, connected, icestate, connectionstate, error, disconnected, stopped
Consume media streams from WHEP-compatible endpoints.
const client = new WHEPClient(endpoint, options)
Methods:
view() — Start viewing, returns MediaStreamgetStream() — Get the received MediaStreammuteAudio(muted), muteVideo(muted) — Mute locallystop() — Stop viewing and cleanupgetStats() — Get RTCStatsReportEvents: connecting, connected, track, icestate, connectionstate, error, disconnected, stopped
https://cae1.meshcast.io/whip/{id} / https://cae1.meshcast.io/whep/{id}https://g.webrtc.live-video.net:4443/v2/offer (WHIP only)