chub-dev 0.1.0 → 0.1.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/bin/chub-mcp +2 -0
- package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
- package/dist/airtable/docs/database/python/DOC.md +1735 -0
- package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
- package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
- package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
- package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
- package/dist/asana/docs/tasks/DOC.md +1396 -0
- package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
- package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
- package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
- package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
- package/dist/auth0/docs/identity/python/DOC.md +1199 -0
- package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
- package/dist/aws/docs/s3/python/DOC.md +1807 -0
- package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
- package/dist/binance/docs/trading/python/DOC.md +1454 -0
- package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
- package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
- package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
- package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
- package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
- package/dist/clerk/docs/auth/python/DOC.md +274 -0
- package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
- package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
- package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
- package/dist/cohere/docs/llm/DOC.md +1335 -0
- package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
- package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
- package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
- package/dist/deepgram/docs/speech/python/DOC.md +685 -0
- package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
- package/dist/deepl/docs/translation/python/DOC.md +944 -0
- package/dist/deepseek/docs/llm/DOC.md +1220 -0
- package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
- package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
- package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
- package/dist/discord/docs/bot/python/DOC.md +1130 -0
- package/dist/elasticsearch/docs/search/DOC.md +1634 -0
- package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
- package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
- package/dist/firebase/docs/auth/DOC.md +1015 -0
- package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
- package/dist/gemini/docs/genai/python/DOC.md +555 -0
- package/dist/github/docs/octokit/DOC.md +1560 -0
- package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
- package/dist/google/docs/bigquery/python/DOC.md +1503 -0
- package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
- package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
- package/dist/huggingface/docs/transformers/DOC.md +948 -0
- package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
- package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
- package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
- package/dist/jira/docs/issues/python/DOC.md +1492 -0
- package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
- package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
- package/dist/landingai-ade/docs/api/DOC.md +620 -0
- package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
- package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
- package/dist/landingai-ade/skills/SKILL.md +489 -0
- package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
- package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
- package/dist/linear/docs/tracker/DOC.md +1554 -0
- package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
- package/dist/livekit/docs/realtime/python/DOC.md +163 -0
- package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
- package/dist/meilisearch/docs/search/DOC.md +1241 -0
- package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
- package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
- package/dist/mongodb/docs/atlas/DOC.md +2041 -0
- package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
- package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
- package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
- package/dist/okta/docs/identity/python/DOC.md +1401 -0
- package/dist/openai/docs/chat/javascript/DOC.md +407 -0
- package/dist/openai/docs/chat/python/DOC.md +568 -0
- package/dist/paypal/docs/checkout/DOC.md +278 -0
- package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
- package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
- package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
- package/dist/plaid/docs/banking/python/DOC.md +1203 -0
- package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
- package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
- package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
- package/dist/prisma/docs/orm/python/DOC.md +1317 -0
- package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
- package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
- package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
- package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
- package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
- package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
- package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
- package/dist/redis/docs/key-value/python/DOC.md +2054 -0
- package/dist/registry.json +2817 -0
- package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
- package/dist/resend/docs/email/DOC.md +1271 -0
- package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
- package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
- package/dist/search-index.json +1 -0
- package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
- package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
- package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
- package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
- package/dist/shopify/docs/storefront/DOC.md +457 -0
- package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
- package/dist/slack/docs/workspace/python/DOC.md +271 -0
- package/dist/square/docs/payments/javascript/DOC.md +1855 -0
- package/dist/square/docs/payments/python/DOC.md +1728 -0
- package/dist/stripe/docs/api/DOC.md +1727 -0
- package/dist/stripe/docs/payments/DOC.md +1726 -0
- package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
- package/dist/stytch/docs/auth/python/DOC.md +1962 -0
- package/dist/supabase/docs/client/DOC.md +1606 -0
- package/dist/twilio/docs/messaging/python/DOC.md +469 -0
- package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
- package/dist/vercel/docs/platform/DOC.md +1940 -0
- package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
- package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
- package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
- package/dist/zendesk/docs/support/python/DOC.md +2297 -0
- package/package.json +22 -6
- package/skills/get-api-docs/SKILL.md +84 -0
- package/src/commands/annotate.js +83 -0
- package/src/commands/build.js +12 -1
- package/src/commands/feedback.js +150 -0
- package/src/commands/get.js +83 -42
- package/src/commands/search.js +7 -0
- package/src/index.js +43 -17
- package/src/lib/analytics.js +90 -0
- package/src/lib/annotations.js +57 -0
- package/src/lib/bm25.js +170 -0
- package/src/lib/cache.js +69 -6
- package/src/lib/config.js +8 -3
- package/src/lib/identity.js +99 -0
- package/src/lib/registry.js +103 -20
- package/src/lib/telemetry.js +86 -0
- package/src/mcp/server.js +177 -0
- package/src/mcp/tools.js +251 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: realtime
|
|
3
|
+
description: "LiveKit Client SDK for JavaScript/TypeScript enabling real-time video, audio, and data communication via WebRTC."
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "javascript"
|
|
6
|
+
versions: "2.15.13"
|
|
7
|
+
updated-on: "2026-03-01"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "livekit,realtime,webrtc,video,audio"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# LiveKit Client SDK Coding Guidelines (JavaScript/TypeScript)
|
|
13
|
+
|
|
14
|
+
You are a LiveKit Client SDK expert. Help me with writing code using the LiveKit Client SDK for JavaScript/TypeScript. Please follow the following guidelines when generating code. You can find the official SDK documentation and code samples here: https://docs.livekit.io
|
|
15
|
+
|
|
16
|
+
## Golden Rule: Use the Current LiveKit Client SDK
|
|
17
|
+
|
|
18
|
+
Always use the official LiveKit Client SDK for JavaScript/TypeScript, which is the standard library for all LiveKit real-time communication interactions.
|
|
19
|
+
|
|
20
|
+
- **Library Name:** LiveKit Client SDK
|
|
21
|
+
- **Package Name:** `livekit-client`
|
|
22
|
+
- **Current Version:** 2.11.3
|
|
23
|
+
|
|
24
|
+
**Installation:**
|
|
25
|
+
- **Correct:** `npm install livekit-client`
|
|
26
|
+
- **Correct:** `yarn add livekit-client`
|
|
27
|
+
- **Correct:** `pnpm add livekit-client`
|
|
28
|
+
|
|
29
|
+
**Import Patterns:**
|
|
30
|
+
- **Correct:** `import { Room, connect } from 'livekit-client'`
|
|
31
|
+
- **Correct:** `import { LocalParticipant, RemoteParticipant } from 'livekit-client'`
|
|
32
|
+
- **Correct:** `import { Track, RoomEvent } from 'livekit-client'`
|
|
33
|
+
- **Correct:** `import { createLocalTracks } from 'livekit-client'`
|
|
34
|
+
|
|
35
|
+
## Core Architecture
|
|
36
|
+
|
|
37
|
+
The LiveKit Client SDK is built around three main concepts: **Rooms**, **Participants**, and **Tracks** <cite />. Understanding this hierarchy is crucial for effective usage.
|
|
38
|
+
|
|
39
|
+
### Room Connection
|
|
40
|
+
|
|
41
|
+
Always start by connecting to a room using the `connect` function:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { connect, Room } from 'livekit-client';
|
|
45
|
+
|
|
46
|
+
const room = await connect(url, token, {
|
|
47
|
+
// connection options
|
|
48
|
+
autoSubscribe: true,
|
|
49
|
+
publishDefaults: {
|
|
50
|
+
simulcast: true,
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Event-Driven Architecture
|
|
56
|
+
|
|
57
|
+
LiveKit uses an event-driven model. Always set up event listeners before connecting <cite />:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
room.on(RoomEvent.Connected, () => {
|
|
61
|
+
console.log('Connected to room');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
room.on(RoomEvent.ParticipantConnected, (participant) => {
|
|
65
|
+
console.log('Participant joined:', participant.identity);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
room.on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
|
|
69
|
+
if (track.kind === Track.Kind.Video) {
|
|
70
|
+
const videoElement = track.attach();
|
|
71
|
+
document.body.appendChild(videoElement);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Media Management
|
|
77
|
+
|
|
78
|
+
### Publishing Local Media
|
|
79
|
+
|
|
80
|
+
Use the `LocalParticipant` methods for common media types:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const localParticipant = room.localParticipant;
|
|
84
|
+
|
|
85
|
+
// Enable camera and microphone
|
|
86
|
+
await localParticipant.setCameraEnabled(true);
|
|
87
|
+
await localParticipant.setMicrophoneEnabled(true);
|
|
88
|
+
|
|
89
|
+
// Enable screen sharing
|
|
90
|
+
await localParticipant.setScreenShareEnabled(true);
|
|
91
|
+
|
|
92
|
+
// Disable camera (mute)
|
|
93
|
+
await localParticipant.setCameraEnabled(false);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Publishing Custom Tracks
|
|
97
|
+
|
|
98
|
+
For custom media sources, use `publishTrack`:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const publication = await room.localParticipant.publishTrack(mediaStreamTrack, {
|
|
102
|
+
name: 'mytrack',
|
|
103
|
+
simulcast: true,
|
|
104
|
+
source: Track.Source.Camera, // or .Microphone, .ScreenShare
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Mute or unpublish later
|
|
108
|
+
publication.setMuted(true);
|
|
109
|
+
room.localParticipant.unpublishTrack(mediaStreamTrack);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Subscribing to Remote Media
|
|
113
|
+
|
|
114
|
+
Access remote participants and their tracks:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const remoteParticipant = room.remoteParticipants.get('participant-identity');
|
|
118
|
+
if (remoteParticipant) {
|
|
119
|
+
if (remoteParticipant.isCameraEnabled) {
|
|
120
|
+
const publication = remoteParticipant.getTrackPublication(Track.Source.Camera);
|
|
121
|
+
if (publication?.isSubscribed) {
|
|
122
|
+
const videoElement = publication.videoTrack?.attach();
|
|
123
|
+
// Add to DOM
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Advanced Features
|
|
130
|
+
|
|
131
|
+
### Pre-creating Tracks
|
|
132
|
+
|
|
133
|
+
Create tracks before joining a room for staging areas:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const tracks = await createLocalTracks({
|
|
137
|
+
audio: true,
|
|
138
|
+
video: true,
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Device Management
|
|
143
|
+
|
|
144
|
+
List and switch between devices:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// List devices
|
|
148
|
+
const devices = await Room.getLocalDevices('audioinput');
|
|
149
|
+
|
|
150
|
+
// Switch to specific device
|
|
151
|
+
const device = devices[devices.length - 1];
|
|
152
|
+
await room.switchActiveDevice('audioinput', device.deviceId);
|
|
153
|
+
|
|
154
|
+
// Switch using constraints (mobile camera)
|
|
155
|
+
await videoTrack.restartTrack({
|
|
156
|
+
facingMode: 'environment',
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Error Handling
|
|
161
|
+
|
|
162
|
+
Handle device failures properly:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
room.on(RoomEvent.MediaDevicesError, (error) => {
|
|
166
|
+
const failure = MediaDeviceFailure.getFailure(error);
|
|
167
|
+
switch (failure) {
|
|
168
|
+
case 'PermissionDenied':
|
|
169
|
+
// Handle permission denied
|
|
170
|
+
break;
|
|
171
|
+
case 'NotFound':
|
|
172
|
+
// Handle device not found
|
|
173
|
+
break;
|
|
174
|
+
case 'DeviceInUse':
|
|
175
|
+
// Handle device in use
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Check last errors
|
|
181
|
+
console.log(room.localParticipant.lastCameraError);
|
|
182
|
+
console.log(room.localParticipant.lastMicrophoneError);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### RPC (Remote Procedure Calls)
|
|
186
|
+
|
|
187
|
+
For participant-to-participant communication:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Register an RPC method
|
|
191
|
+
room.localParticipant?.registerRpcMethod(
|
|
192
|
+
'greet',
|
|
193
|
+
async (data: RpcInvocationData) => {
|
|
194
|
+
console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`);
|
|
195
|
+
return `Hello, ${data.callerIdentity}!`;
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Call an RPC method
|
|
200
|
+
try {
|
|
201
|
+
const response = await room.localParticipant!.performRpc({
|
|
202
|
+
destinationIdentity: 'recipient-identity',
|
|
203
|
+
method: 'greet',
|
|
204
|
+
payload: 'Hello from RPC!',
|
|
205
|
+
});
|
|
206
|
+
console.log('RPC response:', response);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error('RPC call failed:', error);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Video Quality and Simulcast
|
|
213
|
+
|
|
214
|
+
### Simulcast Configuration
|
|
215
|
+
|
|
216
|
+
The SDK automatically configures simulcast layers based on video resolution. Default presets include:
|
|
217
|
+
|
|
218
|
+
- **16:9 content:** Uses `h180` and `h360` simulcast layers
|
|
219
|
+
- **4:3 content:** Uses corresponding 4:3 presets
|
|
220
|
+
- **Screen sharing:** Uses custom calculated layers
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
// Enable simulcast (recommended)
|
|
224
|
+
await room.localParticipant.publishTrack(videoTrack, {
|
|
225
|
+
simulcast: true,
|
|
226
|
+
videoCodec: 'vp9', // or 'vp8', 'h264', 'av1'
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Connection Quality
|
|
231
|
+
|
|
232
|
+
### Monitor Connection Quality
|
|
233
|
+
|
|
234
|
+
Track participant connection quality:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
room.on(RoomEvent.ConnectionQualityChanged, (quality, participant) => {
|
|
238
|
+
console.log(`${participant.identity} quality: ${quality}`);
|
|
239
|
+
// quality can be: 'excellent', 'good', 'poor', 'lost', 'unknown'
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Browser Compatibility
|
|
244
|
+
|
|
245
|
+
The SDK supports modern browsers:
|
|
246
|
+
|
|
247
|
+
- Chrome (desktop and Android)
|
|
248
|
+
- Firefox (desktop and Android)
|
|
249
|
+
- Safari (macOS and iOS)
|
|
250
|
+
- Edge (Chromium-based)
|
|
251
|
+
|
|
252
|
+
Check compatibility:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { isBrowserSupported, supportsAdaptiveStream, supportsDynacast } from 'livekit-client';
|
|
256
|
+
|
|
257
|
+
if (!isBrowserSupported()) {
|
|
258
|
+
console.warn('Browser not supported');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (supportsAdaptiveStream()) {
|
|
262
|
+
// Enable adaptive streaming features
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Best Practices
|
|
267
|
+
|
|
268
|
+
1. **Always handle events:** Set up event listeners before connecting
|
|
269
|
+
2. **Use simulcast:** Enable simulcast for better quality adaptation
|
|
270
|
+
3. **Handle errors gracefully:** Implement proper error handling for device failures
|
|
271
|
+
4. **Clean up resources:** Disconnect from rooms and dispose of tracks when done
|
|
272
|
+
5. **Check browser support:** Verify compatibility before initializing
|
|
273
|
+
6. **Use TypeScript:** The SDK is built with TypeScript for better developer experience
|
|
274
|
+
|
|
275
|
+
## Error Codes
|
|
276
|
+
|
|
277
|
+
Common error codes you may encounter:
|
|
278
|
+
|
|
279
|
+
| Code | Name | Reason |
|
|
280
|
+
|------|------|--------|
|
|
281
|
+
| 1 | `ConnectionError` | Various connection issues |
|
|
282
|
+
| 10 | `UnsupportedServer` | Server version incompatible |
|
|
283
|
+
| 12 | `UnexpectedConnectionState` | Connection state error |
|
|
284
|
+
| 13 | `NegotiationError` | WebRTC negotiation failed |
|
|
285
|
+
| 20 | `TrackInvalidError` | Track-related error |
|
|
286
|
+
| 21 | `DeviceUnsupportedError` | Device not supported |
|
|
287
|
+
| 40 | `CryptorError` | E2EE encryption error |
|
|
288
|
+
|
|
289
|
+
## Useful Links
|
|
290
|
+
|
|
291
|
+
- Documentation: https://docs.livekit.io
|
|
292
|
+
- GitHub Repository: https://github.com/livekit/client-sdk-js
|
|
293
|
+
- Examples: https://github.com/livekit-examples
|
|
294
|
+
- LiveKit Cloud: https://livekit.io/cloud
|
|
295
|
+
|
|
296
|
+
## Notes
|
|
297
|
+
|
|
298
|
+
This guide covers the core functionality of the LiveKit Client SDK. The SDK also includes advanced features like End-to-End Encryption (E2EE), connection diagnostics, and sophisticated media transport optimizations that are documented in the Advanced Features section of the codebase <cite />. For React applications, consider using the LiveKit React Components library for pre-built UI components.
|
|
299
|
+
|
|
300
|
+
Wiki pages you might want to explore:
|
|
301
|
+
- [Overview (livekit/client-sdk-js)](/wiki/livekit/client-sdk-js#1)
|
|
302
|
+
- [Advanced Features (livekit/client-sdk-js)](/wiki/livekit/client-sdk-js#6)
|
|
303
|
+
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: realtime
|
|
3
|
+
description: "LiveKit Python SDK for real-time video, audio, and data communication including room management and recording."
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "python"
|
|
6
|
+
versions: "1.0.17"
|
|
7
|
+
updated-on: "2026-03-01"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "livekit,realtime,webrtc,video,audio"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# LiveKit Python SDK Example
|
|
13
|
+
|
|
14
|
+
This repository contains an interactive Streamlit demo application showcasing the LiveKit Python SDK capabilities for real-time video, audio, and data communication.
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
The example demonstrates key LiveKit Python SDK features including:
|
|
19
|
+
- Access token generation
|
|
20
|
+
- Room management operations
|
|
21
|
+
- Recording (Egress) functionality
|
|
22
|
+
- Real-time connection handling
|
|
23
|
+
- Remote Procedure Calls (RPC)
|
|
24
|
+
- Environment configuration
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
- Python 3.8 or higher
|
|
29
|
+
- LiveKit server instance (LiveKit Cloud or self-hosted)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
1. **Install dependencies:**
|
|
34
|
+
```bash
|
|
35
|
+
pip install streamlit livekit livekit-api
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or using the provided pyproject.toml:
|
|
39
|
+
```bash
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
2. **Set up environment variables:**
|
|
44
|
+
|
|
45
|
+
Copy the sample environment file and configure your LiveKit credentials:
|
|
46
|
+
```bash
|
|
47
|
+
cp example/.env.sample example/.env
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Edit `example/.env` with your LiveKit server details:
|
|
51
|
+
```
|
|
52
|
+
LIVEKIT_URL=wss://your-project.livekit.cloud
|
|
53
|
+
LIVEKIT_API_KEY=your-api-key
|
|
54
|
+
LIVEKIT_API_SECRET=your-api-secret
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Running the Demo
|
|
58
|
+
|
|
59
|
+
1. **Navigate to the example directory:**
|
|
60
|
+
```bash
|
|
61
|
+
cd example
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **Run the Streamlit application:**
|
|
65
|
+
```bash
|
|
66
|
+
streamlit run app.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
3. **Open your browser:**
|
|
70
|
+
The application will automatically open in your default browser at `http://localhost:8501`
|
|
71
|
+
|
|
72
|
+
## Demo Features
|
|
73
|
+
|
|
74
|
+
### Access Token Generation
|
|
75
|
+
Generate JWT tokens for client authentication with configurable:
|
|
76
|
+
- User identity and display name
|
|
77
|
+
- Room permissions (join, publish, subscribe)
|
|
78
|
+
- Token expiration settings
|
|
79
|
+
|
|
80
|
+
### Room Management
|
|
81
|
+
Demonstrate server API capabilities:
|
|
82
|
+
- Create new rooms with custom settings
|
|
83
|
+
- List existing rooms
|
|
84
|
+
- Delete rooms
|
|
85
|
+
- Manage room participants
|
|
86
|
+
|
|
87
|
+
### Recording (Egress)
|
|
88
|
+
Show recording functionality:
|
|
89
|
+
- Start room composite recordings
|
|
90
|
+
- Configure output formats
|
|
91
|
+
- Monitor recording status
|
|
92
|
+
|
|
93
|
+
### Real-time Connection
|
|
94
|
+
Interactive examples of:
|
|
95
|
+
- Connecting to rooms as a participant
|
|
96
|
+
- Handling track subscriptions
|
|
97
|
+
- Processing video/audio streams
|
|
98
|
+
- Managing connection events
|
|
99
|
+
|
|
100
|
+
### RPC Methods
|
|
101
|
+
Remote procedure call demonstrations:
|
|
102
|
+
- Register RPC method handlers
|
|
103
|
+
- Perform RPC calls between participants
|
|
104
|
+
- Handle responses and errors
|
|
105
|
+
|
|
106
|
+
## Project Structure
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
example/
|
|
110
|
+
├── app.py # Main Streamlit application
|
|
111
|
+
├── pyproject.toml # Project dependencies and configuration
|
|
112
|
+
├── .env.sample # Environment variables template
|
|
113
|
+
└── .streamlit/ # Streamlit configuration
|
|
114
|
+
└── config.toml
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## SDK Documentation
|
|
118
|
+
|
|
119
|
+
For comprehensive documentation and additional examples:
|
|
120
|
+
- **Official Documentation**: https://docs.livekit.io/
|
|
121
|
+
- **Python SDK Guide**: https://docs.livekit.io/home/client/connect/
|
|
122
|
+
- **Server API Reference**: https://docs.livekit.io/reference/server/server-apis
|
|
123
|
+
- **Community Examples**: https://github.com/livekit-examples
|
|
124
|
+
|
|
125
|
+
## Environment Variables
|
|
126
|
+
|
|
127
|
+
The application requires the following environment variables:
|
|
128
|
+
|
|
129
|
+
| Variable | Description | Required |
|
|
130
|
+
|----------|-------------|----------|
|
|
131
|
+
| `LIVEKIT_URL` | LiveKit server WebSocket URL | Yes |
|
|
132
|
+
| `LIVEKIT_API_KEY` | API authentication key | Yes |
|
|
133
|
+
| `LIVEKIT_API_SECRET` | API authentication secret | Yes |
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
### Code Style
|
|
138
|
+
The project uses Black and Ruff for code formatting and linting:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Format code
|
|
142
|
+
black .
|
|
143
|
+
|
|
144
|
+
# Lint code
|
|
145
|
+
ruff check .
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Testing
|
|
149
|
+
Run tests using pytest:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pytest
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Support
|
|
156
|
+
|
|
157
|
+
- **Documentation**: https://docs.livekit.io/
|
|
158
|
+
- **Community Slack**: https://livekit.io/join-slack
|
|
159
|
+
- **GitHub Issues**: Report issues on the respective SDK repositories
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
This example is provided under the same license as the LiveKit Python SDK.
|