TaskLeef API 文档

用于管理待办事项、项目和 Kanban 看板的 REST API

最后更新:

身份验证

该 API 支持两种身份验证方式:

1. API 密钥身份验证(推荐)

Generate an API key from your Settings page and include it in the X-API-Key header:

curl -H "X-API-Key: your-api-key" \
  https://taskleef.com/api/todos

2. JWT Bearer 令牌

对于基于浏览器的应用,请通过登录端点进行身份验证:

curl -X POST https://taskleef.com/api/login \
  -H "Content-Type: application/json" \
  -d '{"username": "your-username", "password": "your-password"}'

然后在后续请求中包含该令牌:

curl -H "Authorization: Bearer your-jwt-token" \
  https://taskleef.com/api/todos

待办事项

GET/api/todos

获取已认证用户的所有待办事项。

curl -H "X-API-Key: your-api-key" \
  https://taskleef.com/api/todos
GET/api/todos/{id}

按 ID 获取特定待办事项。

GET/api/inbox

获取未分配到任何项目的待办事项。

POST/api/todos

创建新的待办事项。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"title": "Buy groceries", "description": "Milk, eggs, bread"}' \
  https://taskleef.com/api/todos

请求体

字段类型必填说明
titlestringYesTodo title
descriptionstringNoDetailed description
dueDateISO 8601NoDue date/time
prioritystringNoLow, Medium, High, or Urgent
projectIdUUIDNoAssign to a project
PUT/api/todos/{id}

更新现有待办事项。

PATCH/api/todos/{id}/complete

切换待办事项的完成状态。

curl -X PATCH -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"isCompleted": true}' \
  https://taskleef.com/api/todos/{id}/complete
DELETE/api/todos/{id}

删除待办事项。

POST/api/todos/{parentId}/subtasks

在父待办事项下创建子任务。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"title": "Subtask title"}' \
  https://taskleef.com/api/todos/{parentId}/subtasks

项目

GET/api/projects

列出已认证用户的所有项目。

POST/api/projects

创建新项目。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"title": "Work Tasks", "description": "Tasks for work"}' \
  https://taskleef.com/api/projects
GET/api/projects/{id}

获取特定项目及其待办事项。

PUT/api/projects/{id}

更新项目。

DELETE/api/projects/{id}

删除项目(待办事项将移至收件箱)。

Kanban 看板

GET/api/boards

列出用户有权访问的所有看板。

POST/api/boards

创建新看板。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"title": "Sprint Board", "projectId": "project-uuid"}' \
  https://taskleef.com/api/boards
GET/api/boards/{id}

获取特定看板。

GET/api/boards/{boardId}/columns

获取某个看板的所有列。

GET/api/boards/{boardId}/todos

获取在此看板上拥有卡片的所有待办事项。

POST/api/boards/{boardId}/columns

在看板上创建新列。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"title": "In Progress", "wipLimit": 3}' \
  https://taskleef.com/api/boards/{boardId}/columns
PUT/api/columns/{id}

更新列(标题、WIP 限制、完成标准)。

GET/api/columns/{columnId}/cards

获取某一列中的所有卡片。

DELETE/api/columns/{id}

删除列。

卡片

卡片表示 Kanban 看板上的待办事项。一个待办事项可以在多个看板上拥有卡片。

POST/api/columns/{columnId}/cards

在某一列中为待办事项创建卡片。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"todoId": "todo-uuid"}' \
  https://taskleef.com/api/columns/{columnId}/cards
PUT/api/cards/{id}

更新卡片(移动到不同的列或子列)。

# Move card to a different column
curl -X PUT -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"columnId": "new-column-uuid", "subColumn": "Inbox"}' \
  https://taskleef.com/api/cards/{id}

# Move card to Done subColumn
curl -X PUT -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"subColumn": "Done"}' \
  https://taskleef.com/api/cards/{id}

子列取值

  • Inbox - Active items in the column
  • Done - Completed items within the column
  • Blocked - Items waiting on external dependencies
DELETE/api/cards/{id}

从看板中移除卡片(不会删除待办事项)。

标签

GET/api/tags

列出已认证用户的所有标签。

POST/api/tags

创建新标签。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"name": "urgent"}' \
  https://taskleef.com/api/tags
PUT/api/tags/{id}

更新标签。

DELETE/api/tags/{id}

删除标签。

评论

GET/api/todos/{todoId}/comments

获取某个待办事项上的所有评论。

POST/api/todos/{todoId}/comments

为待办事项添加评论。

curl -X POST -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"text": "This is my comment"}' \
  https://taskleef.com/api/todos/{todoId}/comments
PUT/api/comments/{id}

更新评论。

DELETE/api/comments/{id}

删除评论。

响应格式

成功响应

成功的请求会返回包含所请求数据的 JSON:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "isCompleted": false,
  "createdAt": "2024-01-15T10:30:00Z"
}

错误响应

错误会返回相应的 HTTP 状态码:

  • 400 - Bad Request (invalid input)
  • 401 - Unauthorized (missing or invalid authentication)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Not Found
  • 500 - Internal Server Error

Need help? Check your Settings to manage API keys.