Param | Type | Required | Description |
username |
string |
✅ | The GitHub username for which the data is retrieved. |
noCache |
bool |
No | Whether to use the internal JSON Cache. Default is false. |
Param | Type | Required | Description |
username |
string |
✅ | The GitHub username for which the graph is generated. |
width |
int |
No | The width of the graph in pixels. |
barHeight |
int |
No | The height of the bar in the graph. |
lgItemWidth |
int |
No | The max width of individual legend items in the graph. |
lgItemMaxCnt |
int |
No | The cut-off number of legend items to display. E.g. 8 means top 8 most used languages. |
fontSize |
int |
No | Font size for legend items. Default is 14. |
noCache |
bool |
No | Whether to use the internal JSON Cache. Default is false. |
Note: Any optional query parameter uses a default value if unspecified.
On Render
Choose Docker as deployment language. Set environment variables:
GH_AC_TOKEN
to get higher rate quota (GitHub Docs).CACHE_TIMER
to set the JSON cache expiration time. It can only be integer, the unit is hour and default value is 24 (hours).
After deployment goes live, the endpoint can be called. A typical use case is to insert it into a Markdown rendered by GitHub:

Please note that, since GitHub uses Camo (camo.githubusercontent.com) cache for external assets, and this app does not intend to implement cache busting, you would need to manually edit the Markdown to update the generated image each time. Therefore we recommend using an automation tool like GitHub Action to periodically re-fetch, and put the fetched image's relative path in the Markdown instead like so:

. Below is a sample GitHub Action yml template.
Sample GitHub Action file: 🗒️update-stats.yml.
name: Update GitHub Language Stats
on:
schedule:
- cron: '0 */24 * * *' # Run every 24 hours
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch stats from gitpeek-lang
run: |
mkdir -p assets
curl "https://<your-depl>.onrender.com/api/GitHubStats/<username>/graph?barHeight=15" > assets/github-language-stats.svg
- name: Commit and push if changed
run: |
git config user.name github-actions
git config user.email [email protected]
git add assets/github-language-stats.svg
git diff --quiet && git diff --staged --quiet || git commit -m "Update GitHub language stats"
git push
Can be deployed without Docker containerization. Rough steps:
- Choose an Azure subscription.
- Create a Resource Group, an App Service plan and an App Service associated with it.
- Set environment variables as in deployment on Render.
- Locally publish using commands like
dotnet publish ./gitpeek-lang.csproj -c Release --no-restore --output ./publish
Azure CLI deployment command then can be:
az webapp up --name <your-app-service> --runtime "dotnet:8" --resource-group <your-resource-group> --plan <your-plan>
.
dotnet run
-
If you want to use a GitHub token (recommended), set environment variable GH_AC_TOKEN. For example on Windows command line, that could be done by:
set GH_AC_TOKEN=<your_github_token> && dotnet run
docker-compose up --build
--build
is only necessary if there are source code changes.
Jan 22, 2025: Deployment css and js files
It seems we need to use smth like Libman to restore dependencies such as bootstrap.bundle.min.js before deploying through a provide like render.com. Also need to correct paths in `_Layout.cshtml`. Otherwise there will be 404s when retrieving them.Jan 18, 2025: Azure cost
I only have 1 API Management rule and 1 App Service. Azure's predicted cost is $68.71 per about a month. This probably be good for bulk management but will not be worth it for micro apps like this one.depl: deployment
svr: server
param: parameter