fast-egg-39595
08/25/2025, 10:22 PMtall-airline-16756
08/25/2025, 10:22 PMtall-airline-16756
08/25/2025, 10:23 PMfast-egg-39595
08/25/2025, 10:25 PMtall-airline-16756
08/25/2025, 10:25 PMupdate_subscriptions method. Here’s a simple example to help you out:
from livekit import api
from livekit.protocol.room import UpdateSubscriptionsRequest
# Initialize the LiveKit API client
lkapi = api.LiveKitAPI(
url="your-livekit-url",
api_key="your-api-key",
api_secret="your-api-secret"
)
# Create the unsubscribe request
update_request = UpdateSubscriptionsRequest(
room="your-room-name",
identity="receiving-participant-identity", # The user you want to unsubscribe
track_sids=["TR_AUDIO_TRACK_ID"], # Audio track SID to unsubscribe from
subscribe=False # False to unsubscribe
)
# Execute the unsubscribe operation
try:
response = await lkapi.room.update_subscriptions(update_request)
print("Successfully unsubscribed from audio track")
except Exception as e:
print(f"Oops, something went wrong: {e}")
Just a couple of things to keep in mind:
• Permissions: Make sure your API key has room_admin permissions for the room you’re working with.
• Track SIDs: You’ll need the track SIDs of the audio tracks you want to unsubscribe from. You can get these by checking the list of participants and their tracks, or by listening to room events that track subscriptions.
If you have any questions or want me to walk you through anything else, just give me a shout!
Sources: livekit-rtc/livekit/rtc/room.py