Enter a Git repository URL to get source code statistics using tokei.
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 above, 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
.
You can directly access GitHub repositories using the following format:
https://tokei.kojix2.net/github/:owner/:repo
For example, to analyze the Crystal language repository:
https://tokei.kojix2.net/github/kojix2/tokei-api
This allows you to access analysis results directly without having to input the repository URL.
tokei-api provides a consistent RESTful API. The following endpoints are available:
POST /api/analyses
- Analyze a repositoryGET /api/analyses?url=...
- Retrieve cached analysis result by repository URLGET /api/analyses/:id
- Retrieve a specific analysis resultGET /api/analyses/:id/languages
- Get language statisticsGET /api/analyses/:id/badges/:type
- Get badge dataGET /api/badge/:type?url=...
- Retrieves badge data in Shields.io compatible format for the specified repository.
Available badge types: lines
, language
, languages
, ratio
.
GET /api/github/:owner/:repo
- Analyze a GitHub repositoryGET /api/github/:owner/:repo/languages
- Get language statistics for a GitHub repositoryGET /api/github/:owner/:repo/badges/:type
- Get badge data for a GitHub repository
// Analyze a repository
curl -X POST \
-H "Content-Type: application/json" \
-d '{"url":"https://github.com/kojix2/tokei-api"}' \
https://tokei.kojix2.net/api/analyses
// Retrieve cached analysis result
curl "https://tokei.kojix2.net/api/analyses?url=https://github.com/kojix2/tokei-api"
// Analyze a GitHub repository directly
curl https://tokei.kojix2.net/api/github/kojix2/tokei-api
// Retrieve badge data for any Git repository
curl "https://tokei.kojix2.net/api/badge/lines?url=https://github.com/kojix2/tokei-api"