Skip to main content

rtcexpress-server

Python server SDK for RTCExpress: create the short-lived user tokens your apps need for voice calls, video calls and in-app chat.

Your App Secret must stay on your server. This package runs there: your backend signs the user in, decides which room they may join, and returns a token. The browser or mobile app passes that token to a client SDK (Web, React Native, Flutter, Android).

  • Python 3.8 or newer, no dependencies (standard library only)
  • Type hints included

Install

pip install rtcexpress-server

Usage

import os
from rtcexpress_server import RTCExpressServer

rtc = RTCExpressServer(
    app_id=os.environ["RTC_APP_ID"],
    app_secret=os.environ["RTC_APP_SECRET"],
)

result = rtc.create_token("alice", room_id="support-42")
print(result.token, result.expires_in)

Example with FastAPI

from fastapi import Depends, FastAPI

app = FastAPI()

@app.post("/api/rtc-token")
def rtc_token(room_id: str, user=Depends(current_user)):  # your own login check
    # check the user may join this room first
    result = rtc.create_token(user.id, room_id=room_id)
    return {"token": result.token, "expiresIn": result.expires_in}

It works the same in Django or Flask. create_token is a normal (blocking) call; in async code you can run it with await asyncio.to_thread(rtc.create_token, user_id).

RTCExpressServer(app_id, app_secret, server_url=..., timeout=10.0)

Argument Required Description
app_id yes Your project's App ID, from the customer console.
app_secret yes Your App Secret. Load it from an environment variable or secret store.
server_url no Defaults to https://api.devsquarelabs.com.
timeout no Request timeout in seconds. Defaults to 10.

rtc.create_token(user_id, room_id=None, role=None)

Returns a TokenResponse with token and expires_in (seconds, currently one hour).

  • user_id: your own ID for the user. Each device in a call needs its own.
  • room_id: limits the token to one room. Recommended.
  • role: "host", "publisher", "subscriber" or "audience", for broadcast-style rooms.

Errors

Failures raise RTCExpressError with a status:

Status Meaning
401 Wrong App ID or App Secret.
400 Missing or invalid values.
429 Too many token requests from your server (30 a minute per IP). Reuse a token until it is close to expiry.
0 RTCExpress could not be reached (network error or timeout).
from rtcexpress_server import RTCExpressError

try:
    rtc.create_token("alice")
except RTCExpressError as err:
    if err.status == 401:
        ...  # check RTC_APP_ID / RTC_APP_SECRET
    raise

License

MIT © Devsquare Labs

Metadata

Release files for rtcexpress-server 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rtcexpress-server 0.1.0
File Size Uploaded Provenance Actions
rtcexpress_server-0.1.0.tar.gz 6.3 kB Without provenance Details for rtcexpress_server-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rtcexpress-server 0.1.0
File Interpreter ABI Platform Actions
rtcexpress_server-0.1.0-py3-none-any.whl Python 3 none any Details for rtcexpress_server-0.1.0-py3-none-any.whl

Total release size: 11.8 kB

Release files / rtcexpress_server-0.1.0.tar.gz

Download URL rtcexpress_server-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
63a1dc3cfa7acf5f35f1d151b46ccae2bc2c71a32b99fc5c8b72ec3fc4770161
BLAKE2b-256 checksum
How to use checksums
c4bedad3bb09a26fd60f425840e590d2d5cd5b91bd614272bd42c4173b25c8d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / rtcexpress_server-0.1.0-py3-none-any.whl

Download URL rtcexpress_server-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47ce1a4448d55b5cffea88ae535e5c9a9e9884c5e52663a58ae6623ee853f180
BLAKE2b-256 checksum
How to use checksums
dad7cb09468ab9b16ad2ec7896cea40f694101085960f33d65b8f8cd0a710832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for rtcexpress-server 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page