Video Client

View as Markdown

The Video Client allows you to monitor video room activity. It connects to SignalWire and notifies you when rooms start, end, or when participants join and leave.

1import { Video } from "@signalwire/realtime-api";
2
3const video = new Video.Client({
4 project: "<project-id>",
5 token: "<api-token>",
6});

Once instantiated, use getRoomSessions to list active rooms, or subscribe to events like room.started and room.ended. See Events for all available events.

Constructor

new Video.Client(opts): Video.Client

Creates a new Video Client instance.

Parameters

NameTypeDescription
opts.projectstringRequired. SignalWire project ID.
opts.tokenstringRequired. SignalWire API token.
opts.debug.logWsTraffic?booleanLog WebSocket traffic for debugging. Default: false.

Examples

Listening for room events

1video.on("room.started", async (roomSession) => {
2 console.log("Room started:", roomSession.name);
3});
4
5video.on("room.ended", async (roomSession) => {
6 console.log("Room ended:", roomSession.id);
7});

Getting active rooms

1const { roomSessions } = await video.getRoomSessions();