stapel-video
Video calls: rooms with shareable join codes, an access-level admission model (public / scope-trusted / restricted lobby) with a realtime waiting room over WebSockets, host admit/deny controls, join-token minting through a pluggable video-provider seam (LiveKit by default), a recording-egress seam (start/stop + a video.egress_ended event) that integrates with stapel-recordings by event and never by import, and a presence meter — per-connection spans fed by the media server's own join/leave webhooks, reconciled by a sweeper so a crashed client cannot bill forever, and read back as unioned presence time and a co-presence matrix for whatever prices them, partitioned by an opaque scope_key carried on the join grant so a workspace administrator can read their own people's monthly call time behind their own mandate.
Part of the Stapel framework — composable Django apps that deploy as a monolith or as microservices without changing module code.
Install
pip install stapel-video
At a glance
| Fact | Value |
|---|---|
| Version | 0.12.1 |
| Python | >=3.11 (3.11, 3.12, 3.13, 3.14) |
| HTTP operations | 15 |
| Config axes | 7 |
| Usage surface | 45 |
| Extension points | 16 |
| Error codes | 57 |
| Fleet dependencies | stapel-auth (optional) · stapel-core · stapel-profiles (optional) · stapel-recordings (optional) · stapel-workspaces (optional) |
Documentation
OpenAPI · capabilities.json · llms.txt (for agents)
What this is
- Rooms with human-shareable join codes (
abc-defg-hij). - Admission model —
public(anyone with the code joins),scope_trusted(members of the room's scope join instantly, others wait),restricted(everyone but the host waits in a lobby). - Realtime lobby on the fleet substrate
(stapel-realtime) — one
ephemeral stream
video:lobby:<join_code>carryinglobby.waiting/lobby.admitted/lobby.deniedon the v1 wire envelope, gated on room membership. A browser opens it with its JWT cookie (no header a browser cannot send), behind the origin guard that ambient credential requires. - Host controls — admit / deny waiting guests.
- Provider seam — one
VideoProviderABC (mint join token, create room, start/stop recording egress, verify webhook). Swap vendors without forking. - Recording is a seam, not a pipeline:
start/stop_egressproxy the provider and avideo.egress_endedcomm event carries the storage key to stapel-recordings — by event, never by import. - Presence metering — per-connection spans fed by the media server's own join/leave webhooks (the only departure signal that survives a closed laptop), reconciled by a sweeper so a lost webhook cannot bill forever, and read back as unioned presence time and a co-presence matrix. Raw seconds, no threshold: this instance meters, whatever prices it decides what counts.
- Per-tenant usage — spans carry an opaque
scope_keyset on the join grant, so "who in THIS workspace talked how much, per month" is a read this library answers, gated on the caller's mandate in that very scope. A foreign key answers 404, never 403.
Alpha. See MODULE.md for the agent-facing map of seams.
Quick start
pip install stapel-video # core library
pip install 'stapel-video[livekit]' # + the default LiveKit backend
pip install 'stapel-video[realtime]'# + serving the lobby socket
# urls.py
path("video/", include("stapel_video.urls"))
# settings.py — deliver the lobby signals, and say which pages may open a socket
INSTALLED_APPS = [..., "stapel_realtime", "stapel_video"]
STAPEL_COMM = {"SIGNAL_TRANSPORT": "channels"}
STAPEL_REALTIME = {"ALLOWED_ORIGINS": ["https://app.example.com"]}
# asgi.py (realtime lobby) — routes discovered from INSTALLED_APPS
from django.core.asgi import get_asgi_application
from stapel_realtime.asgi import build_websocket_application
application = build_websocket_application(
http_application=get_asgi_application()
)
API
| Method | Path | What |
|---|---|---|
| POST | /video/api/rooms |
Create a room (creator auto-admitted host, with a token) |
| GET | /video/api/rooms/{join_code} |
Room info |
| POST | /video/api/rooms/{join_code}/join |
Join → admitted / waiting / denied |
| GET | /video/api/rooms/{join_code}/participants |
Participants (anchor-paginated) |
| POST | /video/api/rooms/{join_code}/lobby/admit |
Admit a waiting guest (host-only) |
| POST | /video/api/rooms/{join_code}/lobby/deny |
Deny a waiting guest (host-only) |
| GET | /video/api/v1/scopes/{scope_key}/usage/ |
One tenant's per-month, per-person call time (?months=/?month=, ?tz=) — mandate-gated in that scope |
| POST | /video/api/webhook |
Provider webhook ingress (signed, unauthenticated) |
| WS | ws/video/lobby/{join_code} |
The room's lobby stream — lobby.waiting / lobby.admitted / lobby.denied, read-only (see MODULE.md § Live lobby) |
Configuration (STAPEL_VIDEO)
| Key | Default | What |
|---|---|---|
VIDEO_PROVIDER |
…livekit.LiveKitProvider |
Video backend (dotted path) |
SCOPE_PROVIDER |
…scope.DefaultScopeProvider |
scope_key resolution + membership |
DEFAULT_ACCESS_LEVEL |
restricted |
Access level for a room created without one |
DEFAULT_ADMIT_REQUIRED |
True |
Whether new rooms start with the lobby on |
LIVEKIT_URL / LIVEKIT_API_KEY / LIVEKIT_API_SECRET |
"" |
Default-provider credentials |
WEBHOOK_HANDLERS |
{} |
Provider-event → handler, merged over the builtins |
PRESENCE_SWEEP_INTERVAL_SECONDS |
60 |
How often open presence spans are reconciled |
PRESENCE_SPAN_RETENTION_DAYS |
400 |
When a span is purged (None = never) |
USAGE_MANDATE |
video.usage.read |
Capability a caller must hold in the scope to read its usage |
USAGE_AUTHORIZER |
…usage.staff_only_authorizer |
Fallback gate where there are no workspaces to ask |
USAGE_THROTTLE |
60/min |
Rate for the video-scope-usage throttle scope |
VIDEO_PROVIDER, DEFAULT_ACCESS_LEVEL and DEFAULT_ADMIT_REQUIRED are the
three CTO-facing config axes surfaced in docs/capabilities.json.
Presence metering
Turn the provider's webhooks on (they point at POST /video/api/webhook), and
schedule the two jobs — a meter without the sweeper measures an upper bound,
not a duration:
from stapel_video.tasks import get_video_beat_schedule
CELERY_BEAT_SCHEDULE = {**get_video_beat_schedule(), ...}
Celery is optional: manage.py video_sweep_presence and manage.py video_purge_spans are the cron form. Then read the numbers by comm Function:
from stapel_core.comm import call
call("video.presence.aggregate", {"user_id": uid, "period": "2026-08"})
# {"presence_seconds": 5400, "rooms_count": 3, ...} — unioned, so a laptop
# and a phone are one person present, not two.
call("video.presence.pairs_export", {"period": "2026-08", "limit": 500})
# {"rows": [{"room_key", "user_a", "user_b", "co_presence_seconds"}, ...],
# "cursor": ..., "total": None} — raw overlaps; the "counts as a real
# conversation" threshold belongs to whoever asks, not to the meter.
Per-tenant usage
Pass the partition on the grant and the provider echoes it back onto every span it reports:
provider.mint_join_token(room_ref, user.pk, name, scope_key=str(workspace_id))
Spans recorded before you did that are the host's to place — only you know
which tenant a room_key belonged to:
manage.py video_backfill_scope --resolver myapp.reporting.scope_for_room
Then read a workspace's own numbers, over the bus or over HTTP:
call("video.presence.usage_rollup_by_month",
{"scope_key": str(workspace_id), "months": 6, "tz": "Europe/Berlin"})
# {"months": [{"month": "2026-08", "users": [{"user_id", "presence_seconds",
# "rooms", "connections", ...}]}]} — newest month first, buckets cut at LOCAL
# midnight, so a DST month is genuinely an hour short.
GET /video/api/v1/scopes/{scope_key}/usage/?months=6&tz=Europe/Berlin is the
same answer for a workspace-administration screen. It is not staff-gated: the
caller must hold STAPEL_VIDEO["USAGE_MANDATE"] (default video.usage.read)
in the workspace they are asking about, resolved through the workspaces
access registry — register it on the roles you mean to grant it to. Asking
about somebody else's workspace answers 404, identically to a workspace that
does not exist: a 403 would confirm the id is real. Without workspaces in the
picture, USAGE_AUTHORIZER decides (staff-only unless you replace it).
Rows carry user ids. This library never learns anybody's name; the host resolves it from the roster it already has.
License
MIT — see LICENSE.
This page is assembled by stapel-readme from docs/readme.md plus the contract artifacts in docs/. Edit the prose in docs/readme.md; the badges, facts and links above and below it are generated — do not hand-edit README.md.
Metadata
Release files for stapel-video 0.12.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stapel_video-0.12.1.tar.gz | 241.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stapel_video-0.12.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 444.5 kB
Release files / stapel_video-0.12.1.tar.gz
| Download URL | stapel_video-0.12.1.tar.gz |
|---|---|
| Size | 241.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72bc21da1fd86317619ad0e24546998f6c4a08cb38c588a3ed2a6f6ae345b0c4
|
|
BLAKE2b-256 checksum How to use checksums |
23a8c230e951758e6e89c4fd3b914e6538052af3cf4d9ca1fbe073476e5be224
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / stapel_video-0.12.1-py3-none-any.whl
| Download URL | stapel_video-0.12.1-py3-none-any.whl |
|---|---|
| Size | 203.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40539bfce19c64959b3794156c8c05ed6c150890a76942d2931578d48c56590b
|
|
BLAKE2b-256 checksum How to use checksums |
4bbc22611c27a0c89a033ff7e26835c0632ec0029e10a0904711e09da91fc1d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log