Nate Breeden avatar image
Nate Breeden asked Nate Breeden commented

Retrieve Call MP3 / WAV - Python

We have an automation for our IT tickets, when an agent hangs up with a caller it creates a ticket and then links to RingCentral's call recording for the call to listen to later.

What we would like to do is dump the recording as an attachment to that ticket/email, this would allow us to keep recordings longer.

How am I able to do that? We looked through "Get Call Recordings Data" ( but are not sure how to take that data in Python and save it as a MP3/WAV file.

We have tried taking r.text() and exporting the bytes to a WAV file, but then it returns that r.text() is does not contain only byes(which it doesn't). We have tried loading r.text() into pydub as well, but it does not read it either.

Is this not possible with Python?

rest apisdkcall recording
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered Nate Breeden commented

Here is the sample code for you Nate. If you need to read the call log and download lots of call recordings, you will need to handle the API rate limit. If you need to detect the file format as wav or mp3, you need to read the recording metadata and detect the type to create a correct filename extension.

 def read_account_call_log():
     path = os.getcwd() + "/recording_content/"
     if not os.path.isdir(path):
         print("create folder")
         except OSError as e:
     params = {
         'dateFrom': "2022-01-01T00:00:00.000Z",
         'perPage': 1000
     resp = platform.get('/restapi/v1.0/account/~/call-log', params)
     jsonObj = resp.json()
     for record in jsonObj.records:
         if hasattr(record, 'recording'):
             fileName = str( + ".mp3"
                 res = platform.get(record.recording.contentUri)
                 file = open(("%s%s" % (path, fileName)),'wb')
                 print ("Call recording saved in " + fileName)
             except ApiException as e:
                 print (e.getMessage())
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Nate Breeden avatar image Nate Breeden commented ·

You're awesome as always, Phong! Thank you!

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys