Python API
This page lists the primary public Python APIs for a WHIP Service. Source under whip-sdk/python/src is authoritative.
| Package | API | Description |
|---|---|---|
tirtcxauth | Ed25519TokenIssuer | Create a token issuer |
tirtcxauth | Ed25519TokenVerifier | Create a token verifier |
tirtcxauth | verify_bearer | Verify an HTTP bearer token |
tirtcx | init / start | Initialize and start TiRTC |
tirtcx | WhipAcceptor | Create an authentication-independent acceptor |
tirtcx | WhipAcceptor.whip_accept | Accept an SDP Offer and create a WHIP Session |
tirtcx | WhipSession | Own a pending or connected session |
tirtcx | Conn | An established TiRTC connection object. Handles media exchange, commands, and connection events. |
whipecho | HTTPAdapter | Create an embeddable Echo HTTP adapter |
whipecho | Observer | Receive Echo session, media, failure, and dropped-event notifications |
Token APIs
Ed25519TokenIssuer.issue(service, access_key, device_id, raw_query, ttl_seconds) returns a reusable delegation token. The token contains no nonce. The complete query is canonicalized into its scope.
verify_bearer(authorization, service, raw_query, verifier) returns status 200 and claims on success, 401 for a missing token, 403 for an invalid token, or 500 for missing service configuration.
WhipSession
| API | Description |
|---|---|
answer_sdp | SDP Answer bytes |
wait_conn(timeout) | Wait for and return the same Conn |
close() | Idempotently close a pending or connected session |
Conn
Events use queue.Queue. A zero buffer disables the queue; enabled queues have a minimum capacity of four. events.audio, events.video, events.message, events.command, events.errors, and events.disconnected carry events. done is a threading.Event, and error contains the terminal error.
Send operations include send_audio, send_video, send_message, send_command, request_key_frame, and audio/video subscription methods.
HTTPAdapter
| API | Description |
|---|---|
try_handle_post(raw_query, content_type, body) | Handle Echo POST; return None for ordinary requests |
serve_delete(session_id) | Delete an Echo session |
stats() | Return a statistics snapshot |
shutdown() | Reject new sessions and close active sessions |
The Stats snapshot contains active sessions, accept and connection failures, media totals, send failures, dropped events, and totals grouped by close reason. Observer callbacks may run on multiple session threads; implementations must return quickly and be thread-safe.