RingCentral Python SDK

0.9.2 · active · verified Thu Apr 16

The RingCentral Python SDK provides a convenient way to interact with the RingCentral API, simplifying authentication, request signing, and API call execution. It is currently at version 0.9.2 and follows a semi-regular release cadence, often bundling bug fixes and minor feature enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the RingCentral SDK using environment variables for credentials (client ID, client secret, server URL, username, password). It then performs a login using the password flow and fetches basic account information, finally logging out. Remember to replace placeholder values or set environment variables.

import os
from ringcentral import SDK

# Environment variables for RingCentral credentials
CLIENT_ID = os.environ.get('RINGCENTRAL_CLIENT_ID', 'YOUR_CLIENT_ID')
CLIENT_SECRET = os.environ.get('RINGCENTRAL_CLIENT_SECRET', 'YOUR_CLIENT_SECRET')
SERVER_URL = os.environ.get('RINGCENTRAL_SERVER_URL', 'https://platform.ringcentral.com') # Use 'https://platform.devtest.ringcentral.com' for sandbox
USERNAME = os.environ.get('RINGCENTRAL_USERNAME', 'YOUR_USERNAME') # Phone number with country code, e.g., +1650xxxxxxx
PASSWORD = os.environ.get('RINGCENTRAL_PASSWORD', 'YOUR_PASSWORD')
EXTENSION = os.environ.get('RINGCENTRAL_EXTENSION', None) # Optional, usually '101' for main extension

try:
    if not all([CLIENT_ID, CLIENT_SECRET, SERVER_URL, USERNAME, PASSWORD]):
        print("Please set RINGCENTRAL_CLIENT_ID, RINGCENTRAL_CLIENT_SECRET, RINGCENTRAL_SERVER_URL, RINGCENTRAL_USERNAME, and RINGCENTRAL_PASSWORD environment variables.")
        exit(1)

    rcsdk = SDK(CLIENT_ID, CLIENT_SECRET, SERVER_URL)
    platform = rcsdk.platform()

    # Authorize using password flow
    platform.login(username=USERNAME, password=PASSWORD, extension=EXTENSION)
    print("Logged in successfully!")

    # Example: Fetch extension info
    resp = platform.get('/restapi/v1.0/account/~')
    account_info = resp.json()
    print(f"Account ID: {account_info['id']}")
    print(f"Account Name: {account_info['name']}")

    platform.logout()
    print("Logged out.")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →