Introduction¶
Rocket Python is a Python 2 and 3 library to access the REST API in RocketChat instances. The goal is to implement the entire REST API provided by RocketChat.
Installation¶
First step is to install via pip:
pip install rocket-python
You’ll need to create an instance of the Rocket API by logging in:
from rocketchat.api import RocketChatAPI
api = RocketChatAPI(settings={'username': 'someuser', 'password': 'somepassword',
'domain': 'https://myrockethchatdomain.com'})
Main API Documentation¶
rocketchat package¶
Subpackages¶
rocketchat.calls package¶
Subpackages¶
rocketchat.calls.auth package¶
Submodules¶
rocketchat.calls.auth.get_me module¶
-
class
rocketchat.calls.auth.get_me.
GetMe
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/me'¶
-
post_response
(result)¶
-
Module contents¶
rocketchat.calls.channels package¶
Submodules¶
rocketchat.calls.channels.create_public_room module¶
-
class
rocketchat.calls.channels.create_public_room.
CreatePublicRoom
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.PostMixin
,rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
endpoint
= '/api/v1/channels.create'¶
-
post_response
(result)¶
-
rocketchat.calls.channels.delete_public_room module¶
-
class
rocketchat.calls.channels.delete_public_room.
DeletePublicRoom
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.PostMixin
,rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
endpoint
= '/api/v1/channels.delete'¶
-
post_response
(result)¶
-
rocketchat.calls.channels.get_history module¶
-
class
rocketchat.calls.channels.get_history.
GetRoomHistory
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/channels.history'¶
-
post_response
(result)¶
-
rocketchat.calls.channels.get_public_rooms module¶
-
class
rocketchat.calls.channels.get_public_rooms.
GetPublicRooms
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
()¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/channels.list'¶
-
post_response
(result)¶
-
rocketchat.calls.channels.get_room_info module¶
-
class
rocketchat.calls.channels.get_room_info.
GetRoomInfo
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/channels.info'¶
-
post_response
(result)¶
-
Module contents¶
rocketchat.calls.chat package¶
Submodules¶
rocketchat.calls.chat.send_message module¶
-
class
rocketchat.calls.chat.send_message.
SendMessage
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.PostMixin
,rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
endpoint
= '/api/v1/chat.postMessage'¶
-
Module contents¶
rocketchat.calls.groups package¶
Submodules¶
rocketchat.calls.groups.get_private_room_history module¶
-
class
rocketchat.calls.groups.get_private_room_history.
GetPrivateRoomHistory
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/groups.history'¶
-
post_response
(result)¶
-
rocketchat.calls.groups.get_private_room_info module¶
-
class
rocketchat.calls.groups.get_private_room_info.
GetPrivateRoomInfo
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/groups.info'¶
-
post_response
(result)¶
-
rocketchat.calls.groups.get_private_rooms module¶
-
class
rocketchat.calls.groups.get_private_rooms.
GetPrivateRooms
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
()¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/groups.list'¶
-
post_response
(result)¶
-
rocketchat.calls.groups.get_room_id module¶
-
class
rocketchat.calls.groups.get_room_id.
GetRoomId
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/groups.info'¶
-
post_response
(result)¶
-
rocketchat.calls.groups.upload_file module¶
-
class
rocketchat.calls.groups.upload_file.
UploadFile
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.PostMixin
,rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_files
(**kwargs)¶ Build files :param kwargs: :return:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
endpoint
= '/api/v1/rooms.upload'¶
-
post_response
(result)¶
-
Module contents¶
rocketchat.calls.users package¶
Submodules¶
rocketchat.calls.users.create_user module¶
-
class
rocketchat.calls.users.create_user.
CreateUser
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.PostMixin
,rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
endpoint
= '/api/v1/users.create'¶
-
post_response
(result)¶
-
rocketchat.calls.users.delete_user module¶
-
class
rocketchat.calls.users.delete_user.
DeleteUser
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.PostMixin
,rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
endpoint
= '/api/v1/users.delete'¶
-
post_response
(result)¶
-
rocketchat.calls.users.get_user_info module¶
-
class
rocketchat.calls.users.get_user_info.
GetUserInfo
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/users.info'¶
-
post_response
(result)¶
-
rocketchat.calls.users.get_users module¶
-
class
rocketchat.calls.users.get_users.
GetUsers
(settings=None, *args, **kwargs)¶ Bases:
rocketchat.calls.base.RocketChatBase
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
endpoint
= '/api/v1/users.list'¶
-
post_response
(result)¶
-
Module contents¶
Submodules¶
rocketchat.calls.base module¶
-
class
rocketchat.calls.base.
RocketChatBase
(settings=None, *args, **kwargs)¶ Bases:
object
-
auth_token
= None¶
-
auth_user_id
= None¶
-
build_endpoint
(**kwargs)¶ Build the endpoint for the user given some kwargs from the initial calling.
Returns:
-
build_files
(**kwargs)¶ Build files :param kwargs: :return:
-
build_payload
(**kwargs)¶ Build a payload dict that will be passed directly to the endpoint. If you need to pass this as plain text or whatever you’ll need to the dumping here.
Returns:
-
call
(*args, **kwargs)¶ Parameters: - args –
- kwargs –
Returns:
-
endpoint
= None¶
-
files
= None¶
-
headers
= {}¶
-
method
= 'get'¶
-
post_response
(result)¶
-
set_auth_headers
()¶
-
set_auth_token
()¶
-
settings
= None¶
-
Module contents¶
Submodules¶
rocketchat.api module¶
-
class
rocketchat.api.
RocketChatAPI
(settings=None, *args, **kwargs)¶ Bases:
object
-
close_im_room
(room_id, **kwargs)¶ Close direct message room
Parameters: room_id – Returns:
-
create_im_room
(username, **kwargs)¶ Create direct message room with user
Parameters: username – Returns:
-
create_public_room
(name, **kwargs)¶ Create room with given name :param name: Room name :param kwargs: members: The users to add to the channel when it is created.
Optional; Ex.: [“rocket.cat”], Default: []- read_only: Set if the channel is read only or not.
- Optional; Ex.: True, Default: False
Returns:
-
create_user
(email, name, password, username, **kwargs)¶ Create user :param email: E-mail :param name: Full name :param password: Password :param username: Username :param kwargs: active: roles: join_default_channels: require_password_change: send_welcome_email: verified: custom_fields: :return:
-
delete_public_room
(room_id, **kwargs)¶ Delete room with given ID :param room_id: Room ID :param kwargs: :return:
-
delete_user
(user_id, **kwargs)¶ Delete user :param user_id: User ID :param kwargs: :return:
-
get_im_room_history
(room_id, oldest=None, latest=datetime.datetime(2023, 3, 24, 18, 58, 42, 106267), inclusive=False, count=20, unreads=False, **kwargs)¶ Get various history of specific direct message room
Parameters: - room_id –
- kwargs –
Returns:
-
get_im_rooms
(**kwargs)¶ Get direct message rooms
Returns:
-
get_my_info
(**kwargs)¶
-
get_private_room_history
(room_id, oldest=None, **kwargs)¶ Get various history of specific private group in this case private
Parameters: - room_id –
- kwargs –
Returns:
-
get_private_room_info
(room_id, **kwargs)¶ Get various information about a specific private group
Parameters: - room_id –
- kwargs –
Returns:
-
get_private_rooms
(**kwargs)¶ Get a listing of all private rooms with their names and IDs
-
get_public_rooms
(**kwargs)¶ Get a listing of all public rooms with their names and IDs
-
get_room_history
(room_id, oldest=None, latest=datetime.datetime(2023, 3, 24, 18, 58, 42, 106242), inclusive=False, count=20, unreads=False, **kwargs)¶ Get various history of specific channel/room
Parameters: - room_id –
- kwargs –
Returns:
-
get_room_id
(room_name, **kwargs)¶ Get room ID :param room_name: :param kwargs: :return:
-
get_room_info
(room_id, **kwargs)¶ Get various information about a specific channel/room
Parameters: - room_id –
- kwargs –
Returns:
-
get_user_info
(user_id, **kwargs)¶ Retrieves information about a user, the result is only limited to what the callee has access to view. :param user_id: :param kwargs: :return:
-
get_users
(**kwargs)¶ Gets all of the users in the system and their information :param kwargs: :return:
-
logout
(**kwargs)¶ Logout
Returns:
-
open_im_room
(room_id, **kwargs)¶ Open direct message room
Parameters: room_id – Returns:
-
send_message
(message, room_id, **kwargs)¶ Send a message to a given room
-
set_room_topic
(room_id, topic, **kwargs)¶
-
settings
= None¶
-
upload_file
(room_id, description, file, message, mime_type='text/plain', **kwargs)¶ Upload file to room :param room_id: :param description: :param file: :param kwargs: :return:
-
Module contents¶
Detailed Module Docs¶
Licensing¶
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.