question

Hazel Vu avatar image
Hazel Vu asked Hazel Vu edited

Needs Advice on List User Call Records API

Hello Ring Central Community,

I am very new to getting data via API but I do have a working script that successfully retrieve our company's call data in the format I wanted. Now my next obstacle is that perPage parameter only allows a maximum of 250 records returned for Detailed view.

Is there a way to retrieve more than 250 records?

If there is no way to retrieve more than 250 records, what is the best practices from here? I reviewed Ring Central Data Archival but because we don't have a database, I am not sure what to do. We have AWS S3 but currently it is not being used for company reporting. Should we set up an S3 bucket for this?

I am also not sure how often the API supposed to be called? Do I need to figure out on average how many coming through every hour and schedule the script to retrieve and append data every hour? What if there is an influx of incoming call and there are more than 250 calls during that certain hour?

Thank you in advance for any help or guidance you can provide!

call logs
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 Hazel Vu edited

You can use the pagination value to navigate thru the pages (which each page contains 250 records).

Here is an example how to read the account call log using the RingCentral JS SDK

async function read_account_calllog(){
  var queryParams = {
    dateFrom: "2023-11-01T16:42:12.577Z",
    dateTo: "2023-11-05T16:42:12.577Z",
    view: "Detailed",
    perPage: 250
  }
  try {
    var resp = await platform.get('/restapi/v1.0/account/~/call-log', queryParams)

    var jsonObj = await resp.json()
    
    for (var record of jsonObj.records){
        // parse record and save it to your db
        console.log(JSON.stringify(record))
        console.log("======= ^^^^^ ========")
    }
    // Check if there are next pages
    var navigationObj = jsonObj.navigation
    if (navigationObj.hasOwnProperty("nextPage")){
      read_calllog_nextpage(navigationObj.nextPage.uri)
    }else{
        console.log("no next page. Done")
    }
  }catch(e){
    console.log(e.message)
  }
}

async function read_calllog_nextpage(url){
  try {
    var resp = await platform.get(url)
    var jsonObj = await resp.json()
    for (var record of jsonObj.records){
        // parse record and save it to your db
        console.log(JSON.stringify(record))
        console.log("======= ^^^^^ ========")
    }
    // Check if there are next pages
    var navigationObj = jsonObj.navigation
    if (navigationObj.hasOwnProperty("nextPage")){
        read_calllog_nextpage(navigationObj.nextPage.uri)
      }else{
        console.log("no more next page. Done")
      }
    } catch (e){
      console.log(e.message)
    }
}

You can combine the 2 functions into one and handle the queryParams accordingly.

1 |3000

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

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