No description
- Python 100%
| mattermost-python-extractor.py | ||
| pyproject.toml | ||
| README.md | ||
| requirements.txt | ||
Mattermost Python Extractor
Extract messages from Mattermost teams and channels to JSONL, CSV, or Markdown.
Requirements
mattermostdriver
Install with:
pip install -r requirements.txt
Getting an Authentication Token
The --token argument requires a Mattermost API personal access token. To create one:
- Log in to your Mattermost instance in a web browser.
- Go to Account Settings → Security → Personal Access Tokens.
- Click Create Token, give it a name, and set an expiration date.
- Click Create and copy the token immediately — it won't be shown again.
Alternatively, use the Mattermost API directly:
curl -X POST https://<your-mattermost-url>/api/v4/users/login \
-H "Content-Type: application/json" \
-d '{"login_id":"<your-email>","password":"<your-password>"}'
The response contains an Token header with your session token.
Another way to get your token is to get the value of MMAUTHTOKEN in your web browser cookies.
Usage
python mattermost-python-extractor.py \
--url <mattermost-url> \
--port <port> \
--token <auth-token> \
--team-name <team-name> \
[--channel-name <channel>] \
[--output-format jsonl|csv|md] \
[--with-file]
Arguments
| Argument | Required | Description |
|---|---|---|
--url |
Yes | Mattermost server URL |
port |
Yes | Server port |
--token |
Yes | Authentication token |
--team-name |
Yes | Team name |
--channel-name |
No | Specific channel (omit to extract all public channels) |
--output-format |
No | Output format: jsonl (default), csv, or md |
--with-file |
No | Download attached files (default: only record filenames) |
Examples
Extract all channels from a team as JSONL:
python mattermost-python-extractor.py \
--url mattermost.example.com \
--port 8065 \
--token mytoken \
--team-name myteam
Extract a single channel as Markdown:
python mattermost-python-extractor.py \
--url mattermost.example.com \
--port 8065 \
--token mytoken \
--team-name myteam \
--channel-name general \
--output-format md
Extract with file downloads:
python mattermost-python-extractor.py \
--url mattermost.example.com \
--port 8065 \
--token mytoken \
--team-name myteam \
--channel-name dev \
--output-format csv \
--with-file
Output
- JSONL: One JSON object per line, one file per channel (
{team}.{channel}.jsonl) - CSV: Header row + data rows (
{team}.{channel}.csv) - Markdown: Formatted document with participants list and timestamped messages (
{team}.{channel}.md)
Each record contains: id, mattermost_id, user_id, username, user, user_email, channel, message, files, timestamp, timestamp_unix_milli, type.