how can i get the call start/end time using python...
# ask-ai
o
how can i get the call start/end time using python sdk?
t
Are you working with SIP calls or the standard room-based calls? Knowing this will really help me guide you better on how to retrieve the call start and end times using the Python SDK. I'm here to make this as smooth as possible for you! Sources: livekit-protocol/livekit/protocol/sip.pyi | protobufs/livekit_analytics.proto
o
SIP calls
t
To help you retrieve the call start and end times for SIP calls using the Python SDK, you can look into these fields within the SIP call data structure: • started_at_ns and ended_at_ns: These give you high-precision timestamps in nanoseconds and are the best ones to use for accuracy. • started_at and ended_at: These provide timestamps in seconds, but since they’re marked as deprecated, it’s a good idea to stick with the nanosecond fields. You’ll find these fields included in the SIP call details, accessible through event handlers or API responses related to SIP calls. If you’d like, I’m here to guide you through the implementation in your code or answer any other questions you might have!
o
what about the standard room-based calls?
t
For standard room-based calls, you can easily find out when the call started and ended by looking at these analytics events: • ROOM_CREATED: This event comes with a
created_at
field, showing exactly when the room was created — you can think of this as the call’s start time. • ROOM_ENDED: This event tells you when the room, and therefore the call, has ended. You can access these events through event listeners in your application. If you'd like, I’m more than happy to help you set up these event listeners or provide more details on how to handle these events. Just let me know!