Skip to main content

RingCentral SDK for Python

Unit Tests 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.

Additional resources

Important change logs

1.0.1

  • The SDK requires CPython 3.11 or later. CI tests CPython 3.11 through 3.15.
  • WebSocket subscriptions match server responses to requests, report changes after the server confirms them, and prevent duplicate subscription creation.
  • Each WebSocket client manages one subscription. Use the object from subscriptionCreated to update or remove it. Overrides of send_message() apply to direct calls.
  • Managed subscription frame processing is private. If you used WebSocketSubscription.on_message(), consume the client's subscription events.
  • The WebSocket client reports receive-handler errors without interrupting other handlers and clears its ready state when the receive loop ends.
  • Each WebSocket client owns one connection. Setup waits up to 10 seconds for the initial ConnectionDetails frame, and close invalidates any pending setup.
  • WebSocket setup and recovery use built-in Platform authentication. Token and OAuth refresh HTTP run off the event loop, and SDK callbacks run on that loop. Cancelling a setup stops that connection attempt. A shared OAuth refresh can still finish for the current login.
  • WebSocket recovery uses the saved connection token, keeps confirmed subscriptions when RingCentral restores the session, and reports interrupted requests with unknown outcomes through their subscription error events.
  • WebSocket subscription failures remain available through exceptions and error events, leaving any stdout output to the application.
  • WebSocket sends and subscription creation wait up to 10 seconds per call for a ready connection. On expiry, the SDK emits connectionNotReady and raises TimeoutError before sending. See Subscribing for server events for retry behavior.
  • The SDK supports websockets versions 15 through 17. See Subscribing for server events if you use the underlying connection directly.
  • Upgraded to observable 1.x while preserving SDK callback registration and dispatch behavior.
  • Removed the unused presence_subscription_mock() and subscription_mock() methods from ringcentral.test.TestCase.
  • Apps configured for the OAuth client credentials grant can call login() without arguments.
  • A successful login replaces the prior authentication data. A failed request or malformed response leaves the current session intact.
  • This release carries forward the 0.9.3 certificate bundle fix by requiring certifi>=2026.10.19.
  • Installation requires Requests 2.33.0 or later and urllib3 2.8.0 or later within their 2.x series to pick up security fixes in existing environments.
  • HTTP requests default to a 5-second connect_timeout and a 30-second read_timeout. See HTTP timeouts.
  • Development defaults to Python 3.15. Development and release checks use a locked uv environment.
  • API exception messages omit headers, query strings, and fragments from formatted request details. See Error handling for access to the original request.
  • HTTP requests honor header names regardless of case, preserve caller inputs, and correctly encode query parameters, including lists as repeated values.

Earlier releases

  • In version 0.9.0, we removed PubNub support. If you need subscription to events, please use WebSocket instead. Please refer to demo_subscription.py for more information.
    • If you still need PubNub support, please use version 0.8.x.

Installation

This SDK requires CPython 3.11 or later.

$ pip3 install ringcentral

Usage

Take a look at a sample code.

from ringcentral import SDK

sdk = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER')
platform = sdk.platform()
platform.login(jwt='JWT_TOKEN')
res = platform.get('/account/~/extension/~')
print('User loaded ' + res.json().name)

Each successful login starts with fresh authentication data. If the new response omits a refresh token, the previous token is cleared. If the login request fails or its response is malformed, the prior session stays active. A refresh still in progress for a replaced login cannot change the current session.

Client credentials

For an app configured for the OAuth client credentials grant, call login() with no arguments. The SDK exchanges the client ID and secret for a fresh access token when a request needs one. Call platform.refresh() to renew the token explicitly.

from ringcentral import SDK

platform = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER').platform()
platform.login()
account = platform.get('/restapi/v2/accounts/~').json_dict()
print(account['id'])

Error handling

For failed HTTP responses, the SDK includes the status and RingCentral error text in the exception message. Its formatted request details contain the method and URL path, with headers, query strings, and fragments omitted. To inspect the original request explicitly, call exc.api_response().request() on the caught ApiException.

HTTP timeouts

The SDK defaults to a 5-second connect timeout and a 30-second read timeout for API and token requests. Set connect_timeout and read_timeout in seconds when you create the SDK. Omit either value or pass None to use its default.

sdk = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER', connect_timeout=2, read_timeout=10)

The read timeout measures how long the SDK waits for more data. A response can take longer overall if data keeps arriving. Both timeouts raise ApiException. The server may already have applied a write before the request timed out, so decide whether a retry is safe for that operation.

Subscribing for server events

Please refer to demo_subscription.py

Use a separate sdk.create_web_socket_client() for each simultaneous connection. Each client rejects another setup while it has a ready connection, an ongoing setup, or a socket to close. To reuse that client, await close_connection() before starting another setup. Close is safe to call during setup or after an earlier close. The receive loop and JSON heartbeat belong to their socket.

The SDK uses its own setup path for create_new_connection() and recover_connection(). Applications with their own WebSocket URI and access token can call open_connection() directly. If a subclass overrides open_connection(), applications invoke that override with a direct call.

SDK-managed setup and recovery use built-in token acquisition. Overrides of get_web_socket_token() and Platform request or refresh methods apply to direct application calls. SDK token and OAuth refresh callbacks run on the event loop. Cancelling setup during token acquisition prevents dialing. A shared OAuth refresh can finish for the current login after that setup is cancelled.

Each call to send_message() or create_subscription() waits up to 10 seconds for the connection to become ready. On expiry, the SDK emits connectionNotReady and raises TimeoutError before sending anything. Once ready, the SDK attempts the send once. The caller decides whether to retry after a send error.

Each WebSocket client manages one subscription and one outstanding subscription request. Use create_subscription() to create the subscription and use the object from that client's subscriptionCreated event for update_subscription() or remove_subscription(). The SDK sends these requests through an internal path. Call send_message() directly to send your own messages or use a subclass override.

Awaiting create_subscription(), update_subscription(), or remove_subscription() completes request submission. The corresponding subscriptionCreated, subscriptionUpdated, or subscriptionRemoved event reports server confirmation. The corresponding createSubscriptionError, updateSubscriptionError, or removeSubscriptionError event reports failure. Register your event handlers before submitting the request.

To observe raw WebSocket messages, register a receiveMessage handler. The SDK delivers the original message to raw observers before it processes the message for an active subscription or a pending subscription request. The socket continues to deliver raw messages after confirmed removal or a session reset. off(WebSocketEvents.receiveMessage) clears raw observers independently of managed subscription events. Calling trigger(WebSocketEvents.receiveMessage, message) dispatches only raw observers. A failing raw observer or managed processing step emits its own receiveMessageError with the original exception. Reception continues.

After a disconnect or an intentional close, call recover_connection() to try to restore the previous session. The SDK applies the result before emitting connectionCreated. Successful recovery retains the confirmed subscription and gives possibly transmitted create, update, and remove requests up to 10 seconds for a matching confirmation. The SDK never replays those requests. When the outcome remains unknown, the SDK reports it through createSubscriptionError, updateSubscriptionError, or removeSubscriptionError and keeps the last confirmed subscription state. Check the server state before retrying.

If RingCentral lost the previous session or there is no recovery token, the connection starts a fresh session. Call create_subscription() again after connectionCreated. The original server frame is available as get_connection_info()["connection_details"]. During a recovery attempt, its body reports RingCentral's recoveryState. RingCentral WebSocket recovery guide

The SDK supports websockets versions 15 through 17. get_connection() exposes the underlying websockets connection. To send bytes as a text frame on that connection, use send(data, text=True). Version 17 requires text as a keyword. websockets 17 migration notes

Send SMS

See the SMS demo for a complete example.

dev-notes

https://github.com/ringcentral/ringcentral-python/blob/master/dev-notes.md

Metadata

Release files for ringcentral 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ringcentral 1.0.1
File Size Uploaded Provenance Actions
ringcentral-1.0.1.tar.gz 57.8 kB Without provenance Details for ringcentral-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ringcentral 1.0.1
File Interpreter ABI Platform Actions
ringcentral-1.0.1-py3-none-any.whl Python 3 none any Details for ringcentral-1.0.1-py3-none-any.whl

Total release size: 119.6 kB

Release files / ringcentral-1.0.1.tar.gz

Download URL ringcentral-1.0.1.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
73e8f708eeed76fed75ec85d2d8f013f5e61a3f287b1d918b1d7dbf7525e56f7
BLAKE2b-256 checksum
How to use checksums
5baada5d9676e01e61e2d6f14bc6e75a479b9647557ac9c6eea959fa6c3308f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / ringcentral-1.0.1-py3-none-any.whl

Download URL ringcentral-1.0.1-py3-none-any.whl
Size 61.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad14fa58458eaf90790824bb5efd3bcc85fe8864740a37a8a68998f4d75bce0d
BLAKE2b-256 checksum
How to use checksums
6b9be5d7d956c3217ef59569adf5e4cc5250e41ae873c930ee61bdbd5191630f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for ringcentral 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page