is there any api to get the recording url generate...
# ask-ai
r
is there any api to get the recording url generated by the egress? apart from the webhook
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! You can definitely retrieve the recording URL generated by egress using the ListEgress API, in addition to relying on webhooks. This API is a great way to programmatically check the status and results of your egress sessions, including file or stream URLs. For instance, the API provides details such as: • File-based outputs: URLs found in the
file_results
or
segment_results
fields. • Streaming outputs: URLs available in the
stream_results
field. • Image snapshots: Metadata located in the
image_results
field. You can call this API directly or use SDKs like Node.js, Python, and others to make it easier. If you'd like, I’m here to help with more guidance or examples—just let me know! Sources: Egress & Media Processing | livekit/livekit_composite | DeepWiki | app/api/record/stop/route.ts | livekit/livekit_egress.twirp.go | packages/livekit-server-sdk/src/EgressClient.ts | livekit-protocol/livekit/protocol/egress.pyi
r
Share example for Node.js SDK
t
I'd love to help you get started with using the Node.js SDK to retrieve recording URLs through the ListEgress API. Here's a simple example you can follow:
Copy code
import { EgressClient } from 'livekit-server-sdk';

const egressClient = new EgressClient(
  <LIVEKIT_SERVER_URL>, // Replace with your LiveKit server URL
  <API_KEY>, // Replace with your API key
  <API_SECRET> // Replace with your API secret
);

// List all egresses for a specific room
const egressInfos = await egressClient.listEgress({ roomName: 'my-room' });

for (const info of egressInfos) {
  if (info.status === 'EGRESS_COMPLETE') {
    // Check file output
    if (info.file_results?.length) {
      console.log('File URL:', info.file_results[0].location);
    }
    // Check HLS output
    if (info.segment_results?.length) {
      console.log('HLS playlist URL:', info.segment_results[0].playlist_location);
    }
    // Check streaming output
    if (info.stream_results?.length) {
      console.log('Stream URL:', info.stream_results[0].url);
    }
  }
}
Just be sure to replace
<LIVEKIT_SERVER_URL>
,
<API_KEY>
, and
<API_SECRET>
with your actual LiveKit server details and credentials. This script will help you list all egress sessions for a specific room and fetch the URLs for any recordings that have completed. If you have any questions or need a hand with anything else, please don't hesitate to ask. I'm here to help!
r
does room has to be live, to make this work, will it say room not found if we are no longer using the room
t
Just to reassure you, the room doesn’t need to be live for you to use the ListEgress API. This handy API can fetch egress information whether the room is active or inactive. As long as you have a valid egress ID or room name, you won’t encounter a "room not found" error. That’s because egress information is stored separately from the room’s current status. So, you’re able to access details about completed or even failed egress operations, even after the room has ended. If you have any more questions or need further help, I’m here for you! Sources: pkg/service/redisstore_test.go | packages/livekit-server-sdk/src/EgressClient.ts | livekit/livekit_egress.pb.go