selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
ghstats logo

Self-host ghstats

v0.10.0

Track GitHub repo traffic forever on your own server

BetaOpen SourceMIT
Updated11 hours ago
LanguageRust
Setup difficultyEasy
Stars
190
Port
8080 (HTTP web interface and API)
Docker
ghcr.io/vladkens/ghstats
Install with Docker
ghstats dashboard preview showing repository traffic analytics

What is ghstats?

ghstats is a Rust-based, self-hosted service that fetches GitHub repository traffic data through the GitHub API and persists it in a local SQLite database, overcoming GitHub's built-in 14-day retention window. It presents per-repo dashboards with stars, clones, views, referrers, and top paths, syncs automatically on an hourly schedule (configurable via cron), and optionally tracks private repositories. A read-only JSON API and public SVG badge endpoints let you embed metrics on personal sites or READMEs. Repository visibility can be filtered by owner, name, fork status, or archived state. Deployment requires only the Docker image from ghcr.io/vladkens/ghstats and a mounted volume for the database — no external database, hosted account, or frontend build step. All settings are controlled through environment variables.

Should you self-host ghstats?

ghstats scores 45/100 on selfhost.directory (how scoring works) and ranks #18 of 27 in Analytics. It has 190 GitHub stars.

It shipped 11 stable releases in the past year. The latest, v0.10.0, came out on 25 August 2026.

Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in Rust.

Its closest alternative on selfhost.directory is PostHog (81/100, 40 492 stars). It scores higher overall, so compare the two before you pick. See ghstats vs PostHog side by side.

Features

  • Automatic hourly sync
  • Configurable sync schedule
  • CORS-enabled API
  • Custom header links
  • Embeddable SVG badges
  • Global service badges
  • JSON API
  • Long-term traffic history
  • Per-repository dashboards
  • Private repository support
  • Repository filtering
  • Rotating token support
  • SQLite Storage

ghstats README

How to install ghstats

Install ghstats with Docker

Environment variables
GITHUB_TOKEN, GHS_INCLUDE_PRIVATE, GHS_FILTER, GHS_API_TOKEN, GHS_CRON_SCHEDULE, GHS_CUSTOM_LINKS, HOST, PORT, GITHUB_TOKEN_FILE

docker run -d --env-file .env -p 8080:8080 -v ./data:/app/data --name ghstats ghcr.io/vladkens/ghstats:latest

Requires GITHUB_TOKEN in .env file

How to configure ghstats

  • GHS_API_TOKENToken required to access the JSON API, sent via x-api-token header

    Token required to access the JSON API, sent via x-api-token header

  • GHS_CRON_SCHEDULE0 59 * * * *Cron schedule for metrics collection (six-field format)

    Cron schedule for metrics collection (six-field format)

  • GHS_CUSTOM_LINKSCustom links to display in the header, format: Name|URL,Name|URL

    Custom links to display in the header, format: Name|URL,Name|URL

  • GHS_FILTER*Repository filter rules for display and data collection

    Repository filter rules for display and data collection

  • GHS_INCLUDE_PRIVATEfalseEnable access to private repositories when set to true

    Enable access to private repositories when set to true

    values: true,false

  • GITHUB_TOKENGitHub personal access token with public_repo scope (or repo scope for private repos)

    GitHub personal access token with public_repo scope (or repo scope for private repos)

  • GITHUB_TOKEN_FILEPath to a file containing a rotating GitHub installation token, takes precedence over GITHUB_TOKEN

    Path to a file containing a rotating GitHub installation token, takes precedence over GITHUB_TOKEN

  • HOST0.0.0.0Host address the app binds to

    Host address the app binds to

  • PORT8080Port the app listens on

    Port the app listens on

ghstats releases & version history

More in Dashboard

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…