No description
Find a file
2026-05-26 12:36:32 +02:00
mattermost-python-extractor.py adding multiple output format 2026-04-13 14:31:44 +02:00
pyproject.toml updating ruff config 2026-03-23 15:39:17 +01:00
README.md updating readme 2026-05-26 12:36:32 +02:00
requirements.txt first commit 2026-03-23 15:34:38 +01:00

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:

  1. Log in to your Mattermost instance in a web browser.
  2. Go to Account SettingsSecurityPersonal Access Tokens.
  3. Click Create Token, give it a name, and set an expiration date.
  4. 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.