Wakapi
📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
Install / Use
/learn @muety/WakapiREADME
[!IMPORTANT] Due to limited time available on the maintainers' part, we temporarily do not accept pull requests. Please refrain from submitting contributions for the time being.
🚀 Features
- ✅ Free and open-source
- ✅ Built by developers for developers
- ✅ Statistics for projects, languages, editors, hosts and operating systems
- ✅ Badges
- ✅ Weekly E-Mail reports
- ✅ REST API
- ✅ Partially compatible with WakaTime
- ✅ WakaTime integration
- ✅ Support for Prometheus exports
- ✅ Lightning fast
- ✅ Self-hosted
⌨️ How to use?
There are different options for how to use Wakapi, ranging from our hosted cloud service to self-hosting it. Regardless of which option choose, you will always have to do the client setup in addition.
☁️ Option 1: Use wakapi.dev
If you want to try out a free, hosted cloud service, all you need to do is create an account and then set up your client-side tooling (see below).
📦 Option 2: Quick-run a release
$ curl -L https://wakapi.dev/get | bash
🐳 Option 3: Use Docker
# Create a persistent volume
$ docker volume create wakapi-data
$ SALT="$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1)"
# Run the container
$ docker run -d \
--init \
-p 3000:3000 \
-e "WAKAPI_PASSWORD_SALT=$SALT" \
-v wakapi-data:/data \
--name wakapi \
--restart unless-stopped \
ghcr.io/muety/wakapi:latest
Note: By default, SQLite is used as a database. To run Wakapi in Docker with MySQL or Postgres, see Dockerfile and config.default.yml for further options.
If you want to run Wakapi on Kubernetes, there is wakapi-helm-chart for quick and easy deployment.
Docker Compose
Alternatively, you can use Docker Compose for an even more straightforward deployment. See compose.yml for configuration details.
Wakapi supports Docker Secrets for the following variables: WAKAPI_PASSWORD_SALT, WAKAPI_DB_PASSWORD, WAKAPI_MAIL_SMTP_PASS. You can set these either by having them mounted as a secret file, or directly pass them as environment variables.
Example
export WAKAPI_PASSWORD_SALT=changeme
export WAKAPI_DB_PASSWORD=changeme
export WAKAPI_MAIL_SMTP_PASS=changeme
docker compose up -d
If you prefer to persist data in a local directory while using SQLite as the database, make sure to set the correct user option in the Docker Compose configuration to avoid permission issues.
🧑💻 Option 4: Compile and run from source
# Build and install
# Alternatively: go build -o wakapi
$ go install github.com/muety/wakapi@latest
# Get default config and customize
$ curl -o wakapi.yml https://raw.githubusercontent.com/muety/wakapi/master/config.default.yml
$ vi wakapi.yml
# Run it
$ ./wakapi -config wakapi.yml
Note: Check the comments in config.yml for best practices regarding security configuration and more.
💡 When running Wakapi standalone (without Docker), it is recommended to run it as a SystemD service.
💻 Client setup
Wakapi relies on the open-source WakaTime client tools. In order to collect statistics for Wakapi, you need to set them up.
- Set up WakaTime for your specific IDE or editor. Please refer to the respective plugin guide
- Edit your local
~/.wakatime.cfgfile as follows.
[settings]
# Your Wakapi server URL or 'https://wakapi.dev/api' when using the cloud server
api_url = http://localhost:3000/api
# Your Wakapi API key (get it from the web interface after having created an account)
api_key = 406fe41f-6d69-4183-a4cc-121e0c524c2b
Optionally, you can set up a client-side proxy in addition.
WakaTime integration
You can use WakaTime and Wakapi in parallel, that is, have your coding activity tracked in both systems. This can be configured either on the client-side (preferred) on a system-wide- or per-project basis or using Wakapi's relay functionality (Settings → Integrations) to forward heartbeats to WakaTime.
Example:
[settings]
api_key = defaults-to-this-api-key-when-not-defined-below
[api_urls]
.* = https://wakapi.dev/api|wakapi-api-key
.* = https://api.wakatime.com/api/v1|waka-api-key
See wakatime-cli usage for details.
🔧 Configuration options
You can specify configuration options either via a config file (default: config.yml, customizable through the -c argument) or via environment variables. Here is an overview of all options.
| YAML key / Env. variable | Default | Description |
|---------------------------------------------------------------------------------------------|--------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| env /<br>ENVIRONMENT | dev | Whether to use development- or production settings |
| app.leaderboard_enabled /<br>WAKAPI_LEADERBOARD_ENABLED | true | Whether to enable the public leaderboard |
| app.leaderboard_scope /<br>WAKAPI_LEADERBOARD_SCOPE | 7_days | Aggregation interval for public leaderboard (see here for allowed values) |
| app.leaderboard_generation_time /<br>WAKAPI_LEADERBOARD_GENERATION_TIME | 0 0 6 * * *,0 0 18 * * * | One or multiple times of day at which to re-calculate the leaderboard |
| app.leaderboard_require_auth /<br>WAKAPI_LEADERBOARD_REQUIRE_AUTH | false | Restrict leaderboard access to logged in users only |
| app.aggregation_time /<br>WAKAPI_AGGREGATION_TIME | 0 15 2 * * * | Time of day at which to periodically run summary generation for all users |
| app.report_time_weekly /<br>WAKAPI_REPORT_TIME_WEEKLY | 0 0 18 * * 5 | Week day and time at which to send e-mail reports |
| app.data_cleanup_time /<br>WAKAPI_DATA_CLEANUP_TIME | 0 0 6 * * 0 | When to perform data cleanup operations (see app.data_retention_months) |
| app.optimize_database_time /<br>WAKAPI_OPTIMIZE_DATABASE_TIME | 0 0 8 1 * * | When to perform database vacuuming (SQLite, Postgres) or table optimization (MySQL) |
| app.import_enabled /<br>WAKAPI_IMPORT_ENABLED
