tokei-api provides dynamic badges that you can add to your README or other documentation. These badges visually display code statistics.
tokei-api provides badges for both GitHub repositories and any other Git repository. You can add these badges to your README or other documentation.
To add badges for a GitHub repository, use the following markdown format:
[](https://tokei.kojix2.net/github/owner/repo)
For example, badges for this project (tokei-api):
[](https://tokei.kojix2.net/github/kojix2/tokei-api)
[](https://tokei.kojix2.net/github/kojix2/tokei-api)
[](https://tokei.kojix2.net/github/kojix2/tokei-api)
[](https://tokei.kojix2.net/github/kojix2/tokei-api)
For repositories hosted on other platforms (GitLab, Bitbucket, etc.), first analyze the repository using the form on the home page, then use the following markdown format:
[](https://example.com/user/repo)
Replace https://example.com/user/repo.git
with your repository URL. You can use any of the badge types: lines
, language
, languages
, or ratio
.
Badge Type | GitHub Endpoint | Generic Endpoint | Description |
---|---|---|---|
Lines of Code | /badge/github/:owner/:repo/lines |
/api/badge/lines?url=... |
Total lines of code in the repository |
Top Language | /badge/github/:owner/:repo/language |
/api/badge/language?url=... |
Most used programming language |
Languages Count | /badge/github/:owner/:repo/languages |
/api/badge/languages?url=... |
Number of programming languages used |
Code to Comment Ratio | /badge/github/:owner/:repo/ratio |
/api/badge/ratio?url=... |
Ratio of code to comments |
tokei-api badges are compatible with shields.io endpoint format. This allows for consistent styling with other badges you might be using in your documentation.
The badge endpoints return JSON in the following format:
{
"schemaVersion": 1,
"label": "Lines of Code",
"message": "1.2k",
"color": "blue"
}