The Query API lets you run powerful data transformations over your activity events without writing application code. Queries are submitted as POST requests and return processed event arrays.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ActivityWatch/activitywatch/llms.txt
Use this file to discover all available pages before exploring further.
Endpoint
Optional name for the query (used for caching)
Array of time period strings in the format
"start/end" using ISO 8601 timestampsArray of query statement strings (each element is one statement)
Example: Active time by app
Query language reference
| Function | Signature | Description |
|---|---|---|
query_bucket | (bucket_id) | Fetch all events from a bucket for the query time period |
filter_keyvals | (events, key, values) | Keep events where data[key] is in values |
exclude_keyvals | (events, key, values) | Remove events where data[key] is in values |
filter_period_intersect | (events, filter_events) | Keep events that overlap with filter_events |
merge_events_by_keys | (events, keys) | Merge consecutive events with identical values for given keys |
sort_by_duration | (events) | Sort events descending by duration |
limit_events | (events, count) | Return the first N events |
categorize | (events, rules) | Add a $category key using matching rules |
tag | (events, rules) | Add tags to events based on rules |
The
RETURN statement is required — it specifies which variable to return as the query result.