Python API wrapper for Rocket.Chat
From PyPI (recommended):
pip install rocketchat_API
From source:
git clone https://github.com/jadolg/rocketchat_API.git cd rocketchat_API pip install .
- Python 3.11 or higher
- requests
This library is tested against all supported versions of Python and Rocket.Chat. It is also continuously tested against the latest Rocket.Chat release to ensure compatibility with new versions.
We do not guarantee any compatibility outside of the tested versions.
See the Test GitHub Action to get the list of tested versions.
from rocketchat_API.rocketchat import RocketChat rocket = RocketChat('user', 'pass', server_url='https://demo.rocket.chat') # Get current user info rocket.me() # List all channels for channel in rocket.channels_list(): print(channel.get("name")) # Post a message rocket.chat_post_message('good news everyone!', channel='GENERAL', alias='Farnsworth') # Get channel history rocket.channels_history('GENERAL', max_count=5)
If you already have a user ID and authentication token, you can use them directly:
from rocketchat_API.rocketchat import RocketChat rocket = RocketChat( user_id='WPXGmQ64S3BXdCRb6', auth_token='jvNyOYw2f0YKwtiFS06Fk21HBRBBuV7zI43HmkNzI_s', server_url='https://demo.rocket.chat' ) rocket.me()
Only required parameters are explicitly defined in the RocketChat class methods. However, you can pass any additional parameters supported by the Rocket.Chat API. For a complete list of available parameters, refer to the official Rocket.Chat API documentation.
- Clone the repository:
git clone https://github.com/jadolg/rocketchat_API.git
cd rocketchat_API- Install development dependencies:
pip install -e ".[test]"Tests run against a Rocket.Chat instance in Docker. Make sure you have Docker and Docker Compose installed.
- Start the test server:
docker compose up -d
- Wait for Rocket.Chat to be ready:
until curl --silent http://localhost:3000/api/info/; do sleep 15; echo "waiting for Rocket.Chat server to start"; done
- Run the tests:
pytest
- To run tests with coverage:
pytest --cov=rocketchat_API
- When finished, stop the test server:
docker compose down
This project uses black for code formatting. All code must be formatted with black before submitting a pull request.
To format your code:
black .To check if your code is properly formatted:
black --check --diff .The CI pipeline will automatically reject pull requests that are not properly formatted.
See CONTRIBUTING.md for guidelines on how to contribute to this project.
This project is licensed under the MIT License. See LICENSE.txt for details.