时间记录

查询时间记录

GET /v1/time-entries

默认每页 100 条,最多 500 条。保留筛选条件并传入 nextCursor 继续读取;分页过程中数据可能变化,完整备份请使用导出。

请求参数

fromDate

query · 可选

筛选开始日(含)

类型: string

完整 JSON Schema
{
  "type": "string",
  "format": "date"
}

toDateExclusive

query · 可选

筛选结束日(不含)

类型: string

完整 JSON Schema
{
  "type": "string",
  "format": "date"
}

from

query · 可选

开始时间(含);与 to 同时提供

类型: string

完整 JSON Schema
{
  "type": "string",
  "format": "date-time"
}

to

query · 可选

结束时间(不含);与 from 同时提供

类型: string

完整 JSON Schema
{
  "type": "string",
  "format": "date-time"
}

state

query · 可选

记录、任务或操作状态;语义取决于接口

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "running",
    "stopped",
    "invalid"
  ]
}

projectIds

query · 可选

项目 ID 筛选;GET 用逗号分隔,POST 用数组

类型: string

完整 JSON Schema
{
  "type": "string",
  "maxLength": 8192
}

tagIds

query · 可选

标签 ID;GET 筛选用逗号分隔,正文用数组

类型: string

完整 JSON Schema
{
  "type": "string",
  "maxLength": 8192
}

tagMatch

query · 可选

标签匹配:any 或 all

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "any",
    "all"
  ]
}

noProject

query · 可选

仅匹配无项目的记录

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "true",
    "false"
  ]
}

noTags

query · 可选

仅匹配无标签的记录

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "true",
    "false"
  ]
}

includeDescendants

query · 可选

筛选时包含后代标签

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "true",
    "false"
  ]
}

archived

query · 可选

归档筛选:active、only 或 all

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "active",
    "only",
    "all"
  ]
}

match

query · 可选

时间匹配:overlaps 或 startsWithin

类型: string

完整 JSON Schema
{
  "type": "string",
  "enum": [
    "overlaps",
    "startsWithin"
  ]
}

text

query · 可选

搜索文本;使用 POST 避免进入 URL

类型: any

完整 JSON Schema
{
  "not": {}
}

limit

query · 可选

每页数量,默认 100,最多 500

类型: string

完整 JSON Schema
{
  "type": "string",
  "pattern": "^(?:[1-9][0-9]?|[1-4][0-9]{2}|500)$"
}

cursor

query · 可选

不透明游标;原样传回,不要解析

类型: string

完整 JSON Schema
{
  "type": "string",
  "maxLength": 8192
}

调用示例

将路径参数和请求参数替换为实际值。请求体按上述结构保存到 request.json。

curl --fail-with-body --request GET 'https://api.treering.cn/v1/time-entries' \
  --header "Authorization: Bearer $TREERING_API_TOKEN"

响应

200

成功响应;具体状态取决于操作结果。

application/json

类型: object

字段类型必填说明与约束
itemsarray<object>是资源、事件或操作结果列表
items[]object否{"additionalProperties":false}
items[].idstring是资源、任务或操作标识
items[].versionstring是版本号,十进制字符串,不要转为浮点数 {"pattern":"^(0|[1-9][0-9]*)$"}
items[].etagstring是并发版本标记;保留引号用于 If-Match
items[].updatedAtstring是服务端最后更新时间
items[].operationIdstring否请求回执标识,无需查询状态
items[].deletedAtstring否删除时间
items[].startTimestring | null否开始时间,带时区的 ISO 8601
items[].startTime (anyOf 1)string否
items[].startTime (anyOf 2)null否
items[].stopTimestring | null否结束时间;null 表示运行中
items[].stopTime (anyOf 1)string否
items[].stopTime (anyOf 2)null否
items[].detailstring | null否记录详情
items[].detail (anyOf 1)string否
items[].detail (anyOf 2)null否
items[].notestring | null否备注
items[].note (anyOf 1)string否
items[].note (anyOf 2)null否
items[].projectIdstring | null否项目 ID;无项目为 null
items[].projectId (anyOf 1)string否
items[].projectId (anyOf 2)null否
items[].tagIdsarray<string>否标签 ID;GET 筛选用逗号分隔,正文用数组
items[].tagIds[]string否
items[].sourcestring | null否来源标记
items[].source (anyOf 1)string否
items[].source (anyOf 2)null否
items[].statestring否记录、任务或操作状态;语义取决于接口
items[].durationSecondsnumber | null否持续时间,单位秒,可有小数
items[].durationSeconds (anyOf 1)number否
items[].durationSeconds (anyOf 2)null否
hasMoreboolean是是否还有下一页
nextCursorstring | null是下一页游标;末页为 null
nextCursor (anyOf 1)string否
nextCursor (anyOf 2)null否
evaluatedAtstring是服务端计算结果的时间
effectiveRangeobject | null是此次查询固定的时间范围
effectiveRange (anyOf 1)object否
effectiveRange (anyOf 1).fromstring是开始时间(含);与 to 同时提供
effectiveRange (anyOf 1).tostring是结束时间(不含);与 from 同时提供
effectiveRange (anyOf 2)null否
完整 JSON Schema
{
  "type": "object",
  "required": [
    "items",
    "hasMore",
    "nextCursor",
    "evaluatedAt",
    "effectiveRange"
  ],
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "version",
          "etag",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "资源、任务或操作标识"
          },
          "version": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$",
            "description": "版本号,十进制字符串,不要转为浮点数"
          },
          "etag": {
            "type": "string",
            "description": "并发版本标记;保留引号用于 If-Match"
          },
          "updatedAt": {
            "type": "string",
            "description": "服务端最后更新时间"
          },
          "operationId": {
            "type": "string",
            "description": "请求回执标识,无需查询状态"
          },
          "deletedAt": {
            "type": "string",
            "description": "删除时间"
          },
          "startTime": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "开始时间,带时区的 ISO 8601"
          },
          "stopTime": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "结束时间;null 表示运行中"
          },
          "detail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "记录详情"
          },
          "note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "备注"
          },
          "projectId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "项目 ID;无项目为 null"
          },
          "tagIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "标签 ID;GET 筛选用逗号分隔,正文用数组"
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "来源标记"
          },
          "state": {
            "type": "string",
            "description": "记录、任务或操作状态;语义取决于接口"
          },
          "durationSeconds": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "description": "持续时间,单位秒,可有小数"
          }
        },
        "additionalProperties": false
      },
      "description": "资源、事件或操作结果列表"
    },
    "hasMore": {
      "type": "boolean",
      "description": "是否还有下一页"
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "下一页游标;末页为 null"
    },
    "evaluatedAt": {
      "type": "string",
      "description": "服务端计算结果的时间"
    },
    "effectiveRange": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "from",
            "to"
          ],
          "properties": {
            "from": {
              "type": "string",
              "description": "开始时间(含);与 to 同时提供"
            },
            "to": {
              "type": "string",
              "description": "结束时间(不含);与 from 同时提供"
            }
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "此次查询固定的时间范围"
    }
  }
}

400, 401, 403, 404, 410, 413, 422, 429, 500, 503

错误响应;请按 code 处理。

application/json

类型: object

字段类型必填说明与约束
codestring是机器可读错误码
messagestring否错误说明;请按 code 处理程序逻辑
requestIdstring否请求追踪标识
operationIdstring否请求回执标识,无需查询状态
完整 JSON Schema
{
  "type": "object",
  "required": [
    "code"
  ],
  "properties": {
    "code": {
      "type": "string",
      "description": "机器可读错误码"
    },
    "message": {
      "type": "string",
      "description": "错误说明;请按 code 处理程序逻辑"
    },
    "requestId": {
      "type": "string",
      "description": "请求追踪标识"
    },
    "operationId": {
      "type": "string",
      "description": "请求回执标识,无需查询状态"
    }
  },
  "additionalProperties": true
}

目录