Skip to main content

ghtraffic

Keep your GitHub traffic for longer than 14 days, across all your repos and orgs, and explore it in a dashboard.

GitHub shows a repo's views, clones, referrers and popular pages for the last 14 days only, one repo at a time. ghtraffic collects them for every repo you can push to, on a schedule, and merges each run into a growing history of small CSV files in a git repository you own. Star, fork and watcher counts come along, and star history is rebuilt back to each repo's creation. A static dashboard reads that history.

Dashboard (demo data): https://thorwhalen.github.io/ghtraffic/

Quick start: collect with a GitHub Action

  1. Create a private repository for the data (it will hold the traffic of your private repos too), and add the workflow and config to it:

    pip install ghtraffic
    gh repo create my-traffic-data --private --clone && cd my-traffic-data
    ghtraffic init . --owner @me          # or: --owner me --owner my-org ...
    git add -A && git commit -m "ghtraffic" && git push -u origin main
    

    ghtraffic init writes two files: ghtraffic.toml (what to collect) and .github/workflows/ghtraffic.yml, which is all the workflow needs:

    - uses: actions/checkout@v4
    - uses: thorwhalen/ghtraffic@0.0.2   # the release you installed; pin it
      with:
        token: ${{ secrets.GHTRAFFIC_TOKEN }}
    

    The Action is pinned to a release tag (or pin a commit SHA): the token it receives can read every repo it covers, so it should run code you chose, not whatever lands on main later. It refuses to commit private repos' data into a public repository (input allow-public: true overrides).

    "@me" means you and every organization you belong to, including client or employer organizations whose repo names and traffic may not be yours to copy. List owners explicitly, or use exclude = ["client-org/*"], when that matters.

  2. Create a token with push access to the repos you want: a classic token with the repo and read:org scopes covers every owner you can push to (a fine-grained token is limited to one owner). Save it as the data repo's GHTRAFFIC_TOKEN secret:

    gh secret set GHTRAFFIC_TOKEN
    
  3. Run it once by hand (gh workflow run ghtraffic.yml), and it will run on its own on Mondays and Thursdays from then on. The first run is the cold start: it takes the 14 days GitHub still has, plus each repo's star history. Every later run merges into what is there; re-running is always safe.

Look at it

Open the dashboard at https://thorwhalen.github.io/ghtraffic/ and point it at your data repo, or use #repo=<owner>/<data-repo> in the URL. Paste a fine-grained token that can only read the contents of that one repo. Your browser fetches the data straight from the GitHub API with it. The page itself is public, holds no data, talks to no host but GitHub, and refuses to run inside a frame. The token stays in memory unless you tick "remember"; a remembered token is readable by any page on the same <user>.github.io origin, which is one more reason to give it read access to the data repo only. ?data=<url> reads a public data directory from raw.githubusercontent.com instead.

It shows totals and growth over any time range, by owner and repo, views or clones, totals or uniques, a sortable leaderboard with sparklines, top referrers and pages, and stars and forks over time.

Collect from your own computer

ghtraffic collect --owner @me                  # into ~/.local/share/ghtraffic/data
ghtraffic collect --data-dir ./my-traffic-data # into a checkout of your data repo

The token comes from GHTRAFFIC_TOKEN, GH_TOKEN or GITHUB_TOKEN, or from the GitHub CLI (gh auth login).

From Python:

from ghtraffic import collect, load_settings, Files

report = collect(load_settings(owners=["@me"], exclude=["my-org/sandbox-*"]), store=Files("~/traffic"))
print(report.summary())

store is any MutableMapping[str, str] (relative path to text): a folder by default, or any dol store (S3, a database, ...). rest= and graphql= replace the HTTP transport.

Configuration

ghtraffic.toml, at the data directory's root. Every key is optional.

key default meaning
owners ["@me"] user and org logins; "@me" is you and every org you belong to
exclude [] owner/repo glob patterns to skip ("my-org/*" skips an owner)
include_forks true collect forks too
include_archived true collect archived repos too
snapshot_every_days 14 days between snapshots of referrers, paths and 14-day totals
backfill_stars true rebuild a repo's star history the first time it is seen
max_workers 8 concurrent requests

Unknown keys are refused (a typo never silently falls back to a default). Every key is also a ghtraffic collect flag (--no-include-forks, --snapshot-every-days 7, ...).

Repos you cannot push to have no readable traffic: they are counted and listed in last_run.json, never an error. An organization policy refusing the token (SAML SSO, a ban on classic tokens) is an error, listed with the repo, so a whole org never silently reads as zero traffic. The Action log carries counts only; names and messages go to last_run.json.

Data layout

Plain CSV, one table per kind, split by year, sorted by date so each run adds lines at the end of the current year's file. manifest.json lists every file and its columns.

file rows
views/YYYY.csv, clones/YYYY.csv date,repo,count,uniques: one per repo and day with any traffic (no row means zero)
windows/YYYY.csv fetched,repo,kind,count,uniques: 14-day totals at each snapshot, the only true 14-day unique counts
referrers/YYYY.csv, paths/YYYY.csv the top 10 over the 14 days before fetched; snapshots are 14 days apart, so they never overlap
stars.csv date,repo,stars,forks,watchers: a row only when something changed
repos.csv current metadata of every repo seen
backfills.csv when each repo's star history was rebuilt (a failed backfill is retried next run)
runs.csv, last_run.json one row per run; the last run's details (repos without access, errors)

A day seen by several runs keeps the largest value of each field, so overlapping windows, re-runs and partial days all merge to the same result. Why this layout, and the alternatives: docs/adr/0001-storage.md.

Cost

One job per run, about 1 minute (a few minutes for the cold start with star history). At two runs a week that is about 10 to 20 Actions minutes a month on a private repository, and two missed runs in a row still lose nothing. Data grows by a few MB a year for a few hundred repos.

Limits

  • GitHub keeps traffic for 14 days. Nothing earlier can be recovered, except star history.
  • Star history counts current stargazers by the date they starred; unstars are invisible.
  • Referrers and paths are GitHub's top 10 per repo only. Snapshots are 14 days apart so they can be added up; a missed snapshot run loses the referrer and path data of the days it slipped by (daily views and clones are unaffected).
  • One token for every owner means a classic token (fine-grained tokens are per owner).

Metadata

Release files for ghtraffic 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ghtraffic 0.0.3
File Size Uploaded Provenance Actions
ghtraffic-0.0.3.tar.gz 30.2 kB Without provenance Details for ghtraffic-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ghtraffic 0.0.3
File Interpreter ABI Platform Actions
ghtraffic-0.0.3-py3-none-any.whl Python 3 none any Details for ghtraffic-0.0.3-py3-none-any.whl

Total release size: 60.1 kB

Release files / ghtraffic-0.0.3.tar.gz

Download URL ghtraffic-0.0.3.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
75b5023ae899272a3617952eb98fe4f85d598c21adaed8acb12281b5a0ab8a21
BLAKE2b-256 checksum
How to use checksums
0162d9e53c65326379943580de082959a00692cd18859d3361472382fbc164df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ghtraffic-0.0.3-py3-none-any.whl

Download URL ghtraffic-0.0.3-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64890294f945c8cc2c1384d835ae4800fde7392f4d4e5c09fe9db2a995c438f9
BLAKE2b-256 checksum
How to use checksums
2ab43bb28eef5cf920e43d315a03264a8fb7ad112bbefb9475c87389b6f26356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ghtraffic 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page