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
How to get user performance API by dynamic date range?
Tags: rest api
Mar 31, 2022 at 7:35am   •   3 replies  •  1 likes
Ngoc Nguyen

I was able to call Ring Central Analytics API for the user performance, such as missed calls, aggregated by user by a fixed date range, for example, from 2022-03-23 to 2022-03-24. How can I get the API response by user by a dynamic date range, for example, yesterday, given today is 2022-03-25. My ultimate goal is to have the API response daily as below. I also posted my script below for your reference.


# desired table (after parsed api json into tabular format)

dateusermissed_call_count
2022-03-23user_110
2022-03-23user_220
2022-03-24user_130


# script

{

  "grouping": {

    "groupBy": "Users",

    "ids": []

  },

  "timeSettings": {

    "timeRange": {

      "timeFrom": "2022-03-23T00:00:00.000Z",

      "timeTo": "2022-03-24T00:00:00.000Z"

    },

    "advancedTimeSettings": {

      "timeZone": "US/Eastern",

      "includeDays": [

        "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"

      ],

      "includeHours": [

        {

          "from": "00:00",

          "to": "23:59"

        }

      ]

    }

  },

  "responseOptions": {

    "counters": {

      "allCalls": {

        "aggregationType": "Sum"

      },

    "timers": {

      "allCallsDuration": {

        "aggregationType": "Sum"

      }

     } 

    }

  }

}
on Mar 30, 2022 at 6:27pm   •  0 likes

I was able to put the dynamic date range into the json body, using python.

from datetime import datetime, timedelta

# load json object with the fixed date range
aggregate_json_file = 'aggregate_data_request.json' 
json_request_object = json.load(open(aggregate_json_file)) 

# set dynamic date range
json_request_object['timeSettings']['timeRange']['timeFrom'] =  datetime.now().strftime('%Y-%m-%d %H:%M:%S')

json_request_object['timeSettings']['timeRange']['timeTo'] = (datetime.now() +  timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S')

# print json object with the dynamic date range
print(json_request_object)


2 Answers
answered on Apr 5, 2022 at 9:41am  

Thank you @Suyash Joshi . Yes I am using AWS Glue ELT tool to run the this API daily so making the date range as a variable and passing this to the script works well for my case.


 1
answered on Apr 5, 2022 at 9:17am  

Hi @Ngoc Nguyen it seems like you were able to answer your own problem which is great. Yes by making it a variable and passing the date/time for each day you should be able to get the report daily. You can further run this code as a nightly cron job or use a serverless function that is scheduled to run every day. Let us know if you need any further help.


 1



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