Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/realtimekit/api.md
1# RealtimeKit API Reference23Complete API reference for Meeting object, REST endpoints, and SDK methods.45## Meeting Object API67### `meeting.self` - Local Participant89```typescript10// Properties: id, userId, name, audioEnabled, videoEnabled, screenShareEnabled, audioTrack, videoTrack, screenShareTracks, roomJoined, roomState11// Methods12await meeting.self.enableAudio() / disableAudio() / enableVideo() / disableVideo() / enableScreenShare() / disableScreenShare()13await meeting.self.setName("Name") // Before join only14await meeting.self.setDevice(device)15const devices = await meeting.self.getAllDevices() / getAudioDevices() / getVideoDevices() / getSpeakerDevices()16// Events: 'roomJoined', 'audioUpdate', 'videoUpdate', 'screenShareUpdate', 'deviceUpdate', 'deviceListUpdate'17meeting.self.on('roomJoined', () => {})18meeting.self.on('audioUpdate', ({ audioEnabled, audioTrack }) => {})19```2021### `meeting.participants` - Remote Participants2223**Collections**:24```typescript25meeting.participants.joined / active / waitlisted / pinned // Maps26const participants = meeting.participants.joined.toArray()27const count = meeting.participants.joined.size()28const p = meeting.participants.joined.get('peer-id')29```3031**Participant Properties**:32```typescript33participant.id / userId / name34participant.audioEnabled / videoEnabled / screenShareEnabled35participant.audioTrack / videoTrack / screenShareTracks36```3738**Events**:39```typescript40meeting.participants.joined.on('participantJoined', (participant) => {})41meeting.participants.joined.on('participantLeft', (participant) => {})42```4344### `meeting.meta` - Metadata45```typescript46meeting.meta.meetingId / meetingTitle / meetingStartedTimestamp47```4849### `meeting.chat` - Chat50```typescript51meeting.chat.messages // Array52await meeting.chat.sendTextMessage("Hello") / sendImageMessage(file)53meeting.chat.on('chatUpdate', ({ message, messages }) => {})54```5556### `meeting.polls` - Polling57```typescript58meeting.polls.items // Array59await meeting.polls.create(question, options, anonymous, hideVotes)60await meeting.polls.vote(pollId, optionIndex)61```6263### `meeting.plugins` - Collaborative Apps64```typescript65meeting.plugins.all // Array66await meeting.plugins.activate(pluginId) / deactivate()67```6869### `meeting.ai` - AI Features70```typescript71meeting.ai.transcripts // Live transcriptions (when enabled in Preset)72```7374### Core Methods75```typescript76await meeting.join() // Emits 'roomJoined' on meeting.self77await meeting.leave()78```7980## TypeScript Types8182```typescript83import type { RealtimeKitClient, States, UIConfig, Participant } from '@cloudflare/realtimekit';8485// Main interface86interface RealtimeKitClient {87self: SelfState; // Local participant (id, userId, name, audioEnabled, videoEnabled, roomJoined, roomState)88participants: { joined, active, waitlisted, pinned }; // Reactive Maps89chat: ChatNamespace; // messages[], sendTextMessage(), sendImageMessage()90polls: PollsNamespace; // items[], create(), vote()91plugins: PluginsNamespace; // all[], activate(), deactivate()92ai: AINamespace; // transcripts[]93meta: MetaState; // meetingId, meetingTitle, meetingStartedTimestamp94join(): Promise<void>;95leave(): Promise<void>;96}9798// Participant (self & remote share same shape)99interface Participant {100id: string; // Peer ID (changes on rejoin)101userId: string; // Persistent participant ID102name: string;103audioEnabled: boolean;104videoEnabled: boolean;105screenShareEnabled: boolean;106audioTrack: MediaStreamTrack | null;107videoTrack: MediaStreamTrack | null;108screenShareTracks: MediaStreamTrack[];109}110```111112## Store Architecture113114RealtimeKit uses reactive store (event-driven updates, live Maps):115116```typescript117// Subscribe to state changes118meeting.self.on('audioUpdate', ({ audioEnabled, audioTrack }) => {});119meeting.participants.joined.on('participantJoined', (p) => {});120121// Access current state synchronously122const isAudioOn = meeting.self.audioEnabled;123const count = meeting.participants.joined.size();124```125126**Key principles:** State updates emit events after changes. Use `.toArray()` sparingly. Collections are live Maps.127128## REST API129130Base: `https://api.cloudflare.com/client/v4/accounts/{account_id}/realtime/kit/{app_id}`131132### Meetings133```bash134GET /meetings # List all135GET /meetings/{meeting_id} # Get details136POST /meetings # Create: {"title": "..."}137PATCH /meetings/{meeting_id} # Update: {"title": "...", "record_on_start": true}138```139140### Participants141```bash142GET /meetings/{meeting_id}/participants # List all143GET /meetings/{meeting_id}/participants/{participant_id} # Get details144POST /meetings/{meeting_id}/participants # Add: {"name": "...", "preset_name": "...", "custom_participant_id": "..."}145PATCH /meetings/{meeting_id}/participants/{participant_id} # Update: {"name": "...", "preset_name": "..."}146DELETE /meetings/{meeting_id}/participants/{participant_id} # Delete147POST /meetings/{meeting_id}/participants/{participant_id}/token # Refresh token148```149150### Active Session151```bash152GET /meetings/{meeting_id}/active-session # Get active session153POST /meetings/{meeting_id}/active-session/kick # Kick users: {"user_ids": ["id1", "id2"]}154POST /meetings/{meeting_id}/active-session/kick-all # Kick all155POST /meetings/{meeting_id}/active-session/poll # Create poll: {"question": "...", "options": [...], "anonymous": false}156```157158### Recording159```bash160GET /recordings?meeting_id={meeting_id} # List recordings161GET /recordings/active-recording/{meeting_id} # Get active recording162POST /recordings # Start: {"meeting_id": "...", "type": "composite"} (or "track")163PUT /recordings/{recording_id} # Control: {"action": "pause"} (or "resume", "stop")164POST /recordings/track # Track recording: {"meeting_id": "...", "layers": [...]}165```166167### Livestreaming168```bash169GET /livestreams?exclude_meetings=false # List all170GET /livestreams/{livestream_id} # Get details171POST /meetings/{meeting_id}/livestreams # Start for meeting172POST /meetings/{meeting_id}/active-livestream/stop # Stop173POST /livestreams # Create independent: returns {ingest_server, stream_key, playback_url}174```175176### Sessions & Analytics177```bash178GET /sessions # List all179GET /sessions/{session_id} # Get details180GET /sessions/{session_id}/participants # List participants181GET /sessions/{session_id}/participants/{participant_id} # Call stats182GET /sessions/{session_id}/chat # Download chat CSV183GET /sessions/{session_id}/transcript # Download transcript CSV184GET /sessions/{session_id}/summary # Get summary185POST /sessions/{session_id}/summary # Generate summary186GET /analytics/daywise?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD # Day-wise analytics187GET /analytics/livestreams/overall # Livestream analytics188```189190### Webhooks191```bash192GET /webhooks # List all193POST /webhooks # Create: {"url": "https://...", "events": ["session.started", "session.ended"]}194PATCH /webhooks/{webhook_id} # Update195DELETE /webhooks/{webhook_id} # Delete196```197198## Session Lifecycle199200```201Initialization → Join Intent → [Waitlist?] → Meeting Screen (Stage) → Ended202↓ Approved203[Rejected → Ended]204```205206UI Kit handles state transitions automatically.207208## See Also209210- [Configuration](./configuration.md) - Setup and installation211- [Patterns](./patterns.md) - Usage examples212- [README](./README.md) - Overview and quick start213