Deployable GitHub language chart generator — embeddable SVGs for READMEs and websites.
- Features
- Customize Your Charts
- Usage
- Parameters
- Library
- Deployment & Configuration
- Error Responses
- License
- Generates a chart of your top programming languages (up to 16).
- Customizable: Control the title, size, theme, and number of languages displayed.
- Theming: Supports
default,light, anddarkthemes. - Custom Colours: Set background (
bg), text (text), and individual language colours (c1-c16) via query parameters.
- Theming: Supports
- Dynamic Layout: The legend automatically shifts to a two-column layout when displaying 9 or more languages.
- Automatically fetches GitHub repositories: Public user and organization sources are automatically fetched; private repos can be fetched if tokens have access (personal mode only).
- Hosted instances: Serve charts for others via
?source=— an enumerated allowlist, or*for any GitHub account. Hosted modes fetch public repos only. - Global Token: Optional deployment-wide default token, applied to any source without its own
token, boosting limits from 60 req/hr to 5,000/hr. - Hourly caching: Used to reduce API calls and improve performance. On fetch failure the last good chart is served and refresh retries after either 5 minutes, or when GitHub rate-limit timer resets.
- Automatically ignores forks.
- Ignored repositories: Repos ignored via optional (
IGNORED_REPOS) env var. - Preview-only deployments: Optional
ALLOWED_REFERERSrestricts rendering to your own site — blocks README embeds and hotlinking.
Prefer a visual workflow? Use the @gh-top-languages/builder to preview themes, colours, and layout options interactively, then easily copy the generated embed URL to quickly deploy.
<img
src="https://your-deployment-url.vercel.app/api/languages"
alt="My Top Programming Languages"
/>| Parameter | Type | Description | Default | Example |
|---|---|---|---|---|
test |
Boolean | Uses sample data instead of fetching from GitHub API. | false |
?test=true |
error |
String | Forces an error SVG with the given message. For testing only. | — | ?error=test |
source |
String | Hosted instances only: comma-separated GitHub account names to chart (max 10 when GITHUB_ALLOWED_SOURCES=*). |
— | ?source=torvalds,rails |
Full parameter reference lives in the lib README.
Chart rendering, theming, and parameter parsing are powered by @gh-top-languages/lib.
- Node.js 22+
git clone https://github.com/gh-top-languages/api.git
cd api
npm installCopy .env.example to .env, and update the variables. Configure exactly one mode: Personal or Hosted.
IGNORED_REPOS: Optional comma-separated repo names to exclude from the chart. Accepts a bare name (repo, excluded from all sources) orowner/name(org/repo, scoped to one source).GITHUB_TOKEN: Optional deployment-wide default token, applied to any source without its owntoken. A per-source token always takes precedence; the global token only authenticates public repos (no private repos) while boosting limits (5,000 req/hr instead of 60/hr).ALLOWED_REFERERS: Optional comma-separated hostnames. When set, charts render only for requests whoseOrigin/Refererhostname matches: for preview-only deployments (e.g. serving a builder site). Blocks README embeds, hotlinks, and direct navigation.
GITHUB_USERNAMES: GitHub usernames to fetch repositories from. Accepts a single value (masonlet), comma-separated (masonlet,secondlet), or a JSON array with optional per-user tokens (["masonlet", {"name": "other", "token": "github_pat_..."}]).GITHUB_ORGS: GitHub organization names to fetch repositories from. Accepts a single value (gh-top-languages), comma-separated (gh-top-languages,starweb-libs), or a JSON array with optional per-org tokens (["gh-top-languages", {"name": "starweb-libs", "token": "github_pat_..."}])
GITHUB_ALLOWED_SOURCES: Comma-separated account names selectable via?source=(bare URL renders their combined chart), or*to allow any GitHub account (?source=required, max 10 names per request). Hosted instances chart public repositories only; per-source tokens don't exist in this mode. Warning: with*, anyone can use your instance, and every request they make spends your GITHUB_TOKEN's rate limit.
Your endpoint will be available at http://localhost:3000/api/languages (or your configured PORT)
# Build and serve node:http server
npm start
# Serve vercel serverless endpoint (requires Vercel CLI).
vercel devBuilds to dist/ and runs a plain node:http server. Requires a configured .env (or use ?test=true for sample data).
The default endpoint is /api/languages
Any Node.js host: the server is a standalone node:http entry:
npm startOr, deploy with Vercel: Personal instance (your own chart):
Hosted instance (serve charts for others via ?source=):
All errors return HTTP 200 with an error SVG so they render in GitHub README embeds.
Common error messages:
Set GITHUB_USERNAMES/GITHUB_ORGS, or GITHUB_ALLOWED_SOURCES for a hosted instance: missing environment configurationGITHUB_ALLOWED_SOURCES cannot be combined with GITHUB_USERNAMES/GITHUB_ORGS: both modes configured at onceSource selection is not enabled on this instance/Unknown or disallowed source/Invalid source name/Too many sources: bad?source=request; these are CDN-cached for 5 minutesUnknown GitHub account:?source=named an account that doesn't exist (cached 10 minutes)This instance only serves its own site - deploy your own from github.com/gh-top-languages/api: request blocked byALLOWED_REFERERS(cached 5 minutes)GITHUB_USERNAMES/GITHUB_ORGS must be a valid JSON array. Check your configuration.: malformed JSON array in env configGitHub API error: {status} {statusText}: GitHub API request failedNo language data available: no public repositories found- Rate limiting (
403/429with exhausted quota) is detected separately and logged asGitHub rate limit exceeded; resets at HH:MM:SS; the cached chart is served until the reset.
MIT License - see LICENSE for details.




