DansBananaLoafcake
DansBananaLoafcake

Reputation: 31

Clockify Api - get hours for each user for the last 24 hours

Hi I was wondering if you could help me.

What would be the right endpoint to get a report for hours logged for each user in a given workspace the past 24 hours? The API doesn't make it clear which report to use and what values to supply in a post request to get this result.

Excuse me if I seem a little naive about the capabilities, I have been asked to look at this without prior knowledge of the API and I'm just trying to get me head around it.

Upvotes: 0

Views: 1181

Answers (1)

Paul Wellner Bou
Paul Wellner Bou

Reputation: 554

Clockify just seem to have shut down their old api (I was using). The report API is documented here: https://clockify.me/developers-api#tag-Reports

And this works quite well. For your case, the requests could look like:

curl --request POST \
  --url https://reports.api.clockify.me/v1/workspaces/<YOUR WORKSPACE>/reports/summary \
  --header 'content-type: application/json' \
  --header 'x-api-key: <YOUR API KEY>' \
  --data '{
  "dateRangeStart": "2020-08-13T00:00:00.000Z",
  "dateRangeEnd": "2020-08-13T23:59:59.000Z",
    "summaryFilter": {"groups": ["USER"]},
    "exportType": "JSON"
}'

There is no "last 24h" though, you will have to adjust the dates yourself.

What might be interesting for your case:

  • This example just returns all durations by user. If you want all time entries explicitely, add TIMEENTRY as summary group:
    "groups": ["USER", "TIMEENTRY"]
  • You can also export it to a different format: JSON, CSV, XLSX, PDF are supported.

Upvotes: 1

Related Questions