News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Call log API and Analytics get different call logs.
Tags: rest api
Jul 17, 2023 at 2:25pm   •   2 replies  •  0 likes
Santiago Castaneda

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,


2 Answers
answered on Jul 17, 2023 at 2:51pm  

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.


 0
on Jul 17, 2023 at 8:05pm   •  0 likes

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 ?


on Jul 17, 2023 at 7:59pm   •  0 likes

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


answered on Jul 17, 2023 at 8:17pm  

1689650177393.png

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


 0
on Jul 18, 2023 at 8:14am   •  0 likes

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.



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us