Python API wrapper for Rocket.Chat
Project description
rocketchat_API
Python API wrapper for Rocket.Chat
Installation
From PyPI (recommended):
pip install rocketchat_API
From source:
git clone https://github.com/jadolg/rocketchat_API.git
cd rocketchat_API
pip install .
Requirements
- Python 3.10 or higher
- requests
Compatibility
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.
Usage
Basic Authentication
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)
Token-Based Authentication
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()
Method Parameters
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.
Development
Setting Up the Development Environment
- Clone the repository:
git clone https://github.com/jadolg/rocketchat_API.git
cd rocketchat_API
- Install development dependencies:
pip install -e ".[test]"
Running Tests
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
Code Style
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.
Contributing
See CONTRIBUTING.md for guidelines on how to contribute to this project.
License
This project is licensed under the MIT License. See LICENSE.txt for details.
Supporters
JetBrains supports this project by providing licenses for their development tools.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rocketchat_api-3.5.0.tar.gz.
File metadata
- Download URL: rocketchat_api-3.5.0.tar.gz
- Upload date:
- Size: 89.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a135f5edf8f719b6324954990281849cbc600421c3774feba55bba4e934f4f01
|
|
| MD5 |
7468b429ed6c77317b4a624ae5584d23
|
|
| BLAKE2b-256 |
104f7b5ede3d0340d7e455d62693edd9d533d059b59400a03ef2c4a3721fb971
|
Provenance
The following attestation bundles were made for rocketchat_api-3.5.0.tar.gz:
Publisher:
release.yml on jadolg/rocketchat_API
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocketchat_api-3.5.0.tar.gz -
Subject digest:
a135f5edf8f719b6324954990281849cbc600421c3774feba55bba4e934f4f01 - Sigstore transparency entry: 1279792795
- Sigstore integration time:
-
Permalink:
jadolg/rocketchat_API@e2a85e94fd4aeba66e9da7a99f2e5eb0d1d5e63f -
Branch / Tag:
refs/tags/3.5.0 - Owner: https://github.com/jadolg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e2a85e94fd4aeba66e9da7a99f2e5eb0d1d5e63f -
Trigger Event:
release
-
Statement type:
File details
Details for the file rocketchat_api-3.5.0-py3-none-any.whl.
File metadata
- Download URL: rocketchat_api-3.5.0-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f3e283c22611279345715ece843f6402dd9e910b20a9520e99817a354b68f92
|
|
| MD5 |
1e214fa7cb1078cc3674ebc4a584d4f7
|
|
| BLAKE2b-256 |
0a377cf161d79d2978536ad5df74050d1c75f5ec330d92e099501e9b0c6b2a99
|
Provenance
The following attestation bundles were made for rocketchat_api-3.5.0-py3-none-any.whl:
Publisher:
release.yml on jadolg/rocketchat_API
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocketchat_api-3.5.0-py3-none-any.whl -
Subject digest:
2f3e283c22611279345715ece843f6402dd9e910b20a9520e99817a354b68f92 - Sigstore transparency entry: 1279792818
- Sigstore integration time:
-
Permalink:
jadolg/rocketchat_API@e2a85e94fd4aeba66e9da7a99f2e5eb0d1d5e63f -
Branch / Tag:
refs/tags/3.5.0 - Owner: https://github.com/jadolg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e2a85e94fd4aeba66e9da7a99f2e5eb0d1d5e63f -
Trigger Event:
release
-
Statement type: