An open API service indexing awesome lists of open source software.

https://github.com/code-society-lab/matrixpy

A simple, developer-friendly library to create Matrix bots.
https://github.com/code-society-lab/matrixpy

bot matrix matrix-bot matrix-org python

Last synced: 6 days ago
JSON representation

A simple, developer-friendly library to create Matrix bots.

Awesome Lists containing this project

README

          


A simple, developer-friendly library to create powerful Matrix bots.


matrix.py

[](https://matrixpy.codesociety.xyz/guides/introduction/)
[](https://matrixpy.codesociety.xyz/reference/bot/)

[![Join Discord](https://discordapp.com/api/guilds/823178343943897088/widget.png?style=shield)](https://discord.gg/code-society-823178343943897088)
[![Join Matrix](https://img.shields.io/matrix/codesociety%3Amatrix.org?logo=matrix&label=%20&labelColor=%23202020&color=%23202020)](https://matrix.to/#/%23codesociety:matrix.org)
[![Tests](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/tests.yml/badge.svg)](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/matrix-python)](https://pypi.org/project/matrix-python/)
[![CodeQL Advanced](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/codeql.yml/badge.svg)](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/codeql.yml)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/Code-Society-Lab/matrixpy/badge)](https://securityscorecards.dev/viewer/?uri=github.com/Code-Society-Lab/matrixpy)

---

Matrix.py is a lightweight and intuitive Python library to build bots on the [Matrix protocol](https://matrix.org). 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+

```bash
pip install matrix-python
```

Using a virtual environment is strongly recommended:

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

Create a `config.yml`:

```yaml
USERNAME: "@yourbot:matrix.org"
PASSWORD: "your_password"
```

```python
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**](https://matrixpy.codesociety.xyz/guides/introduction/) — step-by-step tutorials covering commands,
events, checks, extensions, and more
- [**Reference**](https://matrixpy.codesociety.xyz/reference/bot/) — complete API documentation for every class and
function
- [**Examples**](https://matrixpy.codesociety.xyz/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.

- [Submit an issue](https://github.com/Code-Society-Lab/matrixpy/issues)
- [Open a pull request](https://github.com/Code-Society-Lab/matrixpy/blob/main/CONTRIBUTING.md)
- Hop into our [Matrix](https://matrix.to/#/%23codesociety:matrix.org)
or [Discord](https://discord.gg/code-society-823178343943897088) and say hi!

Please read the [CONTRIBUTING.md](./CONTRIBUTING.md) and follow the [code of conduct](./CODE_OF_CONDUCT.md).

## License

Released under the [MIT License](https://github.com/Code-Society-Lab/matrixpy/blob/main/LICENSE).