Skip to main content

Client-Server SDK for Matrix

Project description

Matrix Client SDK for Python
============================

.. image:: https://img.shields.io/pypi/v/matrix-client.svg?maxAge=600
:target: https://pypi.python.org/pypi/matrix-client
:alt: Latest Version
.. image:: https://travis-ci.org/matrix-org/matrix-python-sdk.svg?branch=master
:target: https://travis-ci.org/matrix-org/matrix-python-sdk
:alt: Travis-CI Results
.. image:: https://coveralls.io/repos/github/matrix-org/matrix-python-sdk/badge.svg?branch=master
:target: https://coveralls.io/github/matrix-org/matrix-python-sdk?branch=master
:alt: coveralls.io 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 `#matrix-python-sdk:matrix.org`_.

Documentation can be found at http://matrix-org.github.io/matrix-python-sdk/

.. _`#matrix-python-sdk:matrix.org`: https://matrix.to/#/%23matrix-python-sdk:matrix.org



Installation
=====
Stable release
-----
Install with pip from pypi. This will install all necessary dependencies as well.

.. code:: shell

pip install matrix_client

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

.. code:: shell

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:

.. code:: python

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")
room.send_text("Hello!")


API:

.. code:: python

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:

.. code:: shell

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrix_client-0.3.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

matrix_client-0.3.0-py2.py3-none-any.whl (28.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file matrix_client-0.3.0.tar.gz.

File metadata

File hashes

Hashes for matrix_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 49eeb85d901ce9191bd379fdc8f5b7dcaa64fff7e0d086a56bcd363f12b0c296
MD5 645ea91f6e48089b748a2abe347296af
BLAKE2b-256 879503d1432c24ad8221a3df83f6aeb6d7bfc7d6d3075ff8877139ae7f756e68

See more details on using hashes here.

File details

Details for the file matrix_client-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for matrix_client-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bcb024107483460985864993c87ebf2c5f016827eb4f78cde21ec4e8a395a2e5
MD5 96da79ffa4b21c1c776a8c4eb1cafed1
BLAKE2b-256 edf652a353b6df5f5e60718a072abe3e18115c04f500a1717f6653eefcb3f251

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page