WebSocket API
Connect to Vexa's WebSocket API to receive real-time transcript updates as meetings progress.
Overview
The WebSocket API allows you to receive live transcript segments as they are generated during meetings. Connect once and subscribe to multiple meetings for efficient real-time updates.
Connection
Connect to the WebSocket endpoint
WebSocket URL format (derived from your API URL):
wss://api.vexa.ai/ws?api_key=YOUR_API_KEYNote: Authentication is done via query parameter since browsers cannot set custom headers for WebSocket connections.
Subscribe to Meetings
Send a subscribe message after connecting
{
"action": "subscribe",
"meetings": [
{
"platform": "google_meet",
"native_id": "abc-defg-hij"
}
]
}Keepalive
Send ping messages to keep the connection alive
{
"action": "ping"
}Send a ping every 25 seconds to maintain the connection. The server will respond with a pong message.
Message Types
transcript.mutable- Live transcript segments that may be updatedtranscript.finalized- Final transcript segmentsmeeting.status- Meeting status updatessubscribed- Confirmation of successful subscriptionpong- Response to ping messageserror- Error messages
Code Examples
const ws = new WebSocket('wss://api.vexa.ai/ws?api_key=YOUR_API_KEY');
ws.onopen = () => {
// Subscribe to meeting
ws.send(JSON.stringify({
action: 'subscribe',
meetings: [
{ platform: 'google_meet', native_id: 'abc-defg-hij' }
]
}));
// Start ping interval
setInterval(() => {
ws.send(JSON.stringify({ action: 'ping' }));
}, 25000);
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
switch (message.type) {
case 'transcript.mutable':
case 'transcript.finalized':
// Process transcript segments
message.payload.segments.forEach(segment => {
console.log(`[${segment.speaker}] ${segment.text}`);
});
break;
case 'meeting.status':
console.log('Status:', message.payload.status);
break;
case 'subscribed':
console.log('Subscribed to meetings:', message.meetings);
break;
}
};