Skip to content

Repository files navigation

rocketchat_API

Python Asynchronous API wrapper for Rocket.Chat

Codacy BadgeTest and publishcodecovPyPI

Installation

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

Requirements

Usage

importasynciofromrocketchat_API.rocketchatimportRocketChatasyncdefmain():
rocket=RocketChat('user', 'pass', server_url='server_url')
ifrocket.login_task:
awaitrocket.login_taskprint('Login successful!')
# Use the methods to testresponse=awaitrocket.chat_post_message('test message using asynchronous library!', room_id='room_id')
print(response.json())
asyncio.run(main())

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.

importasyncioimporthttpxfromrocketchat_API.rocketchatimportRocketChatasyncdefmain():
asyncwithhttpx.AsyncClient() asclient:
rocket=RocketChat('user', 'pass', server_url='server_url', client=client)
ifrocket.login_task:
awaitrocket.login_taskprint(rocket.channels_list().json())
print(rocket.channels_history('GENERAL', count=5).json())
asyncio.run(main())

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.

About

Asynchronous implementation of rocketchat_API

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages