Does List sessions API (<https://cloud-api.livekit...
# ask-ai
r
Does List sessions API (https://cloud-api.livekit.io/api/project/${PROJECT_ID}/sessions/) gives ongoing sessions as well?
t
Thanks for reaching out, Shreyansh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely! The List Sessions API does include ongoing (active) sessions in its response. It will return sessions that started within the specified time range, and for those that are still active, you'll see the
egress
field set to
1
. Plus, the
endedAt
field will be
null
for these active sessions. If you have any more questions or need further clarification, feel free to ask—I'm here to help! Sources: Analytics API | LiveKit docs
r
how to know from List session details if session is active or not? (https://cloud-api.livekit.io/api/project/${PROJECT_ID}/sessions/${SESSION_ID})
t
Hi there! To check if a session is still active using the List Session Details API, you’ll want to take a look at the
endTime
field in the response. If you don’t see an
endTime
or if it’s
null
, that means the session is ongoing and active. If you have any questions or need further help, I’m here for you! Sources: Analytics API | LiveKit docs
r
And how to know it on List sessions API??
t
Let's take a look at how you can tell if a session is active using the List Sessions API. You'll want to check a couple of key fields in the session data: • endedAt: When this field is
null
, it means the session is still going strong. • egress: This one gives you a clear picture of the session's status: ◦ `0`: Egress hasn't started yet ◦ `1`: Egress is active, so the session is ongoing ◦ `2`: Egress has finished So, if you see that
endedAt
is
null
and
egress
is
1
, you’re looking at an active session. I hope this helps clarify things for you! Sources: Analytics API | LiveKit docs
r
so we can heavily rely on ended timestamp?
t
While the
endedAt
timestamp can indicate whether a session has concluded, it is recommended to rely on the
egress
field for the most reliable determination of session status. The
egress
field explicitly indicates the session state: • `0`: Session never started • `1`: Session is active • `2`: Session has ended Using
egress == 1
is the most explicit and reliable way to confirm if a session is active, while
endedAt
can serve as supporting information. Sources: Analytics API | LiveKit docs
r
but if we use an egress for a session then only it will be 1 right?
t
Could you clarify if you are referring to the List Sessions API or the List Egress API? The behavior of the
egress
field may depend on the specific API being used, and this will help provide a more accurate response. Sources: Rooms, participants, and tracks | LiveKit docs | livekit-api/livekit/api/livekit_api.py | autocomplete/fish_autocomplete | livekit-protocol/src/livekit.rs
r
List Sessions API
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!