# Wakapi : wakatime API client
Read-only API client for the [Wakatime API](https://wakatime.com/developers), supporting all GET endpoints as blocking or async depending on the `blocking` feature flag.
The following endpoints are implemented:
- [All Time Since Today](https://wakatime.com/developers#all-time-since-today) : [AllTimeSinceToday], [AllTimeSinceTodayParams], [AllTimeSinceToday::fetch]
- [Commit](https://wakatime.com/developers#commit) : [Commit], [CommitParams], [Commit::fetch]
- [Commits](https://wakatime.com/developers#commits) : [Commits], [CommitsParams], [Commits::fetch]
- [Durations](https://wakatime.com/developers#durations) : [Durations], [DurationsParams], [Durations::fetch]
- [Heartbeats](https://wakatime.com/developers#heartbeats) : [Heartbeats], [HeartbeatsParams], [Heartbeats::fetch]
- [Projects](https://wakatime.com/developers#projects) : [Projects], [ProjectsParams], [Projects::fetch]
- [Stats](https://wakatime.com/developers#stats) : [Stats], [StatsParams], [Stats::fetch]
- [Summaries](https://wakatime.com/developers#summaries) : [Summaries], [SummariesParams], [Summaries::fetch]
The structures are based on the [official documentation](https://wakatime.com/developers) last checked **2026-05-15**.
## Known inconsistencies with the official documentation
- **`projects`** — `repository` and `badge` fields are documented as strings but the API returns objects (`RepositoryDetails` and `ProjectBadge` respectively). The struct types match the actual API response.
- **`projects`** — The response includes pagination fields (`page`, `total`, `total_pages`, `prev_page`, `next_page`) not shown in the documentation.
- **`commits`** — The response includes a `page` field not shown in the documentation.
- **`stats`** — The response includes an `is_up_to_date_pending_future` boolean field not present in the documentation.
- **`heartbeats`** — `project_root_count` is present in the response but not documented.
## Usage
### Async mode
```rust
use wakapi::WakapiClient;
let client = WakapiClient::new(
"https://wakatime.com",
"YOUR_WAKATIME_API_KEY",
);
let res = wakapi::Summaries::fetch(
&client,
wakapi::SummariesParams::from_interval("2026-01-01", "2026-01-05"),
).await.unwrap();
println!("{:?}", res);
```
### Blocking mode
```rust
use wakapi::WakapiClient;
let client = WakapiClient::new(
"https://wakatime.com",
"YOUR_WAKATIME_API_KEY",
);
let res = wakapi::Summaries::fetch(
&client,
wakapi::SummariesParams::from_interval("2026-01-01", "2026-01-05"),
).unwrap();
println!("{:?}", res);
```
## Integration tests
Integration tests hit the real Wakatime API and require two environment variables:
| `WAKAPI_URL` | Base URL of the server, e.g. `https://wakatime.com` |
| `WAKAPI_KEY` | Plain-text API key (the client Base64-encodes it) |
```sh
# Async (default)
WAKAPI_URL=https://wakatime.com WAKAPI_KEY=<key> cargo test --test integration
# Blocking
WAKAPI_URL=https://wakatime.com WAKAPI_KEY=<key> cargo test --features blocking --test integration
```
If the environment variables are not set, all tests are silently skipped.
## License
This project is licensed under the MIT License.