Registry / communication / rocketchat-api

rocketchat-api

JSON →
library3.6.1pypypiunverified

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-api
INSTALL
IMPORT
SIG · ROCKETCHAT-API
R
rocketchat-api
communicationpythonv3.6.1
Install
2.3s avg
Import
—
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.6.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.3MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 2.3s · import 0.000s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RocketChatAPI
✓ from rocketchat_API import RocketChatAPI
✗ from rocketchat_API.rocketchat import RocketChatAPI

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.

import os from rocketchat_API.rocketchat import RocketChatAPI # Configure connection details and credentials via environment variables for security ROCKETCHAT_SCHEME = os.environ.get('ROCKETCHAT_SCHEME', 'https') ROCKETCHAT_HOST = os.environ.get('ROCKETCHAT_HOST', 'demo.rocket.chat') ROCKETCHAT_PORT = os.environ.get('ROCKETCHAT_PORT', '443') # Note: Port should be string for consistent config ROCKETCHAT_USER = os.environ.get('ROCKETCHAT_USER', 'your_username') ROCKETCHAT_PASS = os.environ.get('ROCKETCHAT_PASS', 'your_password') rocket = RocketChatAPI(settings={ 'scheme': ROCKETCHAT_SCHEME, 'host': ROCKETCHAT_HOST, 'port': int(ROCKETCHAT_PORT), # Ensure port is int if expected by library 'username': ROCKETCHAT_USER, 'password': ROCKETCHAT_PASS }) # Example: Get information about the current user try: me_info = rocket.me().json() print(f"Logged in as: {me_info.get('username')}") except Exception as e: print(f"Error connecting or authenticating: {e}") # Example: Send a direct message try: if me_info and 'username' in me_info: # Replace 'otheruser' with a valid Rocket.Chat username to send a message to response = rocket.chat_post_message(room_id='GENERAL', text='Hello from rocketchat-api!').json() print(f"Message sent status: {response.get('success')}") except Exception as e: print(f"Error sending message: {e}")
Debug
Known issues
breakingStarting with v3.0.0, the library's exception handling was reworked. Exceptions now carry more detailed error information. Code relying on generic exception catching or checking specific exception attributes might need updates.
fix
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.
affects: >=3.0.0
breakingIn v2.1.0, several API method signatures changed. `rooms_upload` was removed. `addUserToRole` and `removeUserFromRole` now require `role_id` instead of `role_name`. `users_create_token` no longer accepts `username` but requires a `secret` parameter.
fix
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`.
affects: >=2.1.0
breakingAs of v2.0.0, API methods no longer return the raw `requests` response object directly. Instead, they return the JSON body of the response, often as a dictionary or list. Calling `.json()` on the return value will result in an `AttributeError`.
fix
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()`.
affects: >=2.0.0
gotchaWhen providing a custom port for the Rocket.Chat instance, ensure it is passed as an integer in the `settings` dictionary during `RocketChatAPI` initialization, even if read from environment variables (which are strings).
fix
Convert the port string to an integer before passing it to the `RocketChatAPI` constructor, e.g., `port=int(os.environ.get('ROCKETCHAT_PORT', 443))`.
affects: All versions
Upgrade
Version history
3.6.1latest on PyPI · released May 2, 2026
Audit
Dependencies
requestsrequiredHandles underlying HTTP communication with the Rocket.Chat server.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
rocketchat-api — pip install rocketchat-api · libregistry