Skip to main content

RocketChat API with Python

Project description

RocketChat API

Python API wrapper for the Rocket chat API

Documentation

Travis (.org) PyPI - Downloads PyPI Codecov

Install

pip install rocket-python

Usage

Initialize the client with a username and password or token and user_id. This user must have Admin privs:

from rocketchat.api import RocketChatAPI

api = RocketChatAPI(settings={'username': 'someuser', 'password': 'somepassword',
                              'domain': 'https://myrockethchatdomain.com'})
# or
api = RocketChatAPI(settings={'token': 'sometoken', 'user_id': 'someuserid',
                              'domain': 'https://myrockethchatdomain.com'})
Available Calls
api.send_message('message', 'room_id')

api.get_private_rooms()

api.get_private_room_history('room_id', oldest=date)

api.get_public_rooms()

api.get_room_info('room_id')

api.get_private_room_info('room_id')

api.get_room_history('room_id')

api.create_public_room('room_name', 
                        members=[], 
                        read_only=False)

api.delete_public_room('room_id')

api.get_my_info()

api.get_users()

api.get_user_info('user_id')

api.create_user('email', 
                'name', 
                'password', 
                'username', 
                 active=True, 
                 roles=['user'], 
                 join_default_channels=True, 
                 require_password_change=False, 
                 send_welcome_email=False, 
                 verified=False, 
                 customFields=None)
                
api.delete_user('user_id')

api.upload_file(room_id='room_id',
                file='file',
                description='File description',
                message='Example message')

check /rocketchat/calls/api.py for more.

Running Tests

py.test tests rocketchat
Sending a message

You'll first need to get the _id of the room you want to send a message to. Currently, Rocket can only send messages to public rooms.

api.send_message('Your message', room_id)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

rocket_python-1.3.3-py2.py3-none-any.whl (22.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rocket_python-1.3.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for rocket_python-1.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5e8bc74111ed86406d102ee983be299dedc496ce843bd02a5f079eafc684da8d
MD5 2f0c74cba948298fd2fba69bba577476
BLAKE2b-256 a9dcec058428c12f9aef60a13a2fc7fddd28806b2e06e3c2f2432804a1b4ae16

See more details on using hashes here.

Provenance

Supported by

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