Skip to main content

Headless bootstrap tooling for Matomo (installation + API token provisioning)

Project description

matomo-bootstrap

GitHub Sponsors Patreon Buy Me a Coffee PayPal

Headless bootstrap tooling for Matomo Automates installation (via recorded Playwright flow) and API token provisioning for fresh Matomo instances.

This tool is designed for CI, containers, and reproducible environments, where no interactive browser access is available.


Features

  • 🚀 Fully headless Matomo installation

    • Drives the official Matomo web installer using Playwright
    • Automatically skips installation if Matomo is already installed
  • 🔐 API token provisioning

    • Creates an app-specific token via authenticated Matomo session
    • Compatible with Matomo 5.3.x Docker images
  • 🧪 E2E-tested

    • Docker-based end-to-end tests included
  • ❄️ First-class Nix support

    • Flake-based packaging
    • Reproducible CLI and dev environments
  • 🐍 Standard Python CLI

    • Installable via pip
    • Clean stdout (token only), logs on stderr

Requirements

  • A running Matomo instance (e.g. Docker)

  • For fresh installs:

    • Chromium (managed automatically by Playwright)

Installation

Using Nix (recommended)

If you use Nix with flakes:

nix run github:kevinveenbirkenbach/matomo-bootstrap

Install Playwright’s Chromium browser (one-time):

nix run github:kevinveenbirkenbach/matomo-bootstrap#matomo-bootstrap-playwright-install

This installs Chromium into the user cache used by Playwright.


Using Python / pip

Requires Python ≥ 3.10

pip install matomo-bootstrap

Install Chromium for Playwright:

python -m playwright install chromium

Usage

CLI

matomo-bootstrap \
  --base-url http://127.0.0.1:8080 \
  --admin-user administrator \
  --admin-password AdminSecret123! \
  --admin-email administrator@example.org

On success, the command prints only the API token to stdout:

6c7a8c2b0e9e4a3c8e1d0c4e8a6b9f21

Environment Variables

All options can be provided via environment variables:

export MATOMO_URL=http://127.0.0.1:8080
export MATOMO_ADMIN_USER=administrator
export MATOMO_ADMIN_PASSWORD=AdminSecret123!
export MATOMO_ADMIN_EMAIL=administrator@example.org
export MATOMO_TOKEN_DESCRIPTION=my-ci-token

matomo-bootstrap

Debug Mode

Enable verbose logs (stderr only):

matomo-bootstrap --debug

How It Works

  1. Reachability check

    • Waits until Matomo responds over HTTP (any status)
  2. Installation (if needed)

    • Uses a recorded Playwright flow to complete the Matomo web installer
  3. Authentication

    • Logs in using the Login.logme controller
  4. Token creation

    • Calls UsersManager.createAppSpecificTokenAuth
  5. Output

    • Prints the token to stdout (safe for scripting)

End-to-End Tests

Run the full E2E cycle locally:

make e2e

This will:

  1. Start Matomo + MariaDB via Docker
  2. Install Matomo headlessly
  3. Create an API token
  4. Validate the token via Matomo API
  5. Tear everything down again

Project Status

  • ✔ Stable for CI / automation
  • ✔ Tested against Matomo 5.3.x Docker images
  • ⚠ Installer flow is UI-recorded (robust, but may need updates for future Matomo UI changes)

Author

Kevin Veen-Birkenbach 🌐 https://www.veen.world/


License

MIT License See LICENSE

Project details


Download files

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

Source Distribution

matomo_bootstrap-1.0.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

matomo_bootstrap-1.0.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: matomo_bootstrap-1.0.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for matomo_bootstrap-1.0.1.tar.gz
Algorithm Hash digest
SHA256 158f0b488b91e55dda35216e3eed279d8cf8af3faa2fe90dd58d041e10946b4f
MD5 efc121f63eb5a2c29329a44207b6beaf
BLAKE2b-256 ebb8693b6bc866a4cb569938714a1cfccdbcba60507472cf545c9d09e3b720fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for matomo_bootstrap-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82039ffef90bcc8533e1528cbe3cccb8c5be2075f57c5d367b25143442dede82
MD5 330af63a34bfa8eb5b79c6884be986ac
BLAKE2b-256 126592eebad8f2c0a1fb763dbd74838d8eb18e15e0b951ee9c224e554c71fe74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page