openvidu-node-client API


This is a Node library wrapping OpenVidu Server REST API

Check TypeDoc documentation


Code samples

Create a session

var openvidu = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
var properties = {};
openVidu.createSession(properties).then(session => { ... });

Generate a token

var tokenOptions = {
    role: "PUBLISHER",
    data: "user_data"
};
session.generateToken(tokenOptions).then(token => { ... });

Fetch session status

// Fetch all session info from OpenVidu Server
openvidu.fetch()
  .then(anyChange => {
      var activeSessions = openvidu.activeSessions;
  }):

// Fetch one session info from OpenVidu Server
session.fetch()
  .then(anyChange => {
      var activeConnections = session.activeSessions;
  });

Close a session

session.close().then(() => console.log('Session closed'));

Disconnect a user

// Find the desired Connection object in the array Session.activeConnections
session.forceDisconnect(connection);

Unpublish a user's stream

// Find the desired Publisher object in the array Connection.publishers
session.forceUnpublish(publisher);

Manage recordings

// Start recording
var sessionId = session.getSessionId();
openVidu.startRecording(sessionId).then(recordingStarted => ... );

// Stop recording
var recordingId = recordingStarted.id;
openvidu.stopRecording(recordingId).then(recordingStopped => ... );

// Get recording
openvidu.getRecording(recordingId).then(recordingRetrieved => ... );

// List recordings
openVidu.listRecordings().then(recordingList => ... );

// Delete recording
openVidu.deleteRecording(recordingId);