Metadata-Version: 2.4
Name: appsocom
Version: 0.6.3
Summary: Python server SDK for Appsocom Live video calls: join tokens, rooms, moderation and webhook verification
Author: Appsotech Limited
License-Expression: MIT
Project-URL: Homepage, https://live.appsocom.com
Project-URL: Documentation, https://docs.appsocom.dev/server-sdks
Keywords: appsocom,video,calls,webrtc,sfu,cloudflare
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Communications :: Conferencing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# appsocom (Python)

Python server SDK for [Appsocom Live](https://live.appsocom.com): mint join tokens, manage rooms and participants, moderate and verify webhooks. Python 3.9+, standard library only.

```bash
pip install appsocom
```

```python
import os
from appsocom import SfuKit, SfuKitError, verify_webhook

kit = SfuKit("https://api.appsocom.dev", os.environ["APPSOCOM_API_KEY"])  # project API key from the console

tok = kit.create_token("class-1", "u_7", name="Ada", role="student", metadata={"seat": 3})
tok["token"], tok["expiresAt"]

kit.set_role("class-1", "u_9", "student")             # promote an observer
kit.mute("class-1", "*", ["mic"], lock=True)          # mute everyone, keep them muted
kit.set_room_metadata("class-1", {"topic": "Fractions"})
kit.set_track_permissions("class-1", "u_7", {"allowAll": False, "allow": [{"userId": "u_1"}]})
kit.remove_participant("class-1", "u_8", ban=True)
```

Errors raise `SfuKitError` with `.status` and `.body`.

Webhooks (Flask):

```python
@app.post("/appsocom-webhooks")
def hook():
    event = verify_webhook(os.environ["APPSOCOM_WEBHOOK_SECRET"], request.get_data(), request.headers.get("X-SfuKit-Signature"))
    if event is None:
        return "", 401
    print(event["event"], event["roomId"])
    return "", 204
```

All methods: `create_token`, `get_room`, `list_participants`, `update_room`, `set_room_metadata`, `lock_room`, `close_room`, `update_participant`, `set_permissions`, `set_role`, `set_participant_metadata`, `set_track_permissions`, `remove_participant`, `unban`, `mute`, `admit`, `post_chat`, `lower_hands`, `get_attendance`, `get_attendance_csv`, `clear_attendance`, `start_breakouts`, `end_breakouts`, `move_to_group`, `health`, `request()`. Standalone: `sign_token`, `verify_webhook`, `sign_webhook`.

Self-hosting your own deployment instead? Point `url` at it and pass its admin key; the optional `jwt_secret` signs tokens locally without an HTTP call.

Docs: [docs.appsocom.dev](https://docs.appsocom.dev) · License: MIT
