Install

shell
npm install -g profile-graphics

PNG and WebP output uses sharp, an optional dependency that npm installs by default where it is supported. Without it, stick to SVG.

Commands

Command Use it when Example
init You are setting up a repository and want profile-graphics.yml and a GitHub Actions or GitLab CI workflow written for you. profile-graphics init --user octocat
generate You want cards from real provider data. gen is a short alias. profile-graphics generate --user octocat --charts streak,langs
demo You want to try cards and themes without a token; it renders every card by default. profile-graphics demo --theme tokyo-night
preview You want the cards and an HTML page that shows them side by side. With --watch it renders again whenever the config file changes, and the open page reloads every two seconds. profile-graphics preview --demo --watch
validate You want to check the YAML before CI runs. profile-graphics validate --config profile-graphics.yml
doctor You want to check the config and the token of every source, including whether it is the limited Actions token. profile-graphics doctor --config profile-graphics.yml
themes You want the list of presets. profile-graphics themes --json
schema You want the path of the JSON schema. profile-graphics schema
migrate You are moving from github-readme-stats or similar services. profile-graphics migrate --readme README.md
serve You want live image URLs instead of committed files. profile-graphics serve --port 3000 --allow octocat
studio You want to build the README and the config by drag and drop in a local browser app, with a preview on real data. See Studio. profile-graphics studio --demo

generate accepts every option as a flag, as listed in CLI flags and Action inputs; demo accepts all of them except the provider settings. Both read profile-graphics.yml from the current folder when it exists, or the file given with --config.

Exit codes

Code Meaning
0 Success.
1 Configuration or validation error.
2 Provider or API error.
3 Output write error.

Self-host an image endpoint

profile-graphics serve renders cards on request at /<provider>/<user>/<card>.<svg|png|webp> for github, gitlab and forgejo. /<provider>/<user>/dashboard.svg?charts=… returns a dashboard, and /<provider>/<user>.json returns the stats for the <profile-graphics> web component. Other options go in the query string with their Action input names, such as ?theme=dracula&locale=de&calendar_mode=rolling. On single-card routes custom_title sets the card title, as in github-readme-stats. Stats and images stay in memory for --cache seconds and are sent with a matching Cache-Control header. The server listens on 127.0.0.1 unless --host says otherwise.

shell
GITHUB_TOKEN=github_pat_... profile-graphics serve --host 0.0.0.0 --allow octocat --rate-limit 60/60
curl "http://localhost:3000/github/octocat/streak.svg?theme=dracula&locale=de"
curl "http://localhost:3000/github/octocat/dashboard.svg?charts=streak,summary,langs"

--rate-limit 60/60 lets each client send 60 requests per 60 seconds; the Node.js server identifies clients by their socket address. Extra requests get HTTP 429 with a Retry-After header, and a malformed value stops the command with exit code 1.

profile-graphics/server exports the same handler, createCardHandler, as a function from Request to Response, so it runs on Bun, Deno and any host that takes a Fetch API handler. There rateLimit reads the client from the first address in x-forwarded-for, or from your own clientKey function; requests without one are not limited. PNG and WebP need sharp; use SVG where native modules are not available.

bun.ts
import { createCardHandler } from "profile-graphics/server";

const handler = createCardHandler({
  allowedUsers: ["octocat"],
  cacheSeconds: 3600,
  rateLimit: { requests: 60, windowSeconds: 60 }
});

Bun.serve({ port: 3000, fetch: handler });
deno.ts
import { createCardHandler } from "npm:profile-graphics/server";

Deno.serve(createCardHandler({ allowedUsers: ["octocat"] }));

For a container, install the CLI in a Node.js image and pass the provider tokens as environment variables.

Dockerfile
FROM node:22-slim
RUN npm install -g profile-graphics
USER node
EXPOSE 3000
CMD ["profile-graphics", "serve", "--host", "0.0.0.0", "--port", "3000"]
shell
docker build -t profile-graphics .
docker run -p 3000:3000 -e GITHUB_TOKEN=github_pat_... profile-graphics
The server reads GITHUB_TOKEN, GITLAB_TOKEN and FORGEJO_TOKEN from its environment and spends their rate limit on every uncached request; GitHub routes need GITHUB_TOKEN. On public hosts set --allow or allowedUsers, and --rate-limit or rateLimit.

Count profile views

The views card counts on the server: every GET of /<provider>/<user>/views.svg (or .png, .webp) adds one view and returns the new count. HEAD requests and /<provider>/<user>/views.json only read the count; the JSON holds the raw total and the last 14 days. The route never calls the provider, so it needs no token. Paste the image into your README:

README.md
![Profile views](https://cards.example.com/github/octocat/views.svg)

GitHub shows README images through its camo proxy, which caches them. Counter responses are sent with Cache-Control: no-cache, no-store, max-age=0, so camo asks the server again on every page view. That makes the count a number of page loads, not of unique people: GitHub hides who is looking.

Counts live in a store. By default it is memory, which starts from zero on every restart. --counter-file data/views.json keeps them in a JSON file. On Vercel, set UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN (or the KV_REST_API_URL and KV_REST_API_TOKEN that the Vercel marketplace integration creates) and the counts go to Upstash Redis; without them every function instance counts on its own and forgets.

shell
profile-graphics serve --host 0.0.0.0 --allow octocat --counter-file data/views.json
curl "http://localhost:3000/github/octocat/views.svg?views_style=card&theme=dracula"
curl "http://localhost:3000/github/octocat/views.json"

views_style, views_label, views_start and every display option go in the query string, such as ?views_style=card&theme=dracula.

--allow and --rate-limit apply here too: other users get HTTP 403, and a client over the limit still gets the image with the current count, but its request is not counted. Use --allow on a public host so nobody can fill the store with other names.

Token safety

Pass tokens through environment variables or CI secrets. Never commit tokens to profile-graphics.yml. CLI errors mask classic GitHub tokens (ghp_) and GitLab tokens (glpat-).
shell
profile-graphics generate \
  --provider github \
  --user octocat \
  --token "$GITHUB_TOKEN" \
  --output dist

Reproducible builds

Set SOURCE_DATE_EPOCH to a Unix timestamp in seconds and generate, demo and preview use it as the current time: the date window, streaks and "today" are computed for that moment, so the same data always gives the same files. Without it the system clock is used.