Skip to main content

Hi,


I'm getting data hourly from the API filtering it by date. The systom don't shown any error, but when i'm going to compare the logs from an specific hour between the data sent to my database and the analytics portal, the Total Calls are different. Around (5 or 15 calls) is the difference between both in some of the hours. Why could it be happend ?


Note: i'm aware that if the call hasn't finished end, it's not accessible with the API. So that's why i wait aproximately 1.5 hours to get the information of the datarage.


Thanks,


Please share some code how you read the call log and the analytics data. Especially, the dateFrom and dateTo params. Remember that the API takes dateFrom and dateTo as UTC time. And yes, by the time you call the call log API, only completed calls are reported. If you don't expect real-time call log data, set the dateTo to a few hours or a day back to make sure you capture all the calls.


Hi, for me it's clear the UTC to calculate the dateFrom and the dateTo. This is part of the code:

@app.get("/") #http://127.0.0.1:5000/store
def running_api():
#BigQuery Credentials
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'ringCentral2_DB.json'
client = bigquery.Client()
#function to convert UTC startTime to convert it to local florida Time

#The RingCentral API -->
load_dotenv()

rcsdk = SDK( os.environ.get('RC_CLIENT_ID'),
os.environ.get('RC_CLIENT_SECRET'),
os.environ.get('RC_SERVER_URL') )
platform = rcsdk.platform()

try:
platform.login( jwt=os.environ.get('RC_JWT') )
except Exception as e:
sys.exit("Unable to authenticate to platform: " + str(e))

params = {
'view': 'Detailed',
"perPage": 1000
}

try:
now = time.time()
#less15min = now -(60*15)
#dateFrom = datetime.utcfromtimestamp(less15min).strftime('%Y-%m-%dT%H:%M:%S.000Z')
dateto = datetime.utcfromtimestamp(now).strftime('%Y-%m-%dT%H:%M:%S.000Z')
onehourless = dateto.split("T")

if int(onehourless[1].split(":")[0])-2 == -1:
now = time.time() - (60*120)
dateto = datetime.utcfromtimestamp(now).strftime('%Y-%m-%dT%H:%M:%S.000Z')
onehourless = dateto.split("T")
dateFrom = onehourless[0]+"T23:00:00.000Z"
dateto = onehourless[0]+"T23:59:59.999Z"
print(f"The dateFrom {dateFrom} to the dateto: {dateto}")
else:
dateFrom = onehourless[0]+"T"+str(int(onehourless[1].split(":")[0])-1)+":00:00.000Z"
dateto = onehourless[0]+"T"+str(int(onehourless[1].split(":")[0])-1)+":59:59.999Z"

# dateFrom = "2023-07-13T20:00:00.000Z"
# dateto = "2023-07-13T23:59:59.999Z"
print(f"The dateFrom {dateFrom} to the dateto: {dateto}")

resp = platform.get(f'/restapi/v1.0/account/~/call-log?dateFrom={dateFrom}&dateTo={dateto}', params)

records = resp.json().records



You said ... " If you don't expect real-time call log data", we do really need to get real-time-call-data. How can i do that ?

We are getting this data because we need to calculate de call gaps time between calls, but the data is not accurate compare to the portal Analytics. The value "Internal" in the Direction attribute is not sent to the dataset. I'm struggling with this, the report is not precise. Can you help me please ?



1689650177393.png

This is what i ment, the information is not the same in the same our.


I don't see the period of time you set in the Analytics dashboard and your local time zone so I cannot say what could be the time offset you should set to read and to convert from UTC time to your local time. The Analytics dashboard uses your local time so when your app call the API, it also needs to convert to the same local time (take into consideration your app server location if it's not the same as your app frontend).

All in all, The API is taking UTC time and your responsibility is to convert UTC to local time.

For real-time or near real-time call data, please read this article.


Reply