how to get a list of active rooms in nodejs?
# ask-ai
w
how to get a list of active rooms in nodejs?
t
Thanks for reaching out, Sunil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want to grab a list of active rooms in Node.js using LiveKit, you can use the
listRooms()
method from the
RoomServiceClient
. Here’s a simple way to do it: 1. First, set up the RoomServiceClient:
Copy code
const livekitHost = '<LIVEKIT_HOST>'; // Just swap this with your LiveKit host URL
const apiKey = '<API_KEY>';
const apiSecret = '<API_SECRET>';

const svc = new RoomServiceClient(livekitHost, apiKey, apiSecret);
2. Next, call the
listRooms()
method:
`const rooms = await svc.listRooms(); console.log('Active rooms:', rooms);`This will give you an array of
Room
objects, each with details about the active rooms. Bonus tip: If you want to narrow down the list, you can pass an array of room names like this:
Copy code
const rooms = await svc.listRooms(['room1', 'room2']);
Feel free to reach out if you want me to walk you through anything else!
w
give mt he link to nodejs api docs
t
Hey there! You can check out the Node.js API documentation for LiveKit in these handy resources: • LiveKit Node SDKs Repository: Here you'll find detailed API references, easy-to-follow setup instructions, and examples to help you get LiveKit up and running in your Node.js projects. • LiveKit Documentation: This is packed with extra guides and resources to support you while working with LiveKit. If you have any questions or need a hand, just let me know—I’m here to help! Sources: README.md