reports

Summarize tracked time

POST /v1/reports/summary

Maximum range: 366 days; defaults to daily buckets with no grouping. Tag groups are not additive.

Request body

Required

application/json

Type: object

FieldTypeRequiredDescription and constraints
fromDatestringNoInclusive filter start date {"format":"date"}
toDateExclusivestringNoExclusive filter end date {"format":"date"}
fromstringYesInclusive start timestamp; provide with to {"format":"date-time"}
tostringYesExclusive end timestamp; provide with from {"format":"date-time"}
statestringNoEntry, job or operation state; meaning depends on the endpoint {"enum":["running","stopped","invalid"]}
projectIdsarray<string>NoProject IDs; comma-separated in GET, array in POST {"minItems":1,"maxItems":100}
projectIds[]stringNo{"minLength":1,"maxLength":512}
tagIdsarray<string>NoTag IDs; comma-separated GET filter, array in bodies {"minItems":1,"maxItems":100}
tagIds[]stringNo{"minLength":1,"maxLength":512}
tagMatchstringNoTag matching: any or all {"enum":["any","all"]}
noProjectbooleanNoMatch entries without a project
noTagsbooleanNoMatch entries without tags
includeDescendantsbooleanNoInclude descendant tags when filtering
archivedstringNoArchive filter: active, only or all {"enum":["active","only","all"]}
matchstringNoTime matching: overlaps or startsWithin {"enum":["overlaps","startsWithin"]}
textstringNoSearch text; POST avoids putting it in URLs {"maxLength":500}
limitintegerNoPage size; default 100, maximum 500 {"minimum":1,"maximum":500}
cursorstringNoOpaque cursor; return unchanged, do not parse {"maxLength":8192}
timeZonestringYesIANA time zone, for example Asia/Shanghai {"maxLength":128}
periodstringNoReport interval: day, week or month {"enum":["day","week","month"],"default":"day"}
groupBystringNoGrouping: none, project or tag {"enum":["none","project","tag"],"default":"none"}
includeRunningbooleanNoInclude running timers in reports
includeAncestorsbooleanNoInclude ancestor tags in reports
weekStartsOnstringNoFirst day of the week; default monday {"enum":["monday","sunday"]}
Complete JSON Schema
{
  "type": "object",
  "required": [
    "from",
    "to",
    "timeZone"
  ],
  "properties": {
    "fromDate": {
      "type": "string",
      "format": "date",
      "description": "Inclusive filter start date"
    },
    "toDateExclusive": {
      "type": "string",
      "format": "date",
      "description": "Exclusive filter end date"
    },
    "from": {
      "type": "string",
      "format": "date-time",
      "description": "Inclusive start timestamp; provide with to"
    },
    "to": {
      "type": "string",
      "format": "date-time",
      "description": "Exclusive end timestamp; provide with from"
    },
    "state": {
      "type": "string",
      "enum": [
        "running",
        "stopped",
        "invalid"
      ],
      "description": "Entry, job or operation state; meaning depends on the endpoint"
    },
    "projectIds": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 512
      },
      "minItems": 1,
      "maxItems": 100,
      "description": "Project IDs; comma-separated in GET, array in POST"
    },
    "tagIds": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 512
      },
      "minItems": 1,
      "maxItems": 100,
      "description": "Tag IDs; comma-separated GET filter, array in bodies"
    },
    "tagMatch": {
      "type": "string",
      "enum": [
        "any",
        "all"
      ],
      "description": "Tag matching: any or all"
    },
    "noProject": {
      "type": "boolean",
      "description": "Match entries without a project"
    },
    "noTags": {
      "type": "boolean",
      "description": "Match entries without tags"
    },
    "includeDescendants": {
      "type": "boolean",
      "description": "Include descendant tags when filtering"
    },
    "archived": {
      "type": "string",
      "enum": [
        "active",
        "only",
        "all"
      ],
      "description": "Archive filter: active, only or all"
    },
    "match": {
      "type": "string",
      "enum": [
        "overlaps",
        "startsWithin"
      ],
      "description": "Time matching: overlaps or startsWithin"
    },
    "text": {
      "type": "string",
      "maxLength": 500,
      "description": "Search text; POST avoids putting it in URLs"
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 500,
      "description": "Page size; default 100, maximum 500"
    },
    "cursor": {
      "type": "string",
      "maxLength": 8192,
      "description": "Opaque cursor; return unchanged, do not parse"
    },
    "timeZone": {
      "type": "string",
      "maxLength": 128,
      "description": "IANA time zone, for example Asia/Shanghai"
    },
    "period": {
      "type": "string",
      "enum": [
        "day",
        "week",
        "month"
      ],
      "default": "day",
      "description": "Report interval: day, week or month"
    },
    "groupBy": {
      "type": "string",
      "enum": [
        "none",
        "project",
        "tag"
      ],
      "default": "none",
      "description": "Grouping: none, project or tag"
    },
    "includeRunning": {
      "type": "boolean",
      "description": "Include running timers in reports"
    },
    "includeAncestors": {
      "type": "boolean",
      "description": "Include ancestor tags in reports"
    },
    "weekStartsOn": {
      "type": "string",
      "enum": [
        "monday",
        "sunday"
      ],
      "description": "First day of the week; default monday"
    }
  },
  "additionalProperties": false
}

Request example

Replace path and request parameters with actual values. For requests with a body, save it as request.json using the schema above.

curl --fail-with-body --request POST 'https://api.treering.cn/v1/reports/summary' \
  --header "Authorization: Bearer $TREERING_API_TOKEN" \
  --header 'Content-Type: application/json' \
  --data-binary @request.json

Responses

200

Successful response; status depends on the operation result.

application/json

Type: object

FieldTypeRequiredDescription and constraints
totalDurationSecondsnumberYesDeduplicated total duration in seconds
totalEntryCountnumberYesDeduplicated total entry count
bucketsarray<object>YesDate and group buckets
buckets[]objectNo
buckets[].datestringYesDate in the report time zone
buckets[].groupIdstring | nullYesGroup resource ID, or null
buckets[].groupId (anyOf 1)stringNo
buckets[].groupId (anyOf 2)nullNo
buckets[].durationSecondsnumberYesDuration in seconds; may be fractional
buckets[].entryCountnumberYesNumber of entries
evaluatedAtstringYesServer evaluation timestamp
excludedInvalidCountnumberYesNumber of invalid entries excluded
groupingIsAdditivebooleanYesWhether groups can be added without double counting
Complete JSON Schema
{
  "type": "object",
  "required": [
    "totalDurationSeconds",
    "totalEntryCount",
    "buckets",
    "evaluatedAt",
    "excludedInvalidCount",
    "groupingIsAdditive"
  ],
  "properties": {
    "totalDurationSeconds": {
      "type": "number",
      "description": "Deduplicated total duration in seconds"
    },
    "totalEntryCount": {
      "type": "number",
      "description": "Deduplicated total entry count"
    },
    "buckets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "date",
          "groupId",
          "durationSeconds",
          "entryCount"
        ],
        "properties": {
          "date": {
            "type": "string",
            "description": "Date in the report time zone"
          },
          "groupId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Group resource ID, or null"
          },
          "durationSeconds": {
            "type": "number",
            "description": "Duration in seconds; may be fractional"
          },
          "entryCount": {
            "type": "number",
            "description": "Number of entries"
          }
        }
      },
      "description": "Date and group buckets"
    },
    "evaluatedAt": {
      "type": "string",
      "description": "Server evaluation timestamp"
    },
    "excludedInvalidCount": {
      "type": "number",
      "description": "Number of invalid entries excluded"
    },
    "groupingIsAdditive": {
      "type": "boolean",
      "description": "Whether groups can be added without double counting"
    }
  }
}

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

Error response; branch on code.

application/json

Type: object

FieldTypeRequiredDescription and constraints
codestringYesMachine-readable error code
messagestringNoError message; use code for program logic
requestIdstringNoRequest trace identifier
operationIdstringNoRequest receipt identifier; no status polling is needed
Complete JSON Schema
{
  "type": "object",
  "required": [
    "code"
  ],
  "properties": {
    "code": {
      "type": "string",
      "description": "Machine-readable error code"
    },
    "message": {
      "type": "string",
      "description": "Error message; use code for program logic"
    },
    "requestId": {
      "type": "string",
      "description": "Request trace identifier"
    },
    "operationId": {
      "type": "string",
      "description": "Request receipt identifier; no status polling is needed"
    }
  },
  "additionalProperties": true
}

On this page