Skip to main content

Matrix Client SDK for Python

Latest Version Travis-CI Results coveralls.io Results Matrix chatroom Documentation

Matrix client-server SDK for Python 2.7 and 3.4+

Project Status

We strongly recommend using the matrix-nio library rather than this sdk. It is both more featureful and more actively maintained.

This sdk is currently lightly maintained without any person ultimately responsible for the project. Pull-requests may be reviewed, but no new-features or bug-fixes are being actively developed. For more info or to volunteer to help, please see https://github.com/matrix-org/matrix-python-sdk/issues/279 or come chat in #matrix-python-sdk:matrix.org.

Installation

Stable release

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

pip install matrix_client

Development version

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

git clone https://github.com/matrix-org/matrix-python-sdk.git
cd matrix-python-sdk
python setup.py install

Usage

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.

Client:

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(username="foobar", password="monkey")

room = client.create_room("my_room_alias")
room.send_text("Hello!")

API:

from matrix_client.api import MatrixHttpApi

matrix = MatrixHttpApi("https://matrix.org", token="some_token")
response = matrix.send_message("!roomid:matrix.org", "Hello!")

Structure

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

API

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.

Client

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

Samples

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/samplename.py

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.

Release files for matrix-client 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matrix-client 0.4.0
File Size Uploaded
matrix_client-0.4.0.tar.gz 49.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matrix-client 0.4.0
File Interpreter ABI Platform
matrix_client-0.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 92.5 kB

Release files / matrix_client-0.4.0.tar.gz

Download URL matrix_client-0.4.0.tar.gz
Size 49.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0678af40f2cb2f0928a908a410c029747d40cb961ac5a3f1bd05aa35563c3156
BLAKE2b-256 checksum
How to use checksums
939a23c4894da5aeb316903677c71014575c486616026b85e2d0b408f84d8540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release files / matrix_client-0.4.0-py2.py3-none-any.whl

Download URL matrix_client-0.4.0-py2.py3-none-any.whl
Size 43.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
20cb42fb644879858c3fdd348d1c349c33676f11d1597f820abfd0fc0e009cb1
BLAKE2b-256 checksum
How to use checksums
6100f10d4b5d72c5afb9b703ea0cabbea1670cd20159afe1764f4322d00dec99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

1 release file

0.0.6

1 release file

0.0.5

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page