Search code examples
freepbx

Getting recording files on FreePBX through API


I have a bit of a problem with FreePBX API. To sum it, we have Asterisk/FreePBX setup in our intranet, and we have a website on another machine. Task is to show list of recordings in admin panel's orders page for respective order phone number on button click and be able to listen these recordings on said web-server. I have no problem with getting cdr data from FreePBX with GraphQL API, but I cannot find where I can get recording wav files itself in API (I do not have any access to asterisk server and our sysadmin doesn't want to make a shared folder or mount it. Understandable though). ARI doesn't help either, recordings go with FreePBX system (it's put into /asterisk/monitor folder, not /asterisk/recordings) and cannot be accessed through /recordings/stored endpoint.

Maybe I'm blind but GraphQL fetchAllCdrs and fetchCdr are only endpoints that have any relation to recordings, both return JSON with recording's data, including name, id, duration and much more, but I need file itself. Can someone tell me if I can get recording file and where (if yes ofc) through API? As I mentioned before, dances with file system or internal helper webserver is not something I want nor could do.


Solution

  • You can write api which suite your best yourself.

    There is API in /recordings/ but it is not perfect.

    Authorization is via FreePBX users(cookies or see how different ways can be auth in FreePBX). After that to get file go

    https://domain_name.yourserver/admin/config.php?display=cdr&action=download_audio&cdr_file=1679197133.30162
    

    Where cdr_file is uniqueid of main cdr record.