many-hamburger-5823
09/01/2025, 4:54 AMtall-airline-16756
09/01/2025, 4:54 AMtall-airline-16756
09/01/2025, 4:54 AMmetadata property on the Room object with the LiveKit SDKs. Here’s a quick rundown for different SDKs:
• JavaScript/TypeScript: Just use room.metadata.
• Swift: You can access room.metadata as a String?.
• Python: Simply use the metadata property on the Room object.
• Rust: Call room.metadata() to get the metadata.
• Unity (Web): Check out the Metadata property on the Room class.
• React: Use the useRoomInfo hook, which gives you both the room name and metadata.
Just a heads up: room metadata is a string that holds app-specific info everyone in the room can see. You can only set it through server-side APIs like CreateRoom or UpdateRoomMetadata. And if you want to keep an eye on changes, just listen for the RoomMetadataChanged event. Hope this helps!
Sources: src/room/Room.ts | Sources/LiveKit/Core/Room.swift | livekit/src/room/mod.rs | packages/react/src/hooks/useRoomInfo.ts | Room metadata | LiveKit Docsmany-hamburger-5823
09/01/2025, 4:54 AMtall-airline-16756
09/01/2025, 4:55 AMimport os
import logging
import asyncio
from livekit import rtc
# Just a heads up: make sure to set these environment variables with your own details
TOKEN = os.environ.get("LIVEKIT_TOKEN")
URL = os.environ.get("LIVEKIT_URL")
async def main():
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
room = rtc.Room()
# Optional: Listen for any changes to the room metadata
@room.on("room_metadata_changed")
def on_room_metadata_changed():
logger.info("Room metadata changed: %s", room.metadata)
# Connect to the room
await room.connect(URL, TOKEN)
logger.info("Connected to room %s", room.name)
# Grab and show the current room metadata
logger.info("Current room metadata: %s", room.metadata)
# Keep the connection alive so you can catch any updates
await asyncio.Event().wait()
if __name__ == "__main__":
if not TOKEN or not URL:
print("Just a quick reminder: you need to set both TOKEN and URL environment variables")
exit(1)
asyncio.run(main())
Here’s a quick rundown:
• The room.metadata property lets you access the current metadata of the room.
• We set up an event listener for "room_metadata_changed" so you’ll get notified in real time whenever the metadata updates.
Before you run this script, make sure to set your own LIVEKIT_TOKEN and LIVEKIT_URL environment variables. If you need a hand with that, just ask!
Sources: livekit-protocol/livekit/protocol/room.pyi | Room metadata | LiveKit Docs