Skip to content

tradablebits/livekit-server-sdk-python

 
 

Repository files navigation

This repo has been deprecated, it's been superceded by https://github.com/livekit/python-sdks/

LiveKit Server SDK

https://pypi.org/project/livekit-server-sdk-python/ Code style: black Imports: isort

API Reference: https://docs.livekit.io/guides/server-api

Examples

Generate Access Token for a Client

import livekit

grant = livekit.VideoGrant(room_join=True, room="My Cool Room")
access_token = livekit.AccessToken("<api key>", "<api secret>", grant=grant, identity="bob", name="Bob")
token = access_token.to_jwt()

Using RoomServiceClient

import livekit

client = livekit.RoomServiceClient("<host>", "<api key>", "<api secret>")
client.mute_published_track(
    room="<room name>",
    identity="Bob",
    track_sid="<track sid>",
    muted=True,
)

Local Development

Make sure you clone with submodules:

$ git clone --recurse-submodules https://github.com/tradablebits/livekit-server-sdk-python.git

Or if you have already cloned:

$ git submodule update --init

Dependencies

  • golang >= 1.17
  • protoc
    • Ubuntu: sudo apt install protobuf-compiler
  • protoc-gen-twirpy
    • go install github.com/verloop/twirpy/protoc-gen-twirpy@latest
    • make sure ~/go/bin is in your $PATH
  • pre-commit

Environment Setup

Set up the python virtual environment:

$ python3 -m venv env
$ source env/bin/activate
$ pip install --editable '.[dev]'
$ pre-commit install

Run tests

The RoomServiceClient tests require a running LiveKit server. See the LiveKit Getting Started page.

The tests use the following environment variables to locate the LiveKit server.

export LIVEKIT_HOST='http://localhost:7880'
export LIVEKIT_API_KEY='<api key>'
export LIVEKIT_API_SECRET='<api secret>'

Run the tests:

$ pytest

Updating protocol

The build.sh script pulls the latest tag and builds

$ ./bin/build.sh

About

LiveKit Server SDK for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.0%
  • Shell 1.0%