How to list all the active rooms in python?
# ask-ai
f
How to list all the active rooms in python?
g
To list all active rooms in Python, you can use the
ListRooms
method from the LiveKit API. Here's a basic example:
Copy code
from livekit import api
import asyncio

async def list_active_rooms():
    # Initialize the LiveKit API client
    lkapi = api.LiveKitAPI("<URL>")

    # List all active rooms
    room_list = await lkapi.room.list_rooms(api.ListRoomsRequest())
    print("Active Rooms:", room_list)

    # Close the API connection
    await lkapi.aclose()

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(list_active_rooms())
This script initializes the LiveKit API client, lists all active rooms, and prints them. Make sure to replace
<URL>
with your LiveKit server URL. Would you like more details on this process? Sources: - LiveKit Room Management - LiveKit Python SDK Example 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.