Time report query


Would it be possible to explain the REST API call sequence for a “Time Report” as listed on the “Reports Page”.  We currently have API calls to get all of the projects, then get all of the issues by project, analyze the issue for time reported in a given date range.  This approach (while it works) seems very inefficient.  Does the “Time Report” utilize a specific endpoint? (maybe we are missing something?)

1 comment
Official comment

Hi Robert,

This is Julia from YouTrack Support.

There is a special endpoint for working with various reports in your instance: /api/reports. You can use it to retrieve the data from an existing report, just make sure to explicitly query all the needed fields. For example, for the simplest time report that groups data by work item author, you can use this query: /api/reports/{$reportId}?fields=data(groups(meta(linkedUser(visibleName)),totalDuration(value)). The report ID can be obtained from its URL, e.g. https://example.youtrack.cloud/reports/time/123-4 means you should use 123-4 as the report ID.

You will also need to trigger report recalculation to make sure you have the latest data. You can do it by posting this to /api/reports/{$reportId}/status:

    "calculationInProgress": true,
    "$type": "ReportStatus"

And to determine whether the recalculation is over, query /api/reports/{$reportId}/status?fields=calculationInProgress.

To find more information on the available fields and report-related requests, you can try inspecting the network requests in the browser dev console.

Let me know if you have any questions!

Please sign in to leave a comment.