great-rain-98263
11/18/2025, 11:18 AMtall-airline-16756
11/18/2025, 11:18 AMtall-airline-16756
11/18/2025, 11:18 AMroomList grant using your LiveKit API key and secret.
2. List Sessions: Next, query the Analytics API endpoint https://cloud-api.livekit.io/api/project/{project_id}/sessions using your token. You can use query parameters like start, end, limit, and page to narrow down the results.
3. Calculate Duration: From the response, look for createdAt (which shows when the session started) and endedAt (when it ended). Subtracting createdAt from endedAt will give you the call duration.
Here’s an example snippet from the response:
{
"sessions": [
{
"sessionId": "string",
"roomName": "string",
"createdAt": "2025-09-29T13:59:40Z",
"endedAt": "2025-09-29T14:59:40Z",
"numParticipants": 2
}
]
}
This approach lets you easily retrieve and calculate call durations programmatically. If you have any questions or need a hand with any step, please feel free to ask—I’m here to help!
Sources: Analytics API | LiveKit docsgreat-rain-98263
11/26/2025, 12:18 PMtall-airline-16756
11/26/2025, 12:19 PMROOM_ENDED event and calculate the duration by comparing its timestamp with the session's creation time.
2. Using SIP API: For SIP-based calls, you can use the max_call_duration parameter to enforce or monitor call durations. Additionally, SIP-specific events like SIP_CALL_STARTED and SIP_CALL_ENDED can be used to compute durations.
3. Using Observability Data Hooks: Subscribe to session metrics and use timestamps from the first and last events to infer the session duration.
Let me know if you'd like detailed steps or examples for any of these methods!
Sources: Analytics API | LiveKit docs | livekit-protocol/livekit/protocol/analytics.pyi | livekit/livekit_analytics.pb.go | SIP APIs | LiveKit docs | Observability data hooks | LiveKit docs