• Stars
    star
    256
  • Rank 158,787 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python API wrapper for Rocket.Chat

rocketchat_API

Python API wrapper for Rocket.Chat

Codacy Badge Test and publish codecov PyPI

Installation

  • From pypi: pip3 install rocketchat_API
  • From GitHub: Clone our repository and python3 setup.py install

Requirements

Usage

from pprint import pprint
from rocketchat_API.rocketchat import RocketChat

proxy_dict = {
    "http"  : "http://127.0.0.1:3128",
    "https" : "https://127.0.0.1:3128",
}

rocket = RocketChat('user', 'pass', server_url='https://demo.rocket.chat', proxies=proxy_dict)
pprint(rocket.me().json())
pprint(rocket.channels_list().json())
pprint(rocket.chat_post_message('good news everyone!', channel='GENERAL', alias='Farnsworth').json())
pprint(rocket.channels_history('GENERAL', count=5).json())

note: every method returns a requests Response object.

Connection pooling

If you are going to make a couple of request, you can user connection pooling provided by requests. This will save significant time by avoiding re-negotiation of TLS (SSL) with the chat server on each call.

from requests import sessions
from pprint import pprint
from rocketchat_API.rocketchat import RocketChat

with sessions.Session() as session:
    rocket = RocketChat('user', 'pass', server_url='https://demo.rocket.chat', session=session)
    pprint(rocket.me().json())
    pprint(rocket.channels_list().json())
    pprint(rocket.chat_post_message('good news everyone!', channel='GENERAL', alias='Farnsworth').json())
    pprint(rocket.channels_history('GENERAL', count=5).json())

Using a token for authentication instead of user and password

from pprint import pprint
from rocketchat_API.rocketchat import RocketChat

rocket = RocketChat(user_id='WPXGmQ64S3BXdCRb6', auth_token='jvNyOYw2f0YKwtiFS06Fk21HBRBBuV7zI43HmkNzI_s', server_url='https://demo.rocket.chat')
pprint(rocket.me().json())

Method parameters

Only required parameters are explicit on the RocketChat class but you can still use all other parameters. For a detailed parameters list check the Rocket chat API

API coverage

Most of the API methods are already implemented. If you are interested in a specific call just open an issue or open a pull request.

Tests

We are actively testing :)

Tests run on a Rocket.Chat Docker container so install Docker and docker-compose.

  1. To start test server do docker-compose up and to take test server down docker-compose down
  2. To run the tests run pytest

Contributing

You can contribute by doing Pull Requests. (It may take a while to merge your code but if it's good it will be merged). Please, try to implement tests for all your code and use a PEP8 compliant code style.

Reporting bugs and asking for features is also contributing ;) Feel free to help us grow by registering issues.

We hang out here if you want to talk.

Supporters

JetBrains JetBrains supports this project by providing us with licenses for their fantastic products.

More Repositories

1

shadowmere

A website to list Shadowsocks proxies and check them periodically
Python
81
star
2

outline-vpn-api

A Python API wrapper for Outline VPN https://getoutline.org/
Python
79
star
3

DockerImageSave

Saves docker images in a remote host and allows you to download them to circumvent Docker censorship in Cuba
Go
60
star
4

RocketChatBot

REST API based bot for [Rocket.Chat](http://rocket.chat)
Python
20
star
5

vpn2go

Easy setup and API management for OpenVPN server
Python
17
star
6

APKStore

A server using Python + Django + CherryPy to share your Android applications over the network
Python
12
star
7

porkbun-ddns

Keep your Porkbun DNS records updated with your current IP address
Go
11
star
8

TextMadeWeb

Search the web on text mode
Python
11
star
9

ShadowTest

A service to test shadowsocks keys
Go
8
star
10

ShakeItOff

Turn off your Android phone's screen by shaking the device
Java
7
star
11

Shield

iptables based firewall for blocking access to certain urls
Java
6
star
12

UCIntlm

NTLM proxy for android (no root required)
Java
6
star
13

IoTInternetMonitior

An internet connection monitor for ESP8866
Python
5
star
14

jwt-decode

Simple application to decode JWT
Go
5
star
15

outline-ss-server-configuration

A docker-compose deployment for the outline shadowsocks server
Dockerfile
5
star
16

rocketchat-notification-action

Dockerfile
4
star
17

outlinevpn-vultr-terraform

Terraform script to quickly install outline in a vultr server
HCL
2
star
18

CTerminator

Activa el modo Compliance Test en equipos de Ubiquiti
Go
2
star
19

shellhook

Run scripts remotely with a simple HTTP call
Go
2
star
20

caronte

a shadowsocks router
2
star
21

subsbot

Telegram bot for https://www.tusubtitulo.com/
Python
2
star
22

tor-snowflake-snap

a simple snap configuration to install a tor snowflake proxy
2
star
23

helm-klum

A helm chart for installing Kubernetes Lazy User Manager
Makefile
2
star
24

OfflineSandbox

Python
2
star
25

home-k3s-cluster

Experimetal cluster on proxmox + k3s
HCL
2
star
26

clipu

Yet another clipboard sharing application
Go
2
star
27

WearWhip

A punny whip application for your WearOS device
Kotlin
2
star
28

videobot

A telegram bot to download videos from youtube
Python
1
star
29

NotiWeb

RSS Agregator for SNET
Python
1
star
30

v2ray-ws-config

A simple v2ray setup using websockets with Caddy
1
star
31

GoLife

A (not so good) implementation of the Game of Life in GO
Go
1
star
32

annoying_orange_bot

A python rocket chat bot to set reminders
Python
1
star
33

AntiFolderProtector

Simple application to break the security of some FolderProtector versions
Pascal
1
star
34

SMBLanDiscover

Discover SAMBA clients on your Local Area Network
Java
1
star
35

BayesESports

Bayes eSports coding exercise
Python
1
star
36

MiniSMSAPI

Simple API to send SMS using twilio account.
Python
1
star