Matrix Client-Server SDK for Python 2 and 3
Clone or download
non-Jedi Merge pull request #251 from Zil0/fix_mkroom
fix bug when detecting encryption in _mkroom
Latest commit 50676ef Jul 14, 2018


Matrix Client SDK for Python

Latest Version Travis-CI Results Results

This is a Matrix client-server SDK for Python 2.7 and 3.4+

Community discussion on usage of this SDK and development of this SDK can be found at

Documentation can be found at


Stable release

Install with pip from pypi. This will install all necessary dependencies as well.

pip install matrix_client

Development version

Install using in root project directory. This will also install all needed dependencies.

git clone
cd matrix-python-sdk
python install

E2E development

The Olm bindings are not yet hosted on PyPI. Hence it it necessary to pass --process-dependency-links when installing with pip, in order to fetch them from their Git repository. For example replace python install in the above instructions by pip install --process-dependency-links .[e2e].


The SDK provides 2 layers of interaction. The low-level layer just wraps the raw HTTP API calls. The high-level layer wraps the low-level layer and provides an object model to perform actions on.


from matrix_client.client import MatrixClient

client = MatrixClient("http://localhost:8008")

# New user
token = client.register_with_password(username="foobar", password="monkey")

# Existing user
token = client.login_with_password(username="foobar", password="monkey")

room = client.create_room("my_room_alias")


from matrix_client.api import MatrixHttpApi

matrix = MatrixHttpApi("", token="some_token")
response = matrix.send_message("!", "Hello!")


The SDK is split into two modules: api and client.


This contains the raw HTTP API calls and has minimal business logic. You can set the access token (token) to use for requests as well as set a custom transaction ID (txn_id) which will be incremented for each request.


This encapsulates the API module and provides object models such as Room.


A collection of samples are included, written in Python 3.

You can either install the SDK, or run the sample like this:

PYTHONPATH=. python samples/

Building the Documentation

The documentation can be built by installing sphinx and sphinx_rtd_theme.

Simple run make inside docs which will list the avaliable output formats.