Import Clockify Data to Google Sheets
In this guide, we’ll walk through how to pull data from the Clockify API directly into Google Sheets, using the API Connector add-on for Sheets.
Contents
- Before You Begin
- Part 1: Get Your Clockify API Key
- Part 2: Pull Clockify API Data into Sheets
- Part 3: Handle Pagination
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get Your Clockify API Key
- Log in to Clockify.me and click Settings in the left-hand sidebar
- Scroll down to the API section and click Generate
- You should now see your key. Keep it handy as you'll need it in a moment. Congrats! You're now ready to use the Clockify API.
Part 2: Pull Clockify API Data into Sheets
Example #1
For this first example, we'll get a list of our available workspaces, since we'll need the workspace IDs for subsequent requests.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following:
- Application:
Custom
- Method:
GET
- Request URL:
https://api.clockify.me/api/v1/workspaces
- Headers
x-api-key
:your_api_key
- Application:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see data populate your sheet.
Note the workspace IDs returned in column A, and the user Ids in column G.
Example #2
We'll now fetch a detailed time report. Substitute in the workspace ID where it says your_workspace_id
.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following:
- Application:
Custom
- Method:
POST
- Request URL:
https://reports.api.clockify.me/v1/workspaces/your_workspace_id/reports/detailed
- Headers
x-api-key
:your_api_key
Content-type
:application/json
- Request body:
{"dateRangeStart":"2023-08-01T00:00:00.000Z","dateRangeEnd":"2023-08-31T23:59:59.000Z","detailedFilter":{"page":1,"pageSize":1000,"options":{"totals":"EXCLUDE"}}}
- Application:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run.
Part 3: Handle Pagination
Clockify limits the number of records at a time based on the pageSize parameter. To get more, we'll need to paginate through multiple pages of data. The pagination type depends on the endpoint:
Report endpoints
Fetching data from the /reports/detailed
, /reports/summary
, or /reports/weekly
endpoints requires paginating with parameters in the request body:
- Type:
page parameter body
- Page body parameter:
detailedFilter.page
- Run until: choose when to stop running the request
Other endpoints
Other endpoints paginate through the request URL, and can use API Connector's "page parameter" pagination type like this:
- Pagination type:
page parameter
- Page parameter:
page
- Run until:
choose when to stop fetching data
Part 4: API Documentation
Official API documentation: https://docs.clockify.me/