📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Ferdinand Mütsch 1a6ee55d14 fix: respect errors thrown in misc functions 3 weeks ago
.github ci: upgrade docker action 2 months ago
config fix: cancel active subscription upon user account deletion 2 months ago
coverage chore: upgrade dependencies 2 months ago
data chore: add support for astro files (see #469) 4 months ago
etc chore: add runtime directory param to systemd unit [skip ci] 4 months ago
helpers feat: implement file statistics (resolve #80) 3 months ago
middlewares fix: adapt csp header for subscriptions [ci-skip] 5 months ago
migrations chore: add support for astro files (see #469) 4 months ago
mocks fix: badges broken (resolve #475) 3 months ago
models fix: view details of unknown projects on dashboard 2 months ago
postman docs: extend postman collection by get heartbeats compat endpoint 1 year ago
repositories fix: invalid search query in Postgres 3 weeks ago
routes fix: return ok status even upon subscription event handling failure [skip ci] 2 months ago
scripts chore: add support indicator for users 2 months ago
services fix: respect errors thrown in misc functions 3 weeks ago
static fix: view details of unknown projects on dashboard 2 months ago
testing test: remove api call for timezone 5 months ago
utils fix: support user agents set by browser plugin (see #237) 3 months ago
views fix: view details of unknown projects on dashboard 2 months ago
.dockerignore chore: update .dockerignore 4 months ago
.gitattributes ref: add .gitattributes file for line normalisation 1 year ago
.gitignore test: migration testing for mysql/mariadb/postgres 5 months ago
.gitpod.yml .gitpod.yml 2 years ago
Dockerfile docker: add non-root user 4 months ago
LICENSE chore: update license [skip ci] 4 months ago
README.md docs: limit readme stats preview to past week [skip ci] 4 weeks ago
config.default.yml chore: ability to disable home page (resolve #460) 3 months ago
doap.rdf Add DOAP description. 3 years ago
docker-compose.yml chore: remove hard-coded volume from Dockerfile 1 year ago
entrypoint.sh fix: exec to replace environment.sh 1 year ago
go.mod chore: upgrade dependencies 2 months ago
go.sum chore: upgrade dependencies 2 months ago
main.go feat: -version flag 2 months ago
package.json chore: update iconify 7 months ago
sonar-project.properties chore: code smells 2 years ago
tailwind.config.js fix: leaderboard ui on small screens 5 months ago
version.txt feat: automatic version.txt updates 11 months ago
yarn.lock chore: add support indicator for users 2 months ago


A minimalist, self-hosted WakaTime-compatible backend for coding statistics.

Installation instructions can be found below and in the Wiki.

🚀 Features

  • Free and open-source
  • Built by developers for developers
  • Statistics for projects, languages, editors, hosts and operating systems
  • Badges
  • Weekly E-Mail reports
  • Partially compatible with WakaTime
  • WakaTime integration
  • Support for Prometheus exports
  • Lightning fast
  • Self-hosted

🚧 Roadmap

Plans for the near future mainly include, besides usual improvements and bug fixes, a UI redesign as well as additional types of charts and statistics (see #101, #76, #12). If you have feature requests or any kind of improvement proposals feel free to open an issue or share them in our user survey.

⌨️ 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

Alternatively using eget:

$ eget muety/wakapi

🐳 Option 3: Use Docker

# Create a persistent volume
$ docker volume create wakapi-data

$ SALT="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1)"

# Run the container
$ docker run -d \
  -p 3000:3000 \
  -v wakapi-data:/data \
  --name wakapi \

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.

🧑‍💻 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.

  1. Set up WakaTime for your specific IDE or editor. Please refer to the respective plugin guide
  2. Edit your local ~/.wakatime.cfg file as follows.

# 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.

🔧 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 /
dev Whether to use development- or production settings
app.aggregation_time /
0 15 2 * * * Time of day at which to periodically run summary generation for all users
app.report_time_weekly /
0 0 18 * * 5 Week day and time at which to send e-mail reports
app.leaderboard_generation_time /
0 0 6 * * *,0 0 18 * * * One or multiple times of day at which to re-calculate the leaderboard
app.data_cleanup_time /
0 0 6 * * 0 When to perform data cleanup operations (see app.data_retention_months)
app.import_batch_size /
50 Size of batches of heartbeats to insert to the database during importing from external services
app.inactive_days /
7 Number of days after which to consider a user inactive (only for metrics)
app.heartbeat_max_age /
4320h Maximum acceptable age of a heartbeat (see ParseDuration)
app.custom_languages - Map from file endings to language names
app.avatar_url_template /
(see config.default.yml) URL template for external user avatar images (e.g. from Dicebear or Gravatar)
app.support_contact /
hostmaster@wakapi.dev E-Mail address to display as a support contact on the page
app.data_retention_months /
-1 Maximum retention period in months for user data (heartbeats) (-1 for unlimited)
server.port /
3000 Port to listen on
server.listen_ipv4 /
WAKAPI_LISTEN_IPV4 IPv4 network address to listen on (leave blank to disable IPv4)
server.listen_ipv6 /
::1 IPv6 network address to listen on (leave blank to disable IPv6)
server.listen_socket /
- UNIX socket to listen on (leave blank to disable UNIX socket)
server.listen_socket_mode /
0666 Permission mode to create UNIX socket with
server.timeout_sec /
30 Request timeout in seconds
server.tls_cert_path /
- Path of SSL server certificate (leave blank to not use HTTPS)
server.tls_key_path /
- Path of SSL server private key (leave blank to not use HTTPS)
server.base_path /
/ Web base path (change when running behind a proxy under a sub-path)
server.public_url /
http://localhost:3000 URL at which your Wakapi instance can be found publicly
security.password_salt /
- Pepper to use for password hashing
security.insecure_cookies /
false Whether or not to allow cookies over HTTP
security.cookie_max_age /
172800 Lifetime of authentication cookies in seconds or 0 to use Session cookies
security.allow_signup /
true Whether to enable user registration
security.disable_frontpage /
false Whether to disable landing page (useful for personal instances)
security.expose_metrics /
false Whether to expose Prometheus metrics under /api/metrics
db.host /
- Database host
db.port /
- Database port
db.socket /
- Database UNIX socket (alternative to host) (for MySQL only)
db.user /
- Database user
db.password /
- Database password
db.name /
wakapi_db.db Database name
db.dialect /
sqlite3 Database type (one of sqlite3, mysql, postgres, cockroach)
db.charset /
utf8mb4 Database connection charset (for MySQL only)
db.max_conn /
2 Maximum number of database connections
db.ssl /
false Whether to use TLS encryption for database connection (Postgres and CockroachDB only)
db.automgirate_fail_silently /
false Whether to ignore schema auto-migration failures when starting up
mail.enabled /
true Whether to allow Wakapi to send e-mail (e.g. for password resets)
mail.sender /
Wakapi <noreply@wakapi.dev> Default sender address for outgoing mails (ignored for MailWhale)
mail.provider /
smtp Implementation to use for sending mails (one of [smtp, mailwhale])
mail.smtp.host /
- SMTP server address for sending mail (if using smtp mail provider)
mail.smtp.port /
- SMTP server port (usually 465)
mail.smtp.username /
- SMTP server authentication username
mail.smtp.password /
- SMTP server authentication password
mail.smtp.tls /
false Whether the SMTP server requires TLS encryption (false for STARTTLS or no encryption)
mail.mailwhale.url /
- URL of MailWhale instance (e.g. https://mailwhale.dev) (if using mailwhale mail provider)
mail.mailwhale.client_id /
- MailWhale API client ID
mail.mailwhale.client_secret /
- MailWhale API client secret
sentry.dsn /
DSN for to integrate Sentry for error logging and tracing (leave empty to disable)
sentry.enable_tracing /
false Whether to enable Sentry request tracing
sentry.sample_rate /
0.75 Probability of tracing a request in Sentry
sentry.sample_rate_heartbeats /
0.1 Probability of tracing a heartbeat request in Sentry
quick_start /
false Whether to skip initial boot tasks. Use only for development purposes!

Supported databases

Wakapi uses GORM as an ORM. As a consequence, a set of different relational databases is supported.

  • SQLite (default, easy setup)
  • MySQL (recommended, because most extensively tested)
  • MariaDB (open-source MySQL alternative)
  • Postgres (open-source as well)
  • CockroachDB (cloud-native, distributed, Postgres-compatible API)

🔧 API endpoints

See our Swagger API Documentation.

Generating Swagger docs

$ go install github.com/swaggo/swag/cmd/swag@latest
$ swag init -o static/docs

🤝 Integrations

Prometheus export

You can export your Wakapi statistics to Prometheus to view them in a Grafana dashboard or so. Here is how.

# 1. Start Wakapi with the feature enabled
$ ./wakapi

# 2. Get your API key and hash it
$ echo "<YOUR_API_KEY>" | base64

# 3. Add a Prometheus scrape config to your prometheus.yml (see below)

Scrape config example

# prometheus.yml
# (assuming your Wakapi instance listens at localhost, port 3000)

  - job_name: 'wakapi'
    scrape_interval: 1m
    metrics_path: '/api/metrics'
    bearer_token: '<YOUR_BASE64_HASHED_TOKEN>'
      - targets: ['localhost:3000']


There is also a nice Grafana dashboard, provided by the author of wakatime_exporter.

WakaTime integration

Wakapi plays well together with WakaTime. For one thing, you can forward heartbeats from Wakapi to WakaTime to effectively use both services simultaneously. In addition, there is the option to import historic data from WakaTime for consistency between both services. Both features can be enabled in the Integrations section of your Wakapi instance's settings page.

GitHub Readme Stats integrations

Wakapi also integrates with GitHub Readme Stats to generate fancy cards for you. Here is an example. To use this, don't forget to enable public data under Settings -> Permissions.

Click to view code

Github Readme Metrics integration

There is a WakaTime plugin for GitHub Metrics that is also compatible with Wakapi. To use this, don't forget to enable public data under Settings -> Permissions.


Click to view code
- uses: lowlighter/metrics@latest
    # ... other options
    plugin_wakatime: yes
    plugin_wakatime_token: ${{ secrets.WAKATIME_TOKEN }}      # Required
    plugin_wakatime_days: 7                                   # Display last week stats
    plugin_wakatime_sections: time, projects, projects-graphs # Display time and projects sections, along with projects graphs
    plugin_wakatime_limit: 4                                  # Show 4 entries per graph
    plugin_wakatime_url: http://wakapi.dev                    # Wakatime url endpoint
    plugin_wakatime_user: .user.login                         # User

👍 Best practices

It is recommended to use wakapi behind a reverse proxy, like Caddy or nginx, to enable TLS encryption (HTTPS).

However, if you want to expose your wakapi instance to the public anyway, you need to set server.listen_ipv4 to in config.yml.

🧪 Tests

Unit tests

Unit tests are supposed to test business logic on a fine-grained level. They are implemented as part of the application, using Go's testing package alongside stretchr/testify.

How to run

$ CGO_ENABLED=0 go test `go list ./... | grep -v 'github.com/muety/wakapi/scripts'` -json -coverprofile=coverage/coverage.out ./... -run ./...

API tests

API tests are implemented as black box tests, which interact with a fully-fledged, standalone Wakapi through HTTP requests. They are supposed to check Wakapi's web stack and endpoints, including response codes, headers and data on a syntactical level, rather than checking the actual content that is returned.

Our API (or end-to-end, in some way) tests are implemented as a Postman collection and can be run either from inside Postman, or using newman as a command-line runner.

To get a predictable environment, tests are run against a fresh and clean Wakapi instance with a SQLite database that is populated with nothing but some seed data (see data.sql). It is usually recommended for software tests to be safe, stateless and without side effects. In contrary to that paradigm, our API tests strictly require a fixed execution order (which Postman assures) and their assertions may rely on specific previous tests having succeeded.

Prerequisites (Linux only)

# 1. sqlite (cli)
$ sudo apt install sqlite  # Fedora: sudo dnf install sqlite

# 2. newman
$ npm install -g newman

How to run (Linux only)

$ ./testing/run_api_tests.sh

🤓 Developer notes

Building web assets

To keep things minimal, all JS and CSS assets are included as static files and checked in to Git. TailwindCSS and Iconify require an additional build step. To only require this at the time of development, the compiled assets are checked in to Git as well.

$ yarn
$ yarn build  # or: yarn watch

New icons can be added by editing the icons array in scripts/bundle_icons.js.


As explained in #284, precompressed (using Brotli) versions of some of the assets are delivered to save additional bandwidth. This was inspired by Caddy's precompressed directive. gzipped.FileServer checks for every static file's .br or .gz equivalents and, if present, delivers those instead of the actual file, alongside Content-Encoding: br. Currently, compressed assets are simply checked in to Git. Later we might want to have this be part of a new build step.

To pre-compress files, run this:

# Install brotli first
$ sudo apt install brotli  # or: sudo dnf install brotli

# Watch, build and compress
$ yarn watch:compress

# Alternatively: build and compress only
$ yarn build:all:compress

# Alternatively: compress only
$ yarn compress


Since Wakapi heavily relies on the concepts provided by WakaTime, their FAQs largely apply to Wakapi as well. You might find answers there.

What data are sent to Wakapi?
  • File names
  • Project names
  • Editor names
  • Your computer's host name
  • Timestamps for every action you take in your editor
  • ...

See the related WakaTime FAQ section for details.

If you host Wakapi yourself, you have control over all your data. However, if you use our webservice and are concerned about privacy, you can also exclude or obfuscate certain file- or project names.

What happens if I'm offline?

All data are cached locally on your machine and sent in batches once you're online again.

How did Wakapi come about?

Wakapi was started when I was a student, who wanted to track detailed statistics about my coding time. Although I'm a big fan of WakaTime I didn't want to pay $9 a month back then. Luckily, most parts of WakaTime are open source!

How does Wakapi compare to WakaTime?

Wakapi is a small subset of WakaTime and has a lot less features. Cool WakaTime features, that are missing Wakapi, include:

  • Leaderboards
  • Embeddable Charts
  • Personal Goals
  • Team- / Organization Support
  • Additional Integrations (with GitLab, etc.)
  • Richer API

WakaTime is worth the price. However, if you only need basic statistics and like to keep sovereignty over your data, you might want to go with Wakapi.

How are durations calculated?

Inferring a measure for your coding time from heartbeats works a bit differently than in WakaTime. While WakaTime has timeout intervals, Wakapi essentially just pads every heartbeat that occurs after a longer pause with 2 extra minutes.

Here is an example (circles are heartbeats):

|   |10s|      3m      |10s|   |

It is unclear how to handle the three minutes in between. Did the developer do a 3-minute break, or were just no heartbeats being sent, e.g. because the developer was staring at the screen trying to find a solution, but not actually typing code?

  • WakaTime (with 5 min timeout): 3 min 20 sec
  • WakaTime (with 2 min timeout): 20 sec
  • Wakapi: 10 sec + 2 min + 10 sec = 2 min 20 sec

Wakapi adds a "padding" of two minutes before the third heartbeat. This is why total times will slightly vary between Wakapi and WakaTime.

👏 Support

Coding in open source is my passion and I would love to do it on a full-time basis and make a living from it one day. So if you like this project, please consider supporting it 🙂. You can donate either through buying me a coffee or becoming a GitHub sponsor. Every little donation is highly appreciated and boosts my motivation to keep improving Wakapi!

🙏 Thanks

I highly appreciate the efforts of @alanhamlett and the WakaTime team and am thankful for their software being open source.

Moreover, thanks to Frachtwerk for sponsoring server infrastructure for Wakapi.dev.

📓 License

MIT @ Ferdinand Mütsch