or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/pypi-rocketchat-a-p-i

Python API wrapper for Rocket.Chat's REST API, enabling developers to programmatically interact with Rocket.Chat servers for chat automation, bot development, and integration purposes

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/rocketchat-api@1.36.x

To install, run

npx @tessl/cli install tessl/pypi-rocketchat-a-p-i@1.36.0

0

# Rocket.Chat API

1

2

A comprehensive Python wrapper for the Rocket.Chat REST API, enabling developers to programmatically interact with Rocket.Chat servers for chat automation, bot development, and integration purposes. It provides complete coverage of the Rocket.Chat API with support for authentication, channel management, messaging, user administration, and server configuration.

3

4

## Package Information

5

6

- **Package Name**: rocketchat_API

7

- **Language**: Python

8

- **Installation**: `pip install rocketchat_API`

9

10

## Core Imports

11

12

```python

13

from rocketchat_API.rocketchat import RocketChat

14

```

15

16

## Basic Usage

17

18

```python

19

from rocketchat_API.rocketchat import RocketChat

20

21

# Username/password authentication

22

rocket = RocketChat('username', 'password', server_url='https://your-server.com')

23

24

# Token authentication (recommended for production)

25

rocket = RocketChat(user_id='user_id', auth_token='auth_token', server_url='https://your-server.com')

26

27

# Get current user info

28

response = rocket.me()

29

print(response.json())

30

31

# List channels

32

channels = rocket.channels_list()

33

print(channels.json())

34

35

# Send a message

36

result = rocket.chat_post_message(

37

text='Hello from Python!',

38

channel='general'

39

)

40

print(result.json())

41

42

# Get channel history

43

history = rocket.channels_history('GENERAL', count=10)

44

print(history.json())

45

```

46

47

## Architecture

48

49

The RocketChat class inherits from 20+ specialized API section classes, each providing methods for specific functionality areas:

50

51

- **Base Class**: `RocketChatBase` provides HTTP methods and authentication

52

- **API Sections**: Specialized classes for different Rocket.Chat features

53

- **Exception Handling**: Custom exceptions for different error scenarios

54

- **Response Format**: All methods return `requests.Response` objects

55

56

## Authentication Options

57

58

```python { .api }

59

class RocketChat:

60

def __init__(

61

self,

62

user=None,

63

password=None,

64

auth_token=None,

65

user_id=None,

66

server_url="http://127.0.0.1:3000",

67

ssl_verify=True,

68

proxies=None,

69

timeout=30,

70

session=None,

71

client_certs=None,

72

): ...

73

```

74

75

## Core Methods

76

77

```python { .api }

78

def login(self, user, password):

79

"""

80

Authenticate with username/email and password.

81

82

Parameters:

83

- user (str): Username or email address

84

- password (str): User password

85

86

Returns:

87

requests.Response: Authentication result with token and user ID

88

"""

89

90

def logout(self, **kwargs):

91

"""

92

Invalidate your REST rocketchat_API authentication token.

93

94

Returns:

95

requests.Response: Logout result

96

"""

97

98

def info(self, **kwargs):

99

"""

100

Information about the Rocket.Chat server.

101

102

Returns:

103

requests.Response: Server information including version and build

104

"""

105

106

def me(self, **kwargs):

107

"""

108

Get current authenticated user information.

109

110

Returns:

111

requests.Response: Current user details

112

"""

113

```

114

115

## Exception Types

116

117

```python { .api }

118

class RocketException(Exception): ...

119

class RocketConnectionException(Exception): ...

120

class RocketAuthenticationException(Exception): ...

121

class RocketMissingParamException(Exception): ...

122

class RocketUnsuportedIntegrationType(Exception): ...

123

```

124

125

## Capabilities

126

127

### Channel Management

128

129

Complete channel lifecycle management including creation, configuration, membership, and administration. Supports public channels with features like moderation, custom fields, and integration management.

130

131

```python { .api }

132

def channels_create(self, name, **kwargs): ...

133

def channels_info(self, room_id=None, channel=None, **kwargs): ...

134

def channels_list(self, **kwargs): ...

135

def channels_invite(self, room_id, user_id, **kwargs): ...

136

def channels_kick(self, room_id, user_id, **kwargs): ...

137

def channels_history(self, room_id, **kwargs): ...

138

```

139

140

[Channel Management](./channels.md)

141

142

### Chat Operations

143

144

Core messaging functionality including sending, editing, deleting, and searching messages. Supports message reactions, threading, pinning, starring, and advanced features like message reports and read receipts.

145

146

```python { .api }

147

def chat_post_message(self, text, room_id=None, channel=None, **kwargs): ...

148

def chat_update(self, room_id, msg_id, text, **kwargs): ...

149

def chat_delete(self, room_id, msg_id, **kwargs): ...

150

def chat_search(self, room_id, search_text, **kwargs): ...

151

def chat_react(self, msg_id, emoji="smile", **kwargs): ...

152

```

153

154

[Chat Operations](./chat.md)

155

156

### Private Group Management

157

158

Private group management with similar functionality to public channels but with enhanced privacy controls. Includes group creation, membership management, and administrative functions.

159

160

```python { .api }

161

def groups_create(self, name, **kwargs): ...

162

def groups_info(self, room_id=None, room_name=None, **kwargs): ...

163

def groups_list(self, **kwargs): ...

164

def groups_invite(self, room_id, user_id, **kwargs): ...

165

def groups_kick(self, room_id, user_id, **kwargs): ...

166

```

167

168

[Private Groups](./groups.md)

169

170

### Direct Messaging

171

172

One-on-one and multi-user direct messaging capabilities. Includes DM creation, message history, file sharing, and conversation management features.

173

174

```python { .api }

175

def im_create(self, username, **kwargs): ...

176

def im_list(self, **kwargs): ...

177

def im_history(self, room_id, **kwargs): ...

178

def im_open(self, room_id, **kwargs): ...

179

def im_close(self, room_id, **kwargs): ...

180

```

181

182

[Direct Messaging](./direct-messages.md)

183

184

### User Management

185

186

Comprehensive user administration including account creation, profile management, authentication, and user preferences. Supports user roles, presence status, and avatar management.

187

188

```python { .api }

189

def users_create(self, email, name, password, username, **kwargs): ...

190

def users_info(self, user_id=None, username=None, **kwargs): ...

191

def users_list(self, **kwargs): ...

192

def users_update(self, user_id, **kwargs): ...

193

def users_delete(self, user_id, **kwargs): ...

194

```

195

196

[User Management](./users.md)

197

198

### Team Management

199

200

Team-based organization features for managing collections of channels and users. Includes team creation, member management, and room assignment within teams.

201

202

```python { .api }

203

def teams_create(self, name, team_type, **kwargs): ...

204

def teams_info(self, team_id=None, team_name=None, **kwargs): ...

205

def teams_members(self, team_id=None, team_name=None, **kwargs): ...

206

def teams_add_rooms(self, team_id=None, team_name=None, rooms=None, **kwargs): ...

207

```

208

209

[Team Management](./teams.md)

210

211

### LiveChat

212

213

Customer support and live chat functionality for external visitor engagement. Includes visitor management, inquiry handling, agent assignment, and message routing.

214

215

```python { .api }

216

def livechat_register_visitor(self, token, **kwargs): ...

217

def livechat_room(self, token, **kwargs): ...

218

def livechat_message(self, token, rid, msg, **kwargs): ...

219

def livechat_inquiries_take(self, inquiry_id, **kwargs): ...

220

```

221

222

[LiveChat](./livechat.md)

223

224

### Administration

225

226

Server administration and configuration management including settings, permissions, roles, statistics, and integration management. Requires appropriate administrative permissions.

227

228

```python { .api }

229

def settings_get(self, _id, **kwargs): ...

230

def permissions_list_all(self, **kwargs): ...

231

def roles_create(self, name, **kwargs): ...

232

def statistics(self, **kwargs): ...

233

```

234

235

[Administration](./administration.md)

236

237

### Integrations

238

239

Webhook and integration management for connecting Rocket.Chat with external systems. Supports incoming and outgoing webhooks with script execution capabilities.

240

241

```python { .api }

242

def integrations_create(self, integrations_type, name, enabled, username, channel, script_enabled, **kwargs): ...

243

def integrations_get(self, integration_id, **kwargs): ...

244

def integrations_list(self, **kwargs): ...

245

def integrations_update(self, integrations_type, name, enabled, username, channel, script_enabled, integration_id, **kwargs): ...

246

```

247

248

[Integrations](./integrations.md)

249

250

### Roles

251

252

Role management system for server administration. Create, assign, and manage user roles with optional room-specific scope.

253

254

```python { .api }

255

def roles_list(self, **kwargs): ...

256

def roles_create(self, name, **kwargs): ...

257

def roles_add_user_to_role(self, role_name, username, **kwargs): ...

258

def roles_remove_user_from_role(self, role_name, username, **kwargs): ...

259

```

260

261

[Roles](./roles.md)

262

263

### Advanced Room Operations

264

265

Extended room functionality including file uploads, history management, favorites, and administrative functions that work across all room types.

266

267

```python { .api }

268

def rooms_get(self, **kwargs): ...

269

def rooms_upload(self, rid, file, **kwargs): ...

270

def rooms_clean_history(self, room_id, latest, oldest, **kwargs): ...

271

def rooms_favorite(self, room_id=None, room_name=None, favorite=True): ...

272

```

273

274

[Advanced Room Operations](./rooms.md)

275

276

### Server Settings

277

278

Server configuration and settings management including system settings, OAuth configurations, and service configurations.

279

280

```python { .api }

281

def settings_get(self, _id, **kwargs): ...

282

def settings_update(self, _id, value, **kwargs): ...

283

def settings_oauth(self, **kwargs): ...

284

def settings_addcustomoauth(self, name, **kwargs): ...

285

```

286

287

[Server Settings](./settings.md)

288

289

### Permissions

290

291

Server permission management for controlling user capabilities and access rights within Rocket.Chat.

292

293

```python { .api }

294

def permissions_list_all(self, **kwargs): ...

295

def permissions_update(self, permissions, **kwargs): ...

296

```

297

298

[Permissions](./permissions.md)

299

300

### Statistics

301

302

Server statistics and metrics for monitoring usage, performance, and system information.

303

304

```python { .api }

305

def statistics(self, **kwargs): ...

306

def statistics_list(self, **kwargs): ...

307

```

308

309

[Statistics](./statistics.md)

310

311

### Subscriptions

312

313

User subscription management for tracking relationships with rooms, including read status and notifications.

314

315

```python { .api }

316

def subscriptions_get(self, **kwargs): ...

317

def subscriptions_get_one(self, room_id, **kwargs): ...

318

def subscriptions_read(self, rid, **kwargs): ...

319

def subscriptions_unread(self, room_id, **kwargs): ...

320

```

321

322

[Subscriptions](./subscriptions.md)

323

324

### Assets

325

326

Server asset management for uploading and managing custom assets like logos, favicons, and branding elements.

327

328

```python { .api }

329

def assets_set_asset(self, asset_name, file, **kwargs): ...

330

def assets_unset_asset(self, asset_name, **kwargs): ...

331

```

332

333

[Assets](./assets.md)

334

335

### Miscellaneous

336

337

Additional utility functions for directory search and spotlight functionality.

338

339

```python { .api }

340

def directory(self, query, **kwargs): ...

341

def spotlight(self, query, **kwargs): ...

342

```

343

344

[Miscellaneous](./miscellaneous.md)