Async Python client for the Mattermost REST API and WebSocket events.
Project description
MatterAio
Async Python client for the Mattermost REST API and WebSocket events.
MatterAio is intentionally small and explicit:
- async-only
- thin wrapper over Mattermost API v4
- no hidden multi-step workflows
- typed responses with Pydantic models
Installation
With pip:
pip install matteraio
With Poetry:
poetry add matteraio
With uv:
uv add matteraio
Quick Start
Create a bot token in Mattermost and pass it to MattermostClient.
import asyncio
from matteraio import MattermostClient
async def main() -> None:
async with MattermostClient(
base_url="https://mattermost.example.com",
token="YOUR_BOT_TOKEN",
) as client:
bot = await client.init_session()
print(bot.username)
team = await client.teams.get_by_name("engineering")
channel = await client.channels.get_by_name(team.id, "town-square")
post = await client.posts.create(
channel_id=channel.id,
message="Hello from matteraio",
)
thread = await client.posts.thread(post.id)
users = await client.users.search("alice", team_id=team.id, limit=10)
print(post.id, len(thread.posts), [user.username for user in users])
asyncio.run(main())
If you need login/password authentication instead of a bot token, construct the client without
token and call client.users.login(...). Token changes inside one client instance are not
supported; create a new client when credentials change.
Pagination Helpers
Paginated list endpoints can be consumed page by page with the regular list(...) methods, or
as async iterators when you want all items until Mattermost returns a short or empty page.
async for channel in client.channels.iter_all(team.id, per_page=100):
print(channel.name)
async for post in client.posts.iter_channel(channel.id, per_page=100):
print(post.message)
WebSocket Handlers
Use routers and decorators to handle incoming WebSocket events.
from matteraio import MattermostEventDispatcher, MattermostWebSocketClient, PostedEvent
dispatcher = MattermostEventDispatcher()
@dispatcher.on(PostedEvent)
async def on_posted(event: PostedEvent) -> None:
print(event.data.post.message)
async def main() -> None:
async with MattermostWebSocketClient(
base_url="https://mattermost.example.com",
token="YOUR_BOT_TOKEN",
) as websocket:
await dispatcher.start(websocket)
Documentation
- Endpoint reference: REST docs split by Mattermost API area, plus WebSocket and handler references.
Development
Install development dependencies:
uv sync --all-groups
Run local checks:
uv run ruff format .
uv run ruff check .
uv run mypy src tests
uv run pytest
Run opt-in integration tests against a local Mattermost preview server:
docker compose -f docker-compose.integration.yml up -d
MATTERAIO_RUN_INTEGRATION=1 uv run pytest tests/integration -m integration
docker compose -f docker-compose.integration.yml down -v
Set MATTERAIO_BASE_URL to override the default integration server URL.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matteraio-1.0.2.tar.gz.
File metadata
- Download URL: matteraio-1.0.2.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60c4210fcd46a72e243e28d2c0511f657b30df5e64d856563efbd6fadb6d452c
|
|
| MD5 |
f6908c9768abaa94ce57202e618a809e
|
|
| BLAKE2b-256 |
5e5ba5a74a128a3a72c0b8b23410692a80743f3f12339368d73c52e72a1744ac
|
Provenance
The following attestation bundles were made for matteraio-1.0.2.tar.gz:
Publisher:
publish.yml on Sergeydmitr/MatterAio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matteraio-1.0.2.tar.gz -
Subject digest:
60c4210fcd46a72e243e28d2c0511f657b30df5e64d856563efbd6fadb6d452c - Sigstore transparency entry: 1438717577
- Sigstore integration time:
-
Permalink:
Sergeydmitr/MatterAio@0accb09b871fdd08bdc7d148cd977544fb635cfb -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Sergeydmitr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0accb09b871fdd08bdc7d148cd977544fb635cfb -
Trigger Event:
release
-
Statement type:
File details
Details for the file matteraio-1.0.2-py3-none-any.whl.
File metadata
- Download URL: matteraio-1.0.2-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed26901bbffad6fcf6ba2b03c10585eef4c1ba540274de82ff7bd4e7fd1425a5
|
|
| MD5 |
a827a894ec454ea8bc9c108b28b48581
|
|
| BLAKE2b-256 |
236c96e60e24bda560b1dd6c66e8832fe3686aaf35a86aa08c78f351c1b5270d
|
Provenance
The following attestation bundles were made for matteraio-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on Sergeydmitr/MatterAio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matteraio-1.0.2-py3-none-any.whl -
Subject digest:
ed26901bbffad6fcf6ba2b03c10585eef4c1ba540274de82ff7bd4e7fd1425a5 - Sigstore transparency entry: 1438717585
- Sigstore integration time:
-
Permalink:
Sergeydmitr/MatterAio@0accb09b871fdd08bdc7d148cd977544fb635cfb -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Sergeydmitr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0accb09b871fdd08bdc7d148cd977544fb635cfb -
Trigger Event:
release
-
Statement type: