{"id":7686,"library":"rocketchat-api","title":"Rocket.Chat API Wrapper","description":"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.","status":"active","version":"3.5.0","language":"python","source_language":"en","source_url":"https://github.com/jadolg/rocketchat_API","tags":["rocketchat","api","chat","wrapper","messaging"],"install":[{"cmd":"pip install rocketchat-api","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Handles underlying HTTP communication with the Rocket.Chat server.","package":"requests","optional":false}],"imports":[{"wrong":"from rocketchat_API.rocketchat import RocketChatAPI","symbol":"RocketChatAPI","correct":"from rocketchat_API import RocketChatAPI"}],"quickstart":{"code":"import os\nfrom rocketchat_API.rocketchat import RocketChatAPI\n\n# Configure connection details and credentials via environment variables for security\nROCKETCHAT_SCHEME = os.environ.get('ROCKETCHAT_SCHEME', 'https')\nROCKETCHAT_HOST = os.environ.get('ROCKETCHAT_HOST', 'demo.rocket.chat')\nROCKETCHAT_PORT = os.environ.get('ROCKETCHAT_PORT', '443') # Note: Port should be string for consistent config\nROCKETCHAT_USER = os.environ.get('ROCKETCHAT_USER', 'your_username')\nROCKETCHAT_PASS = os.environ.get('ROCKETCHAT_PASS', 'your_password')\n\nrocket = RocketChatAPI(settings={\n    'scheme': ROCKETCHAT_SCHEME,\n    'host': ROCKETCHAT_HOST,\n    'port': int(ROCKETCHAT_PORT), # Ensure port is int if expected by library\n    'username': ROCKETCHAT_USER,\n    'password': ROCKETCHAT_PASS\n})\n\n# Example: Get information about the current user\ntry:\n    me_info = rocket.me().json()\n    print(f\"Logged in as: {me_info.get('username')}\")\nexcept Exception as e:\n    print(f\"Error connecting or authenticating: {e}\")\n\n# Example: Send a direct message\ntry:\n    if me_info and 'username' in me_info:\n        # Replace 'otheruser' with a valid Rocket.Chat username to send a message to\n        response = rocket.chat_post_message(room_id='GENERAL', text='Hello from rocketchat-api!').json()\n        print(f\"Message sent status: {response.get('success')}\")\nexcept Exception as e:\n    print(f\"Error sending message: {e}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"Starting 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.","severity":"breaking","affected_versions":">=3.0.0"},{"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`.","message":"In 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.","severity":"breaking","affected_versions":">=2.1.0"},{"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()`.","message":"As 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`.","severity":"breaking","affected_versions":">=2.0.0"},{"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))`.","message":"When 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).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'-2':52 '1':51 '3.5.0':59 'abstract':32 'activ':40 'allow':14 'api':2,6,10,30,61 'away':33 'cadenc':46 'chat':62 'conveni':25 'current':56 'develop':15 'direct':34 'endpoint':31 'everi':50 'http':35 'instanc':21 'interact':18 'interfac':26 'librari':38 'maintain':41 'messag':64 'minor':48 'month':53 'programmat':17 'provid':23 'python':9 'releas':45 'request':36 'rocket.chat':1,13,20,29 'rocketchat':5,60 'rocketchat-api':4 'typic':44 'various':28 'version':49,57 'wrapper':3,11,63","created_at":"2026-04-16T14:09:02.326150+00:00","updated_at":"2026-04-16T14:09:02.326150+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'RocketChatAPI' from 'rocketchat_API' (/tmp/tmp60rmqjya/venv/lib/python3.12/site-packages/rocketchat_API/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.6.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jadolg/rocketchat_API","docs":null,"changelog":null,"pypi":"https://pypi.org/project/rocketchat-api/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}