rocketchat-api is a Python API wrapper for Rocket.Chat, allowing developers to programmatically interact with Rocket.Chat instances. It provides a convenient interface to various Rocket.Chat API endpoints, abstracting away direct HTTP requests. The library is actively maintained, with a typical release cadence of minor versions every 1-2 months, and its current version is 3.5.0.
pip install rocketchat-apiVerified import paths — ran on the pinned version, not inferred.
Initializes the RocketChatAPI client using environment variables for credentials and connects to a Rocket.Chat instance. It then demonstrates fetching the current user's information and sending a public message. Ensure you replace 'your_username' and 'your_password' with actual credentials or set the corresponding environment variables.
Catch `RocketApiException` and access error details via its attributes (e.g., `e.error`). Update any conditional logic that inspects exception messages to use these new attributes for robustness.
Review calls to affected methods and update parameters accordingly. For `users_create_token`, pass the `secret` value. For role management, ensure you're passing the `role_id`.
Remove `.json()` calls from the end of API method invocations. The methods directly return the parsed JSON response. For example, change `rocket.me().json()` to `rocket.me()`.
Convert the port string to an integer before passing it to the `RocketChatAPI` constructor, e.g., `port=int(os.environ.get('ROCKETCHAT_PORT', 443))`.