The WakaTime Stats API is a tool for generating charts based on your last 7 days of coding data from Wakatime. It uses Matplotlib to make the charts and connects to the Wakatime API to get your data.
Built with Python FastAPI, it's quick and easy to use, perfect for developers who want to visualize their coding activity without much hassle.
You can customize the API to hide certain data, group items, change colors, and adjust the size of your charts. It even supports wildcards for more flexible data handling and uses GitHub language colors to color code programming languages.
GET https://{domain}/api/{your_wakatime_username}/pie/languages
?hide=http**,**ml,docker**,json
&width=420
&height=215
&vue.js=41b883
&bash=89e051
- API allows hiding any data you don't want to show
- API allows defining groups of data. Useful if you don't want to show names of your work-related / confidential projects
- API allows changing color of any data
- API allows changing the output size of the image
- API allows using wildcard (
**
) when hiding or defining groups - API uses GitHub languages colors for coloring languages in the
/languages
endpoint
Hiding all languages that start with "docker" and "java" (Dockerfile, Java, JavaScript) [case-insensitive]
GET https://{domain}/api/{your_wakatime_username}/pie/languages
?hide=docker**,java**
GET https://{domain}/api/{your_wakatime_username}/pie/languages
?hide=**ml
Grouping work-related projects that start with "curo" and "compose-stack" specifically [case-insensitive]
GET https://{domain}/api/{your_wakatime_username}/pie/projects
?group=work-related
&work-related=curo**,compose-stack
GET https://{domain}/api/{your_wakatime_username}/pie/projects
?group=work-related
&work-related=curo**,compose-stack
&work-related_colors=black
&wakatime-api-stats=e5e7eb
GET https://{domain}/api/{your_wakatime_username}/pie/editors
?width=650
&height=300
Swagger UI is available on the /docs
endpoint, but it doesn't cover all available GET parameters
GET /api/{username}/pie/languages
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your WakaTime username |
hide |
string , string [] |
Exact name of the language to hide. Wildcard ** name of the language to hide with prefix** or **suffix. Case-insensitive Multiple value must be comma , separated |
{language_name} |
string |
Key is exact name of the language case-insensitive. Value is color in the HEX format (with or without # ) |
width |
number |
Width of the output image in pixels |
height |
number |
Height of the output image in pixels |
GET /api/{username}/pie/editors
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your WakaTime username |
hide |
string , string [] |
Exact name of the editor to hide. Wildcard ** name of the editor to hide with prefix** or **suffix. Case-insensitive Multiple value must be comma , separated |
{editor_name} |
string |
Key is exact name of the editor case-insensitive. Value is color in the HEX format (with or without # ) |
width |
number |
Width of the output image in pixels |
height |
number |
Height of the output image in pixels |
GET /api/{username}/pie/projects
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your WakaTime username |
hide |
string , string [] |
Exact name of the project or group to hide. Wildcard name of the project (or group) to hide with prefix** or **suffix. Case-insensitive Multiple value must be comma , separated |
{project_name} |
string |
Key is exact name of the project case-insensitive. Value is color in the HEX format (with or without # ) |
width |
number |
Width of the output image in pixels |
height |
number |
Height of the output image in pixels |
group |
string |
Name of the group that can be used in other parameters |
{group_name} |
string , string [] |
Key is exact name of the group. Value is exact name of the project to include in the group. Wildcard ** name of the project to hide with prefix** or **suffix. Case-insensitive Multiple value must be comma , separated |
{group_name}_color |
string |
Key is exact name of the group with following _color suffix. Value is color in the HEX format (with or without # ) |
-
Clone project
git clone [email protected]:krios2146/wakatime-stats-api.git
-
Go to project directory
cd wakatime-stats-api
-
Create
.env
filetouch .env
The content of the
.env
is the followingWAKATIME_BASE_URL=https://wakatime.com/api/v1 WAKATIME_API_KEY=waka_**
-
Set up venv
Assuming that python is installed
python -m venv
source venv/biv/activate
pip install -r requirements.txt
-
Start the API
In dev mode with debug log configuration
uvicorn app.main:app --reload --log-config=debug_log_config.yam
In production mode with fast api cli
fastapi run
-
Alternatively, you can run it inside a Docker container
Build
docker build . -t wakatime-stats-api
Run
docker run -d -p 80:8000 --env-file .env wakatime-stats-api
-
Call the API
In browser type
localhost:8000/api/{your_wakatime_username}/pie/languages
To deploy this project and use it for your own purposes, you need a VPS
This is the easiest way to deploy. Use the GitHub package Docker image of the project
Run on the VPS, assuming you have Docker installed:
- Pull the image
docker pull ghcr.io/krios2146/wakatime-stats-api:latest
- Don't forget to include the
.env
file
docker run -d -p 80:8000 --env-file .env ghcr.io/krios2146/wakatime-stats-api:latest
The only difference with the previous variant is that you should build the Docker image from source before deployment
Run the following locally after cloning the project:
- Build the image
docker build . -t {docker_username}/wakatime-stats-api
- Push the image to your Docker repository
docker push {docker_username}/wakatime-stats-api
Run on the VPS, assuming you have Docker installed:
- Pull the image
docker pull {docker_username}/wakatime-stats-api
- Don't forget to include the
.env
file
docker run -d -p 80:8000 --env-file .env {docker_username}/wakatime-stats-api
The steps are the same as in the Local run section but should be executed on the VPS