An R wrapper around the Clockify API.
The documentation for {clockify}
is hosted at https://datawookie.github.io/clockify/.
You’re going to need to have an API key from your Clockify account. If you don’t yet have an account, create one. Then retrieve the API key from the account settings.
The first thing you’ll need to do is set up your API key. I store
mine in an environment variable called
CLOCKIFY_API_KEY
.
= Sys.getenv("CLOCKIFY_API_KEY") CLOCKIFY_API_KEY
Now load the {clockify}
package and specify the API
key.
library(clockify)
set_api_key(CLOCKIFY_API_KEY)
Let’s turn on some logging so we can see what’s happening behind the scenes.
library(logger)
log_threshold(DEBUG)
Retrieve a list of available workspaces.
workspaces()
2021-09-09 07:16:33 — GET /workspaces
# A tibble: 2 × 2
workspace_id name
<chr> <chr>
1 5ef46294df73063139f60bfc Fathom Data
2 61343c45ab05e02be2c8c1fd Personal
Select a specific workspace.
workspace("61343c45ab05e02be2c8c1fd")
2021-09-09 07:16:33 — Set active workspace -> 61343c45ab05e02be2c8c1fd.
[1] "61343c45ab05e02be2c8c1fd"
Retrieve information on your user profile.
user()
2021-09-09 07:16:33 — GET /user
# A tibble: 1 × 3
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew ACTIVE
Get a list of users.
users()
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/users
# A tibble: 2 × 3
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew ACTIVE
2 5ef46293df73063139f60bf5 Emma ACTIVE
Get a list of clients.
clients()
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/clients
# A tibble: 2 × 3
client_id workspace_id client_name
<chr> <chr> <chr>
1 61343c6c00dc8f48962b9be9 61343c45ab05e02be2c8c1fd Community
2 61343c5d00dc8f48962b9be3 61343c45ab05e02be2c8c1fd Fathom Data
Get a list of projects.
projects()
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/projects
2021-09-09 07:16:34 — Page contains 2 results.
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/projects
2021-09-09 07:16:34 — Page is empty.
2021-09-09 07:16:34 — API returned 2 results.
# A tibble: 2 × 4
project_id project_name client_id billable
<chr> <chr> <chr> <lgl>
1 6134506c777d5361dcdeb3b5 {cex} 61343c5d00dc8f48962b9be3 TRUE
2 61343c9ba15c1d53ad33369f {clockify} 61343c5d00dc8f48962b9be3 FALSE
Retrieve the time entries for the authenticated user.
time_entries()
2021-09-09 07:16:34 — GET /user
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-09 07:16:34 — Page contains 8 results.
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-09 07:16:34 — Page is empty.
2021-09-09 07:16:34 — API returned 8 results.
# A tibble: 8 × 4
id project_id
<chr> <chr>
1 61343cc1777d5361dcdea70a 61343c9ba15c1d53ad33369f
2 61343d06777d5361dcdea729 61343c9ba15c1d53ad33369f
3 61343d27ab05e02be2c8c266 61343c9ba15c1d53ad33369f
4 613448d7777d5361dcdead37 61343c9ba15c1d53ad33369f
5 61344bcad01d3b4a27a82310 61343c9ba15c1d53ad33369f
6 6134548f00dc8f48962bace7 6134506c777d5361dcdeb3b5
7 6134585a777d5361dcdebc5c 6134506c777d5361dcdeb3b5
8 61345c45d01d3b4a27a833c7 6134506c777d5361dcdeb3b5
description duration
<chr> <dbl>
1 Setting up GitHub Actions 12
2 Make coffee 5
3 Populate README.Rmd 68
4 Add GET /workspaces/{workspaceId}/projects/{projectId} 12.0
5 Add GET /workspaces/{workspaceId}/projects/{projectId}/tasks 31.8
6 Add GET https://cex.io/api/ticker/{symbol1}/{symbol2} 16.0
7 Add GET https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{symbolN} 16.5
8 Add GET https://cex.io/api/last_price/{symbol1}/{symbol2} 31.6
Retrieve time entries for another user specified by their user ID.
time_entries(user_id = "5ef46293df73063139f60bf5")
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5ef46293df73063139f60bf5/time-entries
2021-09-09 07:16:34 — Page contains 2 results.
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5ef46293df73063139f60bf5/time-entries
2021-09-09 07:16:34 — Page is empty.
2021-09-09 07:16:34 — API returned 2 results.
# A tibble: 2 × 4
id project_id description duration
<chr> <chr> <chr> <dbl>
1 613630ebba4b374e57155a72 61343c9ba15c1d53ad33369f Another test entry 87
2 613630cb89516b1767a56a08 61343c9ba15c1d53ad33369f Creating hex logo 45.4
<- time_entry_insert(
prepare_cran_id project_id = "61343c9ba15c1d53ad33369f",
start = "2021-08-30 08:00:00",
end = "2021-08-30 10:30:00",
description = "Prepare for CRAN submission"
)
2021-09-09 07:16:34 — Insert time entry.
2021-09-09 07:16:34 — POST /workspaces/61343c45ab05e02be2c8c1fd/time-entries
Check on the ID for this new time entry.
prepare_cran_id
[1] "6139a6c2dacb7878935d87ba"
Confirm that it has been inserted.
time_entries(concise = FALSE) %>%
select(id, description, time_start, time_end)
2021-09-09 07:16:34 — GET /user
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-09 07:16:34 — Page contains 9 results.
2021-09-09 07:16:34 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-09 07:16:34 — Page is empty.
2021-09-09 07:16:34 — API returned 9 results.
# A tibble: 9 × 4
id
<chr>
1 6139a6c2dacb7878935d87ba
2 61343cc1777d5361dcdea70a
3 61343d06777d5361dcdea729
4 61343d27ab05e02be2c8c266
5 613448d7777d5361dcdead37
6 61344bcad01d3b4a27a82310
7 6134548f00dc8f48962bace7
8 6134585a777d5361dcdebc5c
9 61345c45d01d3b4a27a833c7
description
<chr>
1 Prepare for CRAN submission
2 Setting up GitHub Actions
3 Make coffee
4 Populate README.Rmd
5 Add GET /workspaces/{workspaceId}/projects/{projectId}
6 Add GET /workspaces/{workspaceId}/projects/{projectId}/tasks
7 Add GET https://cex.io/api/ticker/{symbol1}/{symbol2}
8 Add GET https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{symbolN}
9 Add GET https://cex.io/api/last_price/{symbol1}/{symbol2}
time_start time_end
<dttm> <dttm>
1 2021-08-30 09:00:00 2021-08-30 11:30:00
2 2021-09-03 06:15:00 2021-09-03 06:27:00
3 2021-09-03 06:27:00 2021-09-03 06:32:00
4 2021-09-03 06:45:00 2021-09-03 07:53:00
5 2021-09-05 05:34:31 2021-09-05 05:46:30
6 2021-09-05 05:47:06 2021-09-05 06:18:56
7 2021-09-05 06:24:30 2021-09-05 06:40:29
8 2021-09-05 06:40:42 2021-09-05 06:57:13
9 2021-09-05 06:57:25 2021-09-05 07:29:01
time_entry_delete(prepare_cran_id)
2021-09-09 07:16:35 — Delete time entry.
2021-09-09 07:16:35 — DELETE /workspaces/61343c45ab05e02be2c8c1fd/time-entries/6139a6c2dacb7878935d87ba
[1] TRUE
Confirm that it has been deleted.
time_entries(concise = FALSE) %>%
select(id, description, time_start, time_end)
2021-09-09 07:16:35 — GET /user
2021-09-09 07:16:35 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-09 07:16:35 — Page contains 8 results.
2021-09-09 07:16:35 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-09 07:16:35 — Page is empty.
2021-09-09 07:16:35 — API returned 8 results.
# A tibble: 8 × 4
id
<chr>
1 61343cc1777d5361dcdea70a
2 61343d06777d5361dcdea729
3 61343d27ab05e02be2c8c266
4 613448d7777d5361dcdead37
5 61344bcad01d3b4a27a82310
6 6134548f00dc8f48962bace7
7 6134585a777d5361dcdebc5c
8 61345c45d01d3b4a27a833c7
description
<chr>
1 Setting up GitHub Actions
2 Make coffee
3 Populate README.Rmd
4 Add GET /workspaces/{workspaceId}/projects/{projectId}
5 Add GET /workspaces/{workspaceId}/projects/{projectId}/tasks
6 Add GET https://cex.io/api/ticker/{symbol1}/{symbol2}
7 Add GET https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{symbolN}
8 Add GET https://cex.io/api/last_price/{symbol1}/{symbol2}
time_start time_end
<dttm> <dttm>
1 2021-09-03 06:15:00 2021-09-03 06:27:00
2 2021-09-03 06:27:00 2021-09-03 06:32:00
3 2021-09-03 06:45:00 2021-09-03 07:53:00
4 2021-09-05 05:34:31 2021-09-05 05:46:30
5 2021-09-05 05:47:06 2021-09-05 06:18:56
6 2021-09-05 06:24:30 2021-09-05 06:40:29
7 2021-09-05 06:40:42 2021-09-05 06:57:13
8 2021-09-05 06:57:25 2021-09-05 07:29:01
Endpoints which have currently been implemented in this package.