atik-r10593 avatar image
atik-r10593 asked atik-r10593 commented

How can I download call log between two defined date using python or Js


I have also a little knowledge of python. I want to download detail call log without fax and Inbound calls between two defined date.

Any idea or sample script will be very helpful for me.


getting started
1 |3000

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

John Wang avatar image
John Wang answered
When making a call to the call-log end point, set the following query parameters:

  • dateFrom
  • dateTo
  • direction = 'Outbound'
  • type = 'Voice'
  • view = 'Detailed'

See this example in Python here:
1 |3000

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

atik-r10593 avatar image
atik-r10593 answered atik-r10593 commented
Hi Sir, 
Thanks for your help with the code, I have tried but getting an error, Actually I am confused where I need to put my login details and secret keys etc. Here I have added my code and error found. 

Here is my code sample:  
import os
from dotenv import load_dotenv

from ringcentral import SDK

sdk = SDK(
os.getenv('Mysecret Key'),

platform = sdk.platform()

from urllib import urlencode
except: # For Python 3
from urllib.parse import urlencode

query = {
'dateFrom': '2018-05-01T00:00:00Z',
'dateTo': '2018-06-01T00:00:00Z',
'direction': 'Outbound',
'type': 'Voice',
'view': 'Detailed'}

qs = urlencode(query)

res = platform.get('/restapi/v1.0/account/~/extension/~/call-log?'+qs)

Here is the error: 
Traceback (most recent call last):
  File "C:/Python34/", line 20, in <module>
  File "C:\Python34\lib\site-packages\ringcentral\platform\", line 105, in login
    raise e
  File "C:\Python34\lib\site-packages\ringcentral\platform\", line 82, in login
    raise Exception('Either code or username with password has to be provided')
Exception: Either code or username with password has to be provided
1 |3000

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

Exception: Either code or username with password has to be provided

The reason you are seeing this error is because of how the code is accepting user credentials. You have two basic options here:

  1. Use an external .env file to hold your credentials and reference the file using an environment variable
  2. Hard code your credentials in to the code and removing the os.getenv function calls (which go to the environment)
The script is using approach 1 but it looks like you are attempting to use approach 2 so we need to make one or the other work. Here are ways to make each work with the script.

Approach 1: Using .env Files

Using external .env files is one recommended approach for storing credentials because it keeps them out of your code which often lives in a source control system and can be seen by many people. To do this, create a text file in the same directory as the '' script. You can place this anywhere, but we'll start with the same directory. The file should have the following content:

You can also set the environment variable like the following. Adjust the path as appropriate


C:\> setx ENV_PATH "%USERPROFILE%\.credentials\.env"

Linux, Unix, OS X

$ export ENV_PATH=$HOME/.credentials/.env

Approach 2 Hardcoding Credentials

You can hard code your credentials as shown, but you need to remove the 'os.getenv' call because that takes an environment variable name and returns it's value. Here you don't want to be calling the environment, so modify the Python code as shown below. You can also remove the dependencies that are no longer used like dotenv and os.

sdk = SDK(
    'Mysecret Key',
platform = sdk.platform()
1 Like 1 ·
This type of script is using the Password Grant Type which you need to configure for your app in the Developer Portal. See my answer on this Stack Overflow question about how to configure this:
1 Like 1 ·
It's now working but giving me empty records. Although I have  lot of calls.
Does the user you are making the API call with have any calls?

When calling the "extension/call-log" endpoint, records are returned specifically for the extension that authorized the app:


To get records for all users in the account, use the "account/call-log" endpoint:

1 Like 1 ·
Could the issue be you are currently making API calls to the sandbox account and your calls are in your production account?

You are currently making API calls against your sandbox account:
When you log into the associated Online Account Portal account (note the .devtest) in the host name, do you see calls in the Call Log report?

To make some calls in the sandbox, you can reset your RingCentral for Desktop softphone to log into your sandbox account and make/receive calls. More information is available on this here:
If you are trying to see calls you made in your production account, you will need to graduate your app and then update your app and user credentials.
1 Like 1 ·

RingCentral has two sets of permissions, app permissions and user permissions. This specific error says "user needs" so this is a user permission. To verify the user you are using has this permission, go to the Online Account Portal:

* Sandbox:

* Production:

Go to "Users" > "Roles" and ensure the user that authorized the app has the "Meetings App Access" permission.

Here's what the permission looks like in the UI:

I posted a bit more on this here:

1 Like 1 ·
Show more comments

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