Base Information
The Tasks API is a fully documented, type-safe JSON API built with Hono and OpenAPI. It provides CRUD operations for managing tasks. Base URL:http://localhost:9999 (configurable via PORT environment variable)
Content Type: application/json
API Version: Defined in package.json
Available Endpoints
The API provides the following endpoints:| Method | Path | Description |
|---|---|---|
| GET | / | API index and health check |
| GET | /doc | OpenAPI specification (JSON) |
| GET | /reference | Interactive API documentation (Scalar) |
| GET | /tasks | List all tasks |
| POST | /tasks | Create a new task |
| GET | /tasks/{id} | Get a specific task by ID |
| PATCH | /tasks/{id} | Update a task by ID |
| DELETE | /tasks/{id} | Delete a task by ID |
Response Format
All API responses use JSON format. The API uses standard HTTP status codes to indicate success or failure.Success Responses
200 OK: Successful GET, POST, or PATCH requestError Responses
404 Not Found: Resource not foundTask Schema
All task objects follow this structure:Auto-incrementing unique identifier for the task
The name/description of the task. Must be between 1 and 500 characters.
Whether the task is completed. Defaults to
false when creating a new task.ISO 8601 timestamp of when the task was created
ISO 8601 timestamp of when the task was last updated
Common Use Cases
List All Tasks
Create a Task
The
done field is required when creating a task. The id, createdAt, and updatedAt fields are automatically generated.Get a Specific Task
Update a Task
PATCH requests support partial updates. You can update just the
name, just the done status, or both fields.Delete a Task
Interactive Documentation
The API includes interactive documentation powered by Scalar:- OpenAPI Spec:
GET /doc- Returns the complete OpenAPI 3.0 specification in JSON format - Interactive UI:
GET /reference- Web-based interface to explore and test all endpoints
Validation
All requests are validated using Zod schemas. When validation fails, the API returns a 422 status with detailed error information:Example: Invalid Task Name
Example: Empty PATCH Request
HTTP Status Codes
The API uses these standard HTTP status codes:| Code | Description |
|---|---|
| 200 | OK - Request succeeded |
| 204 | No Content - Delete succeeded |
| 404 | Not Found - Resource doesn’t exist |
| 422 | Unprocessable Entity - Validation failed |
Database
The API uses SQLite with Drizzle ORM. The database schema is defined in code and migrations are managed through Drizzle Kit.Run
pnpm drizzle-kit push to create or update the database schema.