RingCentral Connect Platform Python SDK

ringcentral, updated 🕥 2023-03-09 19:31:08

RingCentral SDK for Python

Build Status Coverage Status Twitter

RingCentral Developers is a cloud communications platform which can be accessed via more than 70 APIs. The platform's main capabilities include technologies that enable: Voice, SMS/MMS, Fax, Glip Team Messaging, Data and Configurations.

API Reference and APIs Explorer.


This SDK is tested against Python 3.7 so we recommend installing using it with Python 3.7 or newer


sh $ git clone https://github.com/ringcentral/python-sdk.git ./ringcentral-python-sdk

Install dependencies:


sh $ pip3 install ringcentral


Rename credentials-sample.ini to credentials.ini.

Edit credentials.ini and update appropriate parameters. CLIENT_ID is synonymous with APP_KEY. CLIENT_SECRET is synonymous with APP_SECRET. In this repository, the latter convention is used that of APP_KEY and APP_SECRET.


Take a look at a sample code.

```py from ringcentral import SDK

sdk = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER') platform = sdk.platform() platform.login('USERNAME', 'EXTENSION', 'PASSWORD')

res = platform.get('/account/~/extension/~') print('User loaded ' + res.json().name) ```

Subscribing for server events

```py from threading import Thread from time import sleep from ringcentral.subscription import Events

def on_message(msg): print(msg)

def pubnub(): s = sdk.create_subscription() s.add_events(['/account/~/extension/~/message-store']) s.on(Events.notification, on_message) s.register() while True: sleep(0.1)

try: try: import Pubnub t = Thread(target=pubnub) t.start() except ImportError as e: print("No Pubnub SDK, skipping Pubnub test")

except KeyboardInterrupt: pass ```

Send sms

```py from ringcentral import SDK

database = [] database.append({"Customer":"Tyler","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Chen","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Anne","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Brown","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Peter","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"White","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Lisa","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Dan","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Stephanie","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"}) database.append({"Customer":"Lukas","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"})

sdk = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER') platform = sdk.platform() platform.login('USERNAME', 'EXTENSION', 'PASSWORD')

def sendSMS(message, number):
params = {'from': {'phoneNumber': 'USERNAME'},'to': [{'phoneNumber': number}],'text': message} response = platform.post('/restapi/v1.0/account/~/extension/~/sms', params) print('Sent payment reminder to ' + number)

def main(): for i in range(len(database)): customer = database[i] if customer['Payment'] is "Due": sendSMS("Hi " + customer['Customer'] + ". Your payment is due.", customer['PhoneNumber']) time.sleep(5) print("Send payment reminder done.")

if name == 'main': main() ```


error sending fax

opened on 2023-02-08 18:56:52 by tylerlong

Issue below is reported by a developer:

This is the code where the issue begins:


attachment = ('fax.jpg', open('fax.jpg','r').read(), 'image/jpeg') builder.add(attachment)


This is the error that I get when I attach a document:

File "/home/username/Projects/project-paths/fax.py", line 71, in send_fax resp = platform.send_request(request) File "/home/username/.local/lib/python3.9/site-packages/ringcentral/platform/platform.py", line 173, in send_request return self._client.send(self.inflate_request(request, skip_auth_check=skip_auth_check)) File "/home/username/.local/lib/python3.9/site-packages/ringcentral/http/client.py", line 34, in send raise ApiException(response, e) File "/home/username/.local/lib/python3.9/site-packages/ringcentral/http/api_exception.py", line 14, in init if api_response.error(): File "/home/username/.local/lib/python3.9/site-packages/ringcentral/http/api_response.py", line 77, in error message = message + ' (and additional error happened during JSON parse: ' + e.message + ')' AttributeError: 'Exception' object has no attribute 'message'

CloudQuery RingCentral Plugin?

opened on 2023-01-19 10:16:40 by yevgenypats

Hi Team, hopefully this is right place to ask, if not, I'd appreciate if you can direct me.

I'm the founder of cloudquery.io, a high performance open source ELT framework.

Our users are interested in a RingCentral plugin, but as we cannot maintain all the plugins ourselves, I was curious if this would be an interesting collaboration, where we would help implement an initial source plugin, and you will help maintain it.

This will give your users the ability to sync RingCentral data to any of their datalakes/data-warehouses/databases easily using any of the growing list of CQ destination plugins.

Best, Yevgeny

Do not specify default "Accept" header

opened on 2022-12-27 23:47:52 by tylerlong

There is no need to specify it. Because the server knows what content type to return. There is no ambiguity.

And since we specify json as the accept type, binary downloading stops working recently (due to a recent change on server side)


issue with fax attachments in sandbox with python SDK

opened on 2022-11-17 22:22:23 by fchepil

This is code snippet communicating with RC API that attempts to send a pdf doc for faxing.


platform = rcsdk.platform()

# platform.login(jwt=RC_JWT)
builder = rcsdk.create_multipart_builder()
    'to': [{'phoneNumber': recipient}],
    'faxResolution': "High",
    'coverPageText': "Clinic Name \n" + str(sender)

with open(faxdoc, encoding="utf8", errors='ignore') as f:
    content = f.read()
    attachment = (faxdoc, content)


request = builder.request('/account/~/extension/~/fax')

resp = platform.send_request(request)`

Everything looks good and this is output in terminal DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): platform.devtest.ringcentral.com:443 DEBUG:urllib3.connectionpool:https://platform.devtest.ringcentral.com:443 "POST /restapi/oauth/token HTTP/1.1" 200 574 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): platform.devtest.ringcentral.com:443 DEBUG:urllib3.connectionpool:https://platform.devtest.ringcentral.com:443 "POST /restapi/v1.0/account/~/extension/~/fax HTTP/1.1" 200 None INFO:root:E:\pyfaxrc\apps\response\12047861522__E:\pyfaxrc\apps\outbound\test.pdf

The fax that is received is 2 pages, a cover page and a 2nd page that has a watermark saying "test fax using ring central developer account"

The Sandbox Console shows the service as having a successful transmission, even though the attachment was not sent. if I test with a jpeg attachment, I do not receive any fax and the event logs are identical as the pdf, with exception of the filename and extension.

Any advisement appreciated.

PS: (the code snippet that opens the file was changed per RC community advisement as I was receiving errors when using the original code sample.

how set a parameter in SDK builder to not send coverpage

opened on 2021-12-16 23:32:23 by somatusbs

Hi I am reading through the code and can not figure how to set a parameter in builder to not include the coverpage. Would really appreciate guidance on this.

pip 2.7 doesn't work

opened on 2021-07-17 18:51:22 by suyashjoshi

I tried to run this command as stated in our README.md pip install ringcentral to install the SDK but ran into this error:

``` File "/tmp/easy_install-zTh0kz/setuptools_scm-6.0.1/src/setuptools_scm/utils.py", line 41 print(*k) ^ SyntaxError: invalid syntax


Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-OZLxz1/cbor2/ ```

It is because the default pip pointed to version 2.7 which is now in 'end of life' status Python https://www.python.org/downloads/ so it didn't work and then when I tried to install using pip3 install ringcentral that worked successfully. I'll submit a PR with the fix.


0.7.16 2023-01-18 01:34:54

What's Changed

  • removed accept header so to also work for binary response by @DaKingKong in https://github.com/ringcentral/ringcentral-python/pull/52

New Contributors

  • @DaKingKong made their first contribution in https://github.com/ringcentral/ringcentral-python/pull/52

Full Changelog: https://github.com/ringcentral/ringcentral-python/compare/0.7.15...0.7.16

Adding support for Analytics API 2022-10-06 21:36:13

0.7.12 2022-02-14 23:19:11

JWT tokens support

0.7.11 2019-06-05 17:36:06

  • Fixed broken Python 2.7 support
  • Fixed query string arrays

0.7.9 2018-03-13 22:07:57

  • Auth Code grant
  • Redirect URI support
  • Custom prefixes support
  • Fixed installation

0.7.8 2018-03-05 19:09:42

  • Auth Code grant
  • Redirect URI support
  • Custom prefixes support

Cloud Business Communications

GitHub Repository