Python API wrapper for the Rocket chat API
pip install rocket-python
Initialize the client with a username and password or token and user_id. Currently no 2FA is supported.
from rocketchat.api import RocketChatAPI
api = RocketChatAPI(settings={'username': 'someuser', 'password': 'somepassword',
'domain': 'https://myrocketchatdomain.com'})
# or
api = RocketChatAPI(settings={'token': 'sometoken', 'user_id': 'someuserid',
'domain': 'https://myrocketchatdomain.com'})
api.send_message('message', 'room_id')
api.upload_file(room_id='room_id',
file='file',
description='File description',
message='Example message')
api.upload_remote_file(room_id='room_id',
url='url',
description='File description',
message='Example message')
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.get_user_id('user_name')
api.get_users()
api.get_user_info('user_id')
api.get_my_info()
api.create_im_room('username')
api.close_room('room_id')
api.open_room('room_id')
api.get_im_room_history('room_id', oldest=date)
api.get_im_rooms()
api.create_private_room('room_name',
members=[],
read_only=False)
api.invite_private_room('room_id', 'user_id')
api.get_private_rooms()
api.get_private_room_history('room_id', oldest=date)
api.get_room_id('room_name')
api.get_private_room_info('room_id')
api.set_room_topic('topic', 'room_id')
api.get_public_rooms()
api.create_public_room('room_name',
members=[],
read_only=False)
api.invite_public_room('room_id', 'user_id')
api.get_room_info('room_id')
api.get_public_room_id('room_name')
api.get_room_history('room_id')
api.delete_public_room('room_id')
check /rocketchat/calls/api.py for more.
py.test tests rocketchat
You'll first need to get the _id
of the room you want to send a message to.
api.send_message('Your message', room_id)