Skip to main content

Python API wrapper for Rocket.Chat

Project description

rocketchat_API

Python API wrapper for Rocket.Chat

Codacy Badge Test Test against latest Rocket.Chat version codecov PyPI

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

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

  1. Clone the repository:
git clone https://github.com/jadolg/rocketchat_API.git
cd rocketchat_API
  1. 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.

  1. Start the test server:
docker compose up -d
  1. 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
  1. Run the tests:
pytest
  1. To run tests with coverage:
pytest --cov=rocketchat_API
  1. 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 logo.

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

rocketchat_api-3.6.0.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rocketchat_api-3.6.0-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file rocketchat_api-3.6.0.tar.gz.

File metadata

  • Download URL: rocketchat_api-3.6.0.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rocketchat_api-3.6.0.tar.gz
Algorithm Hash digest
SHA256 4d09aea8ddb1d590c25976978602c28021ba5485c6e6f21b8e3c5944007ebfe7
MD5 7e654e8e9f5e3422d7d3e4a1a4409ced
BLAKE2b-256 34dde1c29315aef597e4d3fb401c2a41e5185ea89fafb5a8712f4728ce61dbba

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocketchat_api-3.6.0.tar.gz:

Publisher: release.yml on jadolg/rocketchat_API

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rocketchat_api-3.6.0-py3-none-any.whl.

File metadata

  • Download URL: rocketchat_api-3.6.0-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rocketchat_api-3.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cd203f67e119c5eb8142c2699641abcaf46c69d7ea090bea1c4a52f3b1a9cf8
MD5 2ea8a33fb4ef2edfd81381d1ef9f0aab
BLAKE2b-256 66bb165884558a49bbe85787c3e635f4401e6d06eeeae3818d9d70af60a91786

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocketchat_api-3.6.0-py3-none-any.whl:

Publisher: release.yml on jadolg/rocketchat_API

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page