important-judge-78504
11/14/2025, 5:58 PMtall-airline-16756
11/14/2025, 5:58 PMtall-airline-16756
11/14/2025, 5:59 PMnumActiveParticipants in the session data that shows the real-time number of active participants.
To access this, you just need to call the listLiveKitSessions() endpoint. When you do, the response will include details about each session, like this:
{
"sessions": [
{
"sessionId": "...",
"roomName": "...",
"numActiveParticipants": 5,
...
}
]
}
If you’d like, I’m here to guide you through the implementation or answer any other questions you have. Just let me know!
Sources: Subscribing to tracks | LiveKit docs | Analytics API | LiveKit docs | livekit-rtc/livekit/rtc/_proto/room_pb2.pyiimportant-judge-78504
11/14/2025, 5:59 PMtall-airline-16756
11/14/2025, 6:00 PMroomList grant. Here’s how you can do it:
from livekit import AccessToken
api_key = "your_api_key"
api_secret = "your_api_secret"
token = AccessToken(api_key, api_secret)
token.add_grant(room_list=True)
access_token = token.to_jwt()
1. Query the Analytics API: Next, use the token you just generated to make an HTTP request to the listLiveKitSessions endpoint. Check out this example:
import requests
def get_sessions_with_active_participants(project_id, access_token):
endpoint = f"https://cloud-api.livekit.io/api/project/{project_id}/sessions"
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
response = requests.get(endpoint, headers=headers)
response.raise_for_status()
return response.json()['sessions']
# Example usage
project_id = "p_your_project_id"
sessions = get_sessions_with_active_participants(project_id, access_token)
for session in sessions:
print(f"Room: {session['roomName']}, Active Participants: {session['numActiveParticipants']}")
Just remember to swap out your_api_key, your_api_secret, and p_your_project_id with your actual credentials and project ID. If you hit any bumps or have more questions, I’m here to help—just let me know!
Sources: Analytics API | LiveKit docs