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
Pull call data python API
Tags: call logs
Sep 24, 2019 at 8:06am   •   1 replies  •  0 likes
Arron Voce

Hi,

How can I pull the call data in a Python script, I've been able to connect fine however I'm not sure how to deal with pagination?

I'd like to run the script every 15 mins to pull recent calls and not create duplicats, any sample code that you can help me with?

I will then send the JSON data to a MySQL database.

Thanks

1 Answer
answered on Oct 7, 2019 at 3:18am  

Hi, unfortunately I just keep getting this error with no luck.

Traceback (most recent call last):

File "C:\Users\TPH Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ringcentral\http\client.py", line 28, in send

response.response().raise_for_status()

File "C:\Users\TPH Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests-2.21.0-py3.7.egg\requests\models.py", line 940, in raise_for_status

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://platform.ringcentral.com//restapi/oauth/token

During handling of the above exception, another exception occurred:



 0
answered on Oct 7, 2019 at 2:36am  

Thank you so much!


 0
answered on Oct 7, 2019 at 2:49am  

I get


dateFrom = datetime.utcfromtimestamp(less15Mins).strftime('%Y-%m-%dT%H:%M:%S.000Z'

^

SyntaxError: invalid syntax


 0
answered on Sep 24, 2019 at 2:31pm  

Here you are. Run this script every 15 mins or put it in a loop to call every 15 mins.

from ringcentral import SDK
from credentials import *
import time, json
from time import sleep
from datetime import datetime


rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER)
platform = rcsdk.platform()
platform.login(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD)

now = time.time()
less15Mins = now - (60 * 1
dateFrom = datetime.utcfromtimestamp(less15Mins).strftime('%Y-%m-%dT%H:%M:%S.000Z'
# use the perPage to control your reading block. max is 1000 items
params = {
    'dateFrom': dateFrom,
    'perPage': 1000
}

resp = platform.get('/restapi/v1.0/account/~/extension/~/call-log', params)
print ((resp.json()))

run = True
while run:
    try:
        nextPage = resp.json().navigation.nextPage
        print (nextPage.uri)
        resp = platform.get(nextPage.uri)
        for record in resp.json().records:
            print ("Call type: " + record.type)
        nextPage = resp.json().navigation.nextPage
        sleep(1.2)
    except:
        print("not found")
        run = False

 0



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