livekit-api 1.2.0__tar.gz → 1.2.1__tar.gz

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.
Files changed (23) hide show
  1. livekit_api-1.2.1/PKG-INFO +59 -0
  2. livekit_api-1.2.1/README.md +29 -0
  3. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/access_token.py +20 -8
  4. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/egress_service.py +11 -0
  5. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/sip_service.py +8 -4
  6. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/twirp_client.py +7 -0
  7. livekit_api-1.2.1/livekit/api/version.py +1 -0
  8. {livekit_api-1.2.0 → livekit_api-1.2.1}/pyproject.toml +1 -1
  9. livekit_api-1.2.0/PKG-INFO +0 -36
  10. livekit_api-1.2.0/README.md +0 -6
  11. livekit_api-1.2.0/livekit/api/version.py +0 -1
  12. {livekit_api-1.2.0 → livekit_api-1.2.1}/.gitignore +0 -0
  13. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/__init__.py +0 -0
  14. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/_dial_timeout.py +0 -0
  15. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/_failover.py +0 -0
  16. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/_service.py +0 -0
  17. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/agent_dispatch_service.py +0 -0
  18. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/connector_service.py +0 -0
  19. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/ingress_service.py +0 -0
  20. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/livekit_api.py +0 -0
  21. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/py.typed +0 -0
  22. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/room_service.py +0 -0
  23. {livekit_api-1.2.0 → livekit_api-1.2.1}/livekit/api/webhook.py +0 -0
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.5
2
+ Name: livekit-api
3
+ Version: 1.2.1
4
+ Summary: Python Server API for LiveKit
5
+ Project-URL: Documentation, https://docs.livekit.io
6
+ Project-URL: Website, https://livekit.io/
7
+ Project-URL: Source, https://github.com/livekit/python-sdks/
8
+ Author-email: LiveKit <support@livekit.io>
9
+ License-Expression: Apache-2.0
10
+ Keywords: audio,livekit,realtime,video,webrtc
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Multimedia :: Sound/Audio
21
+ Classifier: Topic :: Multimedia :: Video
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.9.0
24
+ Requires-Dist: aiohttp>=3.9.0
25
+ Requires-Dist: livekit-protocol<2.0.0,>=1.1.25
26
+ Requires-Dist: protobuf>=4
27
+ Requires-Dist: pyjwt>=2.0.0
28
+ Requires-Dist: types-protobuf>=4
29
+ Description-Content-Type: text/markdown
30
+
31
+ # LiveKit Server APIs
32
+
33
+ Access LiveKit server APIs and generate access tokens.
34
+
35
+ See https://docs.livekit.io/reference/server/server-apis for more information.
36
+
37
+ ## Authentication
38
+
39
+ Every request to the server APIs is authenticated. `LiveKitAPI` supports two modes:
40
+
41
+ - **API key & secret** — recommended for backend use. The SDK signs a short-lived token per request from your key and secret. Keep your API secret on the server; never ship it to a client.
42
+ - **Access token** — for client-side use where the API secret must not be exposed. Pass a pre-signed [access token](https://docs.livekit.io/home/get-started/authentication/) that already carries the grants for the operations you'll perform; the SDK sends it verbatim.
43
+
44
+ ```python
45
+ from livekit import api
46
+
47
+ # API key & secret: set LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET,
48
+ # then construct with no arguments...
49
+ lkapi = api.LiveKitAPI()
50
+
51
+ # ...or pass any of them explicitly to override the corresponding env var:
52
+ lkapi = api.LiveKitAPI("https://my.livekit.host", api_key="api-key", api_secret="api-secret")
53
+
54
+ # Pre-signed access token (client-side): with LIVEKIT_URL set, pass just the token:
55
+ lkapi = api.LiveKitAPI.with_token("a-pre-signed-token")
56
+ ```
57
+
58
+ The url and credentials fall back to the `LIVEKIT_URL`, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, and `LIVEKIT_TOKEN` environment variables. Values you pass explicitly take precedence; the environment variables are used only as a fallback for arguments you omit — an ambient `LIVEKIT_TOKEN`, for example, won't override an explicitly-provided API key and secret.
59
+
@@ -0,0 +1,29 @@
1
+ # LiveKit Server APIs
2
+
3
+ Access LiveKit server APIs and generate access tokens.
4
+
5
+ See https://docs.livekit.io/reference/server/server-apis for more information.
6
+
7
+ ## Authentication
8
+
9
+ Every request to the server APIs is authenticated. `LiveKitAPI` supports two modes:
10
+
11
+ - **API key & secret** — recommended for backend use. The SDK signs a short-lived token per request from your key and secret. Keep your API secret on the server; never ship it to a client.
12
+ - **Access token** — for client-side use where the API secret must not be exposed. Pass a pre-signed [access token](https://docs.livekit.io/home/get-started/authentication/) that already carries the grants for the operations you'll perform; the SDK sends it verbatim.
13
+
14
+ ```python
15
+ from livekit import api
16
+
17
+ # API key & secret: set LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET,
18
+ # then construct with no arguments...
19
+ lkapi = api.LiveKitAPI()
20
+
21
+ # ...or pass any of them explicitly to override the corresponding env var:
22
+ lkapi = api.LiveKitAPI("https://my.livekit.host", api_key="api-key", api_secret="api-secret")
23
+
24
+ # Pre-signed access token (client-side): with LIVEKIT_URL set, pass just the token:
25
+ lkapi = api.LiveKitAPI.with_token("a-pre-signed-token")
26
+ ```
27
+
28
+ The url and credentials fall back to the `LIVEKIT_URL`, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, and `LIVEKIT_TOKEN` environment variables. Values you pass explicitly take precedence; the environment variables are used only as a fallback for arguments you omit — an ambient `LIVEKIT_TOKEN`, for example, won't override an explicitly-provided API key and secret.
29
+
@@ -233,14 +233,26 @@ class TokenVerifier:
233
233
  if verify_signature and (not self.api_key or not self.api_secret):
234
234
  raise ValueError("api_key and api_secret must be set")
235
235
 
236
- claims = jwt.decode(
237
- token,
238
- key=self.api_secret or "",
239
- issuer=self.api_key or "",
240
- algorithms=["HS256"],
241
- leeway=self._leeway.total_seconds(),
242
- options={"verify_signature": verify_signature},
243
- )
236
+ # First-party minters always set exp. Without this, a hand-rolled token
237
+ # with a valid signature and no exp verifies forever (livekit/protocol#1706).
238
+ if verify_signature:
239
+ claims = jwt.decode(
240
+ token,
241
+ key=self.api_secret or "",
242
+ issuer=self.api_key or "",
243
+ algorithms=["HS256"],
244
+ leeway=self._leeway.total_seconds(),
245
+ options={"verify_signature": True, "require": ["exp"]},
246
+ )
247
+ else:
248
+ claims = jwt.decode(
249
+ token,
250
+ key=self.api_secret or "",
251
+ issuer=self.api_key or "",
252
+ algorithms=["HS256"],
253
+ leeway=self._leeway.total_seconds(),
254
+ options={"verify_signature": False},
255
+ )
244
256
  video_dict = claims.get("video", dict())
245
257
  video_dict = {camel_to_snake(k): v for k, v in video_dict.items()}
246
258
  video_dict = {k: v for k, v in video_dict.items() if k in VideoGrants.__dataclass_fields__}
@@ -9,6 +9,7 @@ from livekit.protocol.egress import (
9
9
  UpdateStreamRequest,
10
10
  ListEgressRequest,
11
11
  StopEgressRequest,
12
+ StartEgressRequest,
12
13
  EgressInfo,
13
14
  ListEgressResponse,
14
15
  )
@@ -93,6 +94,16 @@ class EgressService(Service):
93
94
  EgressInfo,
94
95
  )
95
96
 
97
+ async def start_egress(self, start: StartEgressRequest) -> EgressInfo:
98
+ """Starts an egress; the request's source and outputs determine the egress type."""
99
+ return await self._client.request(
100
+ SVC,
101
+ "StartEgress",
102
+ start,
103
+ self._auth_header(VideoGrants(room_record=True)),
104
+ EgressInfo,
105
+ )
106
+
96
107
  async def update_layout(self, update: UpdateLayoutRequest) -> EgressInfo:
97
108
  """Updates the layout of a composite recording."""
98
109
  return await self._client.request(
@@ -31,6 +31,7 @@ from livekit.protocol.sip import (
31
31
  DeleteSIPDispatchRuleRequest,
32
32
  CreateSIPParticipantRequest,
33
33
  TransferSIPParticipantRequest,
34
+ TransferSIPParticipantResponse,
34
35
  SIPParticipantInfo,
35
36
  SIPTransport,
36
37
  SIPMediaConfig,
@@ -832,8 +833,8 @@ class SipService(Service):
832
833
  transfer: TransferSIPParticipantRequest,
833
834
  *,
834
835
  timeout: Optional[float] = None,
835
- ) -> SIPParticipantInfo:
836
- """Transfer a SIP participant to a different room.
836
+ ) -> TransferSIPParticipantResponse:
837
+ """Transfer a SIP participant to another number or SIP endpoint.
837
838
 
838
839
  Args:
839
840
  transfer: Request containing transfer details
@@ -842,7 +843,10 @@ class SipService(Service):
842
843
  longer timeout when unset.
843
844
 
844
845
  Returns:
845
- Updated SIP participant information
846
+ The outcome of the transfer: its id, status, reason, and the SIP
847
+ status when the outcome came from a SIP response. A status other
848
+ than successful means the transfer did not complete, even when no
849
+ error was raised.
846
850
  """
847
851
  # Transferring a call dials a phone, which takes longer than a normal
848
852
  # call, so keep the request alive past ringing. Pin the ring window so the
@@ -861,7 +865,7 @@ class SipService(Service):
861
865
  ),
862
866
  sip=SIPGrants(call=True),
863
867
  ),
864
- SIPParticipantInfo,
868
+ TransferSIPParticipantResponse,
865
869
  timeout=client_timeout,
866
870
  )
867
871
  except ServerError as e:
@@ -14,6 +14,7 @@
14
14
 
15
15
  import asyncio
16
16
  import logging
17
+ import uuid
17
18
  from typing import Dict, List, Optional, Type, TypeVar
18
19
 
19
20
  import aiohttp
@@ -37,6 +38,11 @@ logger = logging.getLogger("livekit")
37
38
  # Identifies the SDK and version to the server on every request.
38
39
  _USER_AGENT = f"livekit-server-sdk-python/{__version__}"
39
40
 
41
+ # Carries a per-request idempotency key. The SDK's auto-retries (see _failover)
42
+ # keep the same key across attempts, so the server can identify and deduplicate
43
+ # repeated requests.
44
+ REQUEST_ID_HEADER = "X-Livekit-Request-Id"
45
+
40
46
  # Shared across all clients in the process so the region list is fetched once.
41
47
  _REGION_CACHE = RegionCache()
42
48
 
@@ -207,6 +213,7 @@ class TwirpClient:
207
213
  headers["User-Agent"] = _USER_AGENT
208
214
  forward_headers = dict(headers) # for the discovery fetch (no content-type yet)
209
215
  headers["Content-Type"] = "application/protobuf"
216
+ headers[REQUEST_ID_HEADER] = str(uuid.uuid4())
210
217
  serialized_data = data.SerializeToString()
211
218
 
212
219
  # The effective per-attempt timeout is the per-call override, or the
@@ -0,0 +1 @@
1
+ __version__ = "1.2.1"
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "aiohttp>=3.9.0",
33
33
  "protobuf>=4",
34
34
  "types-protobuf>=4",
35
- "livekit-protocol>=1.1.19,<2.0.0",
35
+ "livekit-protocol>=1.1.25,<2.0.0",
36
36
  ]
37
37
 
38
38
  [project.urls]
@@ -1,36 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: livekit-api
3
- Version: 1.2.0
4
- Summary: Python Server API for LiveKit
5
- Project-URL: Documentation, https://docs.livekit.io
6
- Project-URL: Website, https://livekit.io/
7
- Project-URL: Source, https://github.com/livekit/python-sdks/
8
- Author-email: LiveKit <support@livekit.io>
9
- License-Expression: Apache-2.0
10
- Keywords: audio,livekit,realtime,video,webrtc
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3 :: Only
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Programming Language :: Python :: 3.14
20
- Classifier: Topic :: Multimedia :: Sound/Audio
21
- Classifier: Topic :: Multimedia :: Video
22
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
- Requires-Python: >=3.9.0
24
- Requires-Dist: aiohttp>=3.9.0
25
- Requires-Dist: livekit-protocol<2.0.0,>=1.1.19
26
- Requires-Dist: protobuf>=4
27
- Requires-Dist: pyjwt>=2.0.0
28
- Requires-Dist: types-protobuf>=4
29
- Description-Content-Type: text/markdown
30
-
31
- # LiveKit Server APIs
32
-
33
- Access LiveKit server APIs and generate access tokens.
34
-
35
- See https://docs.livekit.io/reference/server/server-apis for more information.
36
-
@@ -1,6 +0,0 @@
1
- # LiveKit Server APIs
2
-
3
- Access LiveKit server APIs and generate access tokens.
4
-
5
- See https://docs.livekit.io/reference/server/server-apis for more information.
6
-
@@ -1 +0,0 @@
1
- __version__ = "1.2.0"
File without changes