A complete headless REST API server for Taskwarrior in Go with:
- ✅ Full CRUD operations for tasks
- ✅ Task lifecycle operations (start, stop, done)
- ✅ Report endpoints (next, active, completed, waiting, all)
- ✅ Project management
- ✅ Token-based authentication
- ✅ CORS support
- ✅ Interactive Swagger UI documentation
- ✅ Environment variable configuration
- ✅ Graceful shutdown
- ✅ Request logging
- Language: Go 1.21+
- Web Framework: Gin
- API Documentation: Swagger/OpenAPI
- Configuration: Environment variables only
- Integration: Taskwarrior CLI (no direct file access)
taskwarrior-api/
├── cmd/server/main.go # Server entry point with Swagger metadata
├── internal/
│ ├── api/
│ │ ├── router.go # Routes and middleware setup
│ │ ├── handlers/
│ │ │ ├── tasks.go # Task CRUD + lifecycle operations
│ │ │ ├── reports.go # Report endpoints
│ │ │ └── projects.go # Project endpoints
│ │ └── middleware/
│ │ ├── auth.go # Bearer token authentication
│ │ └── logging.go # Request logging
│ ├── taskwarrior/
│ │ ├── types.go # Task models + custom time parsing
│ │ ├── client.go # CLI wrapper
│ │ └── parser.go # Filtering and validation
│ ├── config/config.go # Environment variable configuration
│ └── auth/token.go # Token validation
├── docs/ # Auto-generated Swagger docs
├── Makefile # Build automation
├── env.example # Configuration template
├── go.mod & go.sum # Dependencies
└── README.md # Complete documentation
GET /api/v1/tasks- List tasks with filtersGET /api/v1/tasks/:uuid- Get single taskPOST /api/v1/tasks- Create taskPATCH /api/v1/tasks/:uuid- Update taskDELETE /api/v1/tasks/:uuid- Delete taskPOST /api/v1/tasks/:uuid/done- Mark as completePOST /api/v1/tasks/:uuid/start- Start timerPOST /api/v1/tasks/:uuid/stop- Stop timer
GET /api/v1/reports/next- Pending by urgencyGET /api/v1/reports/active- Started tasksGET /api/v1/reports/completed- Completed tasksGET /api/v1/reports/waiting- Waiting tasksGET /api/v1/reports/all- All tasks
GET /api/v1/projects- List projects with countsGET /api/v1/projects/:name/tasks- Tasks in project
GET /swagger/index.html- Interactive Swagger UIGET /health- Health check (no auth)
- Uses CLI exclusively (
task export,task add, etc.) - Never directly touches
.task/files - Custom time parser for Taskwarrior's
20060102T150405Zformat - Returns dates only (
YYYY-MM-DD) in API responses - Input sanitization to prevent command injection
- Simple bearer token validation
- Multiple tokens supported (comma-separated)
- All endpoints except
/healthand/swagger/*require auth
- Environment variables only (no config files)
- Required:
TW_API_TOKENS - Optional: host, port, data location, CORS, log level
- See
env.examplefor template
- Consistent JSON error format with error codes
- Proper HTTP status codes
- Detailed logging for debugging
export TW_API_TOKENS="your-token"
make runhttp://localhost:8080/swagger/index.html
curl -H "Authorization: Bearer your-token" \
http://localhost:8080/api/v1/tasksmake install # Install dependencies + swag CLI
make build # Build binary (auto-generates Swagger docs)
make run # Run server
make swagger # Generate Swagger docs only
make test # Run tests
make clean # Clean build artifacts🚧 Under Construction - Not production-ready
The server is functional but still in active development. APIs may change.