bbb-api-js
v1.1.1
Published
API integration for BigBlueButton
Maintainers
Readme
bbb-api-js
A TypeScript/JavaScript client library for interacting with the BigBlueButton API.
Features
- Full TypeScript support with comprehensive type definitions
- Promise-based API for async/await usage
- Automatic checksum generation with multiple hash algorithm support (SHA-1, SHA-256, SHA-384, SHA-512)
- Built-in XML parsing and response handling
- Custom error classes for better error handling
- Zero runtime dependencies (except
axiosandxml2js)
Installation
npm install bbb-api-jsQuick Start
import { BBBClient } from 'bbb-api-js';
// Initialize the client
const client = new BBBClient({
serverUrl: 'https://bbb.example.com/bigbluebutton/api',
secret: 'your-shared-secret'
});
// Create a meeting
const meeting = await client.create({
meetingID: 'my-meeting-123',
name: 'My First Meeting',
attendeePW: 'attendee-password',
moderatorPW: 'moderator-password',
record: true
});
// Generate a join URL for a moderator
const joinUrl = client.join({
fullName: 'John Doe',
meetingID: 'my-meeting-123',
password: meeting.moderatorPW
});
console.log('Join the meeting at:', joinUrl);API Reference
Important Notes
All parameters and response fields documented below are part of the official BigBlueButton API specification unless otherwise noted. This library is a direct wrapper around the BBB API and does not add or modify any functionality.
Response Structure:
All API responses include a returncode field with either 'SUCCESS' or 'FAILED'. This field is preserved in all response objects returned by this library, maintaining compatibility with the actual BBB API response structure.
Constructor
new BBBClient(config)
Creates a new BigBlueButton API client.
Parameters:
config.serverUrl(string, required): Base URL of your BigBlueButton API endpointconfig.secret(string, required): Shared secret from your BBB serverconfig.hashAlgorithm(string, optional): Hash algorithm for checksums. Options:'sha1','sha256'(default),'sha384','sha512'
const client = new BBBClient({
serverUrl: 'https://bbb.example.com/bigbluebutton/api',
secret: 'your-shared-secret',
hashAlgorithm: 'sha256' // optional
});Methods
create(params): Promise<CreateMeetingResponse>
Creates a new meeting.
Official BBB API Reference: https://docs.bigbluebutton.org/development/api#create
Required Parameters:
meetingID(string): Unique identifier for the meetingname(string): Display name for the meeting
Optional Parameters:
attendeePW(string): Password for attendeesmoderatorPW(string): Password for moderatorswelcome(string): Welcome message displayed when users joindialNumber(string): Dial-in number for voice conferencevoiceBridge(string): Voice bridge numbermaxParticipants(number): Maximum number of participantslogoutURL(string): URL to redirect users when meeting endsrecord(boolean): Whether meeting is recorded on startduration(number): Duration of meeting in minutesisBreakout(boolean): Whether this is a breakout roomparentMeetingID(string): Parent meeting ID for breakout roomssequence(number): Sequence number for breakout roomsautoStartRecording(boolean): Whether to auto-start recordingallowStartStopRecording(boolean): Whether participants can start/stop recordingwebcamsOnlyForModerator(boolean): Whether webcams are shared only with moderatorslogo(string): Logo to display in the clientcopyright(string): Copyright textmuteOnStart(boolean): Whether to mute on startguestPolicy('ALWAYS_ACCEPT' | 'ALWAYS_DENY' | 'ASK_MODERATOR'): Guest approval policymeta_*(string): Additional metadata (key-value pairs with meta_ prefix)
Response Fields:
returncode('SUCCESS' | 'FAILED'): API response statusmeetingID(string): Meeting identifierinternalMeetingID(string): Internal meeting identifierparentMeetingID(string, optional): Parent meeting identifierattendeePW(string): Attendee passwordmoderatorPW(string): Moderator passwordcreateTime(number): Meeting creation timestampvoiceBridge(string): Voice bridge numberdialNumber(string, optional): Dial-in numbercreateDate(string): Meeting creation datehasUserJoined(boolean): Whether any user has joinedduration(number): Meeting durationhasBeenForciblyEnded(boolean): Whether meeting was forcibly endedmessage(string, optional): Additional message (e.g., duplicate warning)messageKey(string, optional): Message key for localization
const meeting = await client.create({
meetingID: 'meeting-123',
name: 'Team Standup',
attendeePW: 'ap',
moderatorPW: 'mp',
welcome: 'Welcome to the meeting!',
record: true,
duration: 60,
meta_description: 'Daily team standup'
});
console.log('Status:', meeting.returncode);
console.log('Meeting created:', meeting.meetingID);
console.log('Internal ID:', meeting.internalMeetingID);join(params): string
Generates a join URL for a participant to join a meeting.
Important: This method does NOT make an API call. It only generates the URL that users should navigate to in their browser.
Official BBB API Reference: https://docs.bigbluebutton.org/development/api#join
Required Parameters:
fullName(string): Display name for the participantmeetingID(string): Meeting ID to joinpassword(string): Attendee or moderator password
Optional Parameters:
createTime(number): Meeting creation time for validationuserID(string): Custom user identifierwebVoiceConf(string): Web voice conference voice bridgeconfigToken(string): Configuration tokendefaultLayout(string): Default layout for the useravatarURL(string): URL to user's avatar imageredirect(boolean): Whether to redirect immediatelyclientURL(string): Custom client URLjoinViaHtml5(boolean): Join via HTML5 clientguest(boolean): Whether user is a guest
Returns: Complete join URL as a string
Throws: BBBConfigError if required parameters are missing
// Generate moderator join URL
const modUrl = client.join({
fullName: 'Jane Smith',
meetingID: 'meeting-123',
password: meeting.moderatorPW,
userID: 'user-456'
});
// Generate attendee join URL
const attendeeUrl = client.join({
fullName: 'John Doe',
meetingID: 'meeting-123',
password: meeting.attendeePW
});getMeetingInfo(meetingID): Promise<MeetingInfo>
Gets detailed information about a running meeting.
Official BBB API Reference: https://docs.bigbluebutton.org/development/api#getmeetinginfo
Required Parameters:
meetingID(string): Meeting ID
Response Fields:
returncode('SUCCESS' | 'FAILED'): API response statusmeetingName(string): Meeting namemeetingID(string): Meeting identifierinternalMeetingID(string): Internal meeting identifiercreateTime(number): Meeting creation timestampcreateDate(string): Meeting creation datevoiceBridge(string): Voice bridge numberdialNumber(string, optional): Dial-in numberattendeePW(string): Attendee passwordmoderatorPW(string): Moderator passwordrunning(boolean): Whether meeting is currently runningduration(number): Meeting durationhasUserJoined(boolean): Whether any user has joinedrecording(boolean): Whether meeting is being recordedhasBeenForciblyEnded(boolean): Whether meeting was forcibly endedstartTime(number, optional): Meeting start timestampendTime(number, optional): Meeting end timestampparticipantCount(number): Number of participantslistenerCount(number): Number of listenersvoiceParticipantCount(number): Number of voice participantsvideoCount(number): Number of video streamsmaxUsers(number): Maximum users allowedmoderatorCount(number): Number of moderatorsattendees(Attendee[]): Array of attendee objectsmetadata(Record<string, string>, optional): Meeting metadataisBreakout(boolean): Whether this is a breakout room
const info = await client.getMeetingInfo('meeting-123');
console.log('Status:', info.returncode);
console.log('Meeting:', info.meetingName);
console.log('Running:', info.running);
console.log('Participants:', info.participantCount);
console.log('Attendees:', info.attendees.map(a => a.fullName));endMeeting(meetingID, password): Promise<EndMeetingResponse>
Forcibly ends a meeting and kicks all participants out.
Official BBB API Reference: https://docs.bigbluebutton.org/development/api#end
Required Parameters:
meetingID(string): Meeting IDpassword(string): Moderator password
Response Fields:
returncode('SUCCESS' | 'FAILED'): API response statusmessage(string, optional): Response messagemessageKey(string, optional): Message key for localization
const result = await client.endMeeting('meeting-123', 'moderator-password');
console.log('Status:', result.returncode);
console.log('Message:', result.message);getRecordings(params?): Promise<GetRecordingsResult>
Retrieves recordings from the server.
Official BBB API Reference: https://docs.bigbluebutton.org/development/api#getrecordings
Optional Parameters:
meetingID(string): Filter by meeting ID (if not provided, returns all recordings)recordID(string): Filter by recording IDstate('processing' | 'processed' | 'published' | 'unpublished' | 'deleted' | 'any'): Filter by statemeta_*(string): Metadata filters (key-value pairs with meta_ prefix)
Response Fields:
returncode('SUCCESS' | 'FAILED'): API response statusrecordings(Recording[]): Array of recording objectsmessage(string, optional): Response messagemessageKey(string, optional): Message key for localization
Recording Object Fields:
recordID(string): Recording identifiermeetingID(string): Meeting identifierinternalMeetingID(string): Internal meeting identifiername(string): Recording nameisBreakout(boolean): Whether from breakout roompublished(boolean): Whether recording is publishedstate(string): Recording statestartTime(number): Recording start timestampendTime(number): Recording end timestampparticipants(number): Number of participantsmetadata(Record<string, string>, optional): Recording metadataplayback(object, optional): Playback format information
// Get all recordings
const result = await client.getRecordings();
console.log('Status:', result.returncode);
console.log('Total recordings:', result.recordings.length);
// Get recordings for a specific meeting
const meetingResult = await client.getRecordings({
meetingID: 'meeting-123'
});
// Get published recordings
const publishedResult = await client.getRecordings({
state: 'published'
});
meetingResult.recordings.forEach(recording => {
console.log('Recording:', recording.name);
console.log('Duration:', recording.endTime - recording.startTime);
console.log('Participants:', recording.participants);
});insertDocument(params): Promise<InsertDocumentResponse>
Inserts presentation documents into a running meeting.
Available since BigBlueButton 2.5
Official BBB API Reference: https://docs.bigbluebutton.org/development/api#insertdocument
Required Parameters:
meetingID(string): Meeting ID to insert documents intodocuments(Document[]): Array of documents to insert (must have at least one)
Document Object Properties:
url(string, optional): URL of the document (mutually exclusive withcontent)content(string, optional): Base64 encoded document content (mutually exclusive withurl)filename(string, optional): Filename (useful if URL lacks extension)downloadable(boolean, optional): Whether document can be downloaded (default: false)removable(boolean, optional): Whether document can be removed (default: true)
Note: The first document in the array will be loaded immediately in the client. Other documents will be processed in the background.
Response Fields:
returncode('SUCCESS' | 'FAILED'): API response statusmessage(string, optional): Response messagemessageKey(string, optional): Message key for localization
Throws: BBBConfigError if documents array is empty or invalid
// Insert a document from URL
const result = await client.insertDocument({
meetingID: 'meeting-123',
documents: [
{
url: 'https://example.com/presentation.pdf',
filename: 'slides.pdf'
}
]
});
console.log('Status:', result.returncode);
// Insert multiple documents with options
await client.insertDocument({
meetingID: 'meeting-123',
documents: [
{
url: 'https://example.com/doc1.pdf',
filename: 'document1.pdf',
downloadable: true,
removable: false
},
{
content: 'JVBERi0xLjQKJeLjz9MKMy...', // Base64 encoded PDF
filename: 'document2.pdf'
}
]
});Error Handling
The library provides custom error classes for better error handling:
import {
BBBError, // Base error class
BBBAPIError, // API returned error
BBBNetworkError, // Network request failed
BBBParseError, // XML parsing failed
BBBConfigError // Invalid configuration
} from 'bbb-api-js';
try {
const meeting = await client.create({
meetingID: 'test',
name: 'Test Meeting'
});
} catch (error) {
if (error instanceof BBBAPIError) {
console.error('API Error:', error.message);
console.error('Message Key:', error.messageKey);
} else if (error instanceof BBBNetworkError) {
console.error('Network Error:', error.message);
} else if (error instanceof BBBConfigError) {
console.error('Configuration Error:', error.message);
}
}Complete Example
Here's a complete example showing a typical workflow:
import { BBBClient } from 'bbb-api-js';
async function runMeeting() {
// Initialize client
const client = new BBBClient({
serverUrl: 'https://bbb.example.com/bigbluebutton/api',
secret: 'your-shared-secret'
});
try {
// Create a meeting
const meeting = await client.create({
meetingID: 'demo-meeting',
name: 'Demo Meeting',
attendeePW: 'attendee123',
moderatorPW: 'moderator456',
record: true,
autoStartRecording: true,
allowStartStopRecording: true,
welcome: 'Welcome to the demo!',
meta_description: 'This is a demo meeting'
});
console.log('Meeting created successfully!');
console.log('Meeting ID:', meeting.meetingID);
// Generate join URLs
const moderatorUrl = client.join({
fullName: 'Moderator',
meetingID: meeting.meetingID,
password: meeting.moderatorPW
});
const attendeeUrl = client.join({
fullName: 'Attendee',
meetingID: meeting.meetingID,
password: meeting.attendeePW
});
console.log('Moderator URL:', moderatorUrl);
console.log('Attendee URL:', attendeeUrl);
// Wait a bit, then check meeting info
await new Promise(resolve => setTimeout(resolve, 5000));
const info = await client.getMeetingInfo(meeting.meetingID);
console.log('Meeting is running:', info.running);
console.log('Participant count:', info.participantCount);
// Get recordings (if any exist)
const recordings = await client.getRecordings({
meetingID: meeting.meetingID
});
console.log('Recordings found:', recordings.length);
// End the meeting
await client.endMeeting(meeting.meetingID, meeting.moderatorPW);
console.log('Meeting ended');
} catch (error) {
console.error('Error:', error);
}
}
runMeeting();TypeScript Support
This library is written in TypeScript and provides full type definitions. All parameters and return types are fully typed:
import type {
BBBClientConfig,
CreateMeetingParams,
CreateMeetingResponse,
JoinMeetingParams,
MeetingInfo,
Recording,
Attendee
} from 'bbb-api-js';
// Your IDE will provide full autocomplete and type checkingDevelopment
Build
npm run buildRun Tests
npm testRun Tests with Coverage
npm run test:coverageLicense
ISC
Links
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
