Skip to main content

nio

Build Status codecov license Documentation Status #nio

nio is a multilayered matrix client library. The underlying base layer doesn't do any IO on its own. On top of the base layer, a no-IO HTTP client implementation exists, as well as a full fledged batteries included asyncio layer using aiohttp.

Documentation

The full API documentation for nio can be found at https://matrix-nio.readthedocs.io

Installation

To install nio, simply use pip:

$ pip install matrix-nio

Note that this installs nio without end-to-end encryption support. For e2ee support, python-olm is needed which requires the libolm C library (version 3.x).

After libolm has been installed, the e2ee enabled version of nio can be installed using pip:

$ pip install "matrix-nio[e2e]"

Usage

Unless special requirements disallow the usage of asyncio, by far the easiest way to use nio is using the asyncio layer.

Please do note that these examples require python 3.5+ for the async/await syntax. nio on the other hand works with older python versions as well.

Sending a message

import asyncio
from nio import AsyncClient

async def main():
    client = AsyncClient("https://example.org", "@alice:example.org")

    await client.login("hunter1")
    await client.room_send(
        room_id="!test:example.org",
        message_type="m.room.message",
        content={
            "msgtype": "m.text",
            "body": "Hello World"
        }
    )
    await client.close()

asyncio.get_event_loop().run_until_complete(main())

Receiving messages

import asyncio
from nio import (AsyncClient, RoomMessageText)

async def message_cb(room, event):
    print(
        "Message received for room {} | {}: {}".format(
            room.display_name, room.user_name(event.sender), event.body
        )
    )

async def main():
    client = AsyncClient("https://example.org", "@alice:example.org")
    client.add_event_callback(message_cb, RoomMessageText)

    await client.login("hunter1")
    await client.sync_forever(timeout=30000)

asyncio.get_event_loop().run_until_complete(main())

Metadata

Release files for matrix-nio 0.7

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-nio 0.7
File Size Uploaded
matrix-nio-0.7.tar.gz 120.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matrix-nio 0.7
File Interpreter ABI Platform
matrix_nio-0.7-py3-none-any.whl Python 3 none any Details

Total release size: 265.5 kB

Release files / matrix-nio-0.7.tar.gz

Download URL matrix-nio-0.7.tar.gz
Size 120.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7fa9188b7e10aadc1598d22ea9d98e937b389dc44479026108f0a111684ea87f
BLAKE2b-256 checksum
How to use checksums
be3f8296fb28bead6fb96b6298ccca26246423bcda3d030fe4d4a4b25be442bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/43.0.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.1

Release files / matrix_nio-0.7-py3-none-any.whl

Download URL matrix_nio-0.7-py3-none-any.whl
Size 144.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2f9adf6ceda9923a9852b89b31d2e07744a0a3bdd86834d5de1f490d18c162c
BLAKE2b-256 checksum
How to use checksums
05e645a227a917ae6d3d09119465d1477a216dff2c64c7a9038d4a1137247854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/43.0.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.1

Release history Release notifications | RSS feed

0.26.0

2 release files

0.25.0

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.21.2

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.2

2 release files

0.20.0

2 release files

0.18.7

2 release files

0.18.6

2 release files

0.18.5

2 release files

0.18.4

2 release files

0.18.3

2 release files

0.16.0

2 release files

0.15.2

2 release files

0.15.1

2 release files

0.15.0

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.12.0

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

This release

0.7 This release

2 release files

0.6

1 release file

0.5

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

2 release files

0.2

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