Skip to main content
A simple, developer-friendly library to create powerful Matrix bots.
matrix.py

Join Discord Join Matrix Tests PyPI CodeQL Advanced OpenSSF Scorecard


Matrix.py is a lightweight and intuitive Python library to build bots on the Matrix protocol. It provides a clean, decorator-based API similar to popular event-driven frameworks, allowing developers to focus on behavior rather than boilerplate.

  • Minimal setup — install and have a working bot running in minutes
  • Event-driven — async/await API reacting to any Matrix room event
  • Command system — decorator-based commands with automatic argument parsing
  • Extensions — split your bot into modules as it grows

Quickstart

Requirements: Python 3.10+

pip install matrix-python

Using a virtual environment is strongly recommended:

python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install matrix-python

Create a config.yml:

USERNAME: "@yourbot:matrix.org"
PASSWORD: "your_password"
from matrix import Bot, Context

bot = Bot()


@bot.command("ping")
async def ping(ctx: Context):
    await ctx.reply("Pong!")


bot.start(config="config.yml")

Send !ping in any room the bot is in, it will reply Pong!.

Where to go next

  • Guides — step-by-step tutorials covering commands, events, checks, extensions, and more
  • Reference — complete API documentation for every class and function
  • Examples — ready-to-run example bots demonstrating common patterns

Contributing

We welcome everyone to contribute! Whether it's fixing bugs, suggesting features, or improving the docs. Every bit helps.

Please read the CONTRIBUTING.md and follow the code of conduct.

License

Released under the MIT License.

Download files

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

Source Distribution

matrix_python-1.0.1.tar.gz (96.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrix_python-1.0.1-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file matrix_python-1.0.1.tar.gz.

File metadata

  • Download URL: matrix_python-1.0.1.tar.gz
  • Upload date:
  • Size: 96.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrix_python-1.0.1.tar.gz
Algorithm Hash digest
SHA256 00e4ce904f60735a4c91ca734d60c4e2193d73ef50bbe4ca3b27f94e7fcbf08b
MD5 688b8aecfe2a89bae21b9b08ce2bcde6
BLAKE2b-256 2a73f7b5554f06228e1750374969ad13d66d7b4d986174f2d3667d4e02a9bfd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrix_python-1.0.1.tar.gz:

Publisher: publish.yml on Code-Society-Lab/matrixpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matrix_python-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: matrix_python-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrix_python-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1518684ab04bae416f91e46a527847a90583bfb9486008cdb83977790a44053
MD5 1ee3080733cf807a55783fe21403fadc
BLAKE2b-256 b2a705a0a077a13a90703c30bfcddd668f0929500830f186685551ae83a8c3d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrix_python-1.0.1-py3-none-any.whl:

Publisher: publish.yml on Code-Society-Lab/matrixpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
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