give me curl to see rooms which are running and ge...
# ask-ai
b
give me curl to see rooms which are running and get their info or python code which i can run in google colab, short code snippet
t
Thanks for reaching out, Mohammed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you list running rooms and get their details, you can use either
curl
or Python. I’ve shared examples for both below to make it easier for you: Using curl:
Copy code
curl -X POST "<https://your-project.livekit.cloud/twirp/livekit.RoomService/ListRooms>" \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic $(echo -n "api-key:api-secret" | base64)" \
  -d '{}'
Just remember to replace
api-key
,
api-secret
, and
your-project.livekit.cloud
with your actual project details. Using Python:
Copy code
from livekit import api
import asyncio

async def list_rooms():
    lkapi = api.LiveKitAPI()
    try:
        response = await lkapi.room.list_rooms(api.ListRoomsRequest())
        for room in response.rooms:
            print(f"Room: {room.name}, SID: {room.sid}, Participants: {room.num_participants}, Metadata: {room.metadata}")
    except Exception as e:
        print(f"Error: {e}")
    finally:
        await lkapi.aclose()

asyncio.run(list_rooms())
For the Python example, please make sure you have set the environment variables
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
. This will help everything run smoothly. If you have any questions or need more help, just let me know—I’m here for you! Sources: livekit-api/livekit/api/livekit_api.py | Managing participants | LiveKit Docs | test/lktest/livekit.go | livekit/livekit_room.twirp.go | Managing rooms | LiveKit Docs