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
.
CLOCKIFY_API_KEY = Sys.getenv("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.
# A tibble: 2 × 2
workspace_id name
<chr> <chr>
1 5ef46294df73063139f60bfc Fathom Data
2 61343c45ab05e02be2c8c1fd Personal
Select a specific workspace.
workspace("61343c45ab05e02be2c8c1fd")
Retrieve information on your user profile.
user()
2021-09-10 17:33:04 — GET /user
# A tibble: 1 × 3
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew ACTIVE
Get a list of users.
users()
Get a list of projects.
projects()
2021-09-10 17:33:04 — GET /workspaces/61343c45ab05e02be2c8c1fd/projects
2021-09-10 17:33:04 — Page contains 2 results.
2021-09-10 17:33:04 — GET /workspaces/61343c45ab05e02be2c8c1fd/projects
2021-09-10 17:33:04 — Page is empty.
2021-09-10 17:33:04 — 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.
2021-09-10 17:33:05 — GET /user
2021-09-10 17:33:05 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-10 17:33:05 — Page contains 8 results.
2021-09-10 17:33:05 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-10 17:33:05 — Page is empty.
2021-09-10 17:33:05 — API returned 8 results.
# A tibble: 8 × 4
id project_id description duration
<chr> <chr> <chr> <dbl>
1 61343cc1777d5361dcdea70a 61343c9ba15c1d53ad33369f Set up GitHub Acti… 12
2 61343d06777d5361dcdea729 61343c9ba15c1d53ad33369f Make coffee 5
3 61343d27ab05e02be2c8c266 61343c9ba15c1d53ad33369f Populate README.Rmd 68
4 613448d7777d5361dcdead37 61343c9ba15c1d53ad33369f Add GET /workspace… 12.0
5 61344bcad01d3b4a27a82310 61343c9ba15c1d53ad33369f Add GET /workspace… 31.8
6 6134548f00dc8f48962bace7 6134506c777d5361dcdeb3b5 Add GET /ticker/{s… 16.0
7 6134585a777d5361dcdebc5c 6134506c777d5361dcdeb3b5 Add GET /tickers/{… 16.5
8 61345c45d01d3b4a27a833c7 6134506c777d5361dcdeb3b5 Add GET /last_pric… 31.6
Retrieve time entries for another user specified by their user ID.
time_entries(user_id = "5ef46293df73063139f60bf5")
2021-09-10 17:33:05 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5ef46293df73063139f60bf5/time-entries
2021-09-10 17:33:05 — Page contains 2 results.
2021-09-10 17:33:05 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5ef46293df73063139f60bf5/time-entries
2021-09-10 17:33:05 — Page is empty.
2021-09-10 17:33:05 — 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
prepare_cran_id <- time_entry_insert(
project_id = "61343c9ba15c1d53ad33369f",
start = "2021-08-30 08:00:00",
end = "2021-08-30 10:30:00",
description = "Prepare for CRAN submission"
)
2021-09-10 17:33:05 — Insert time entry.
2021-09-10 17:33:05 — POST /workspaces/61343c45ab05e02be2c8c1fd/time-entries
Check on the ID for this new time entry.
prepare_cran_id
Confirm that it has been inserted.
time_entries(concise = FALSE) %>%
select(id, description, time_start, time_end)
2021-09-10 17:33:05 — GET /user
2021-09-10 17:33:05 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-10 17:33:06 — Page contains 9 results.
2021-09-10 17:33:06 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-10 17:33:06 — Page is empty.
2021-09-10 17:33:06 — API returned 9 results.
# A tibble: 9 × 4
id description time_start time_end
<chr> <chr> <dttm> <dttm>
1 613b96d15fed1049e3dfedc7 Prepare for … 2021-08-30 08:00:00 2021-08-30 10:30:00
2 61343cc1777d5361dcdea70a Set up GitHu… 2021-09-03 05:15:00 2021-09-03 05:27:00
3 61343d06777d5361dcdea729 Make coffee 2021-09-03 05:27:00 2021-09-03 05:32:00
4 61343d27ab05e02be2c8c266 Populate REA… 2021-09-03 05:45:00 2021-09-03 06:53:00
5 613448d7777d5361dcdead37 Add GET /wor… 2021-09-05 04:34:31 2021-09-05 04:46:30
6 61344bcad01d3b4a27a82310 Add GET /wor… 2021-09-05 04:47:06 2021-09-05 05:18:56
7 6134548f00dc8f48962bace7 Add GET /tic… 2021-09-05 05:24:30 2021-09-05 05:40:29
8 6134585a777d5361dcdebc5c Add GET /tic… 2021-09-05 05:40:42 2021-09-05 05:57:13
9 61345c45d01d3b4a27a833c7 Add GET /las… 2021-09-05 05:57:25 2021-09-05 06:29:01
time_entry_delete(prepare_cran_id)
2021-09-10 17:33:06 — Delete time entry.
2021-09-10 17:33:06 — DELETE /workspaces/61343c45ab05e02be2c8c1fd/time-entries/613b96d15fed1049e3dfedc7
[1] TRUE
Confirm that it has been deleted.
time_entries(concise = FALSE) %>%
select(id, description, time_start, time_end)
2021-09-10 17:33:06 — GET /user
2021-09-10 17:33:06 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-10 17:33:06 — Page contains 8 results.
2021-09-10 17:33:06 — GET /workspaces/61343c45ab05e02be2c8c1fd/user/5f227e0cd7176a0e6e754409/time-entries
2021-09-10 17:33:06 — Page is empty.
2021-09-10 17:33:06 — API returned 8 results.
# A tibble: 8 × 4
id description time_start time_end
<chr> <chr> <dttm> <dttm>
1 61343cc1777d5361dcdea70a Set up GitHu… 2021-09-03 05:15:00 2021-09-03 05:27:00
2 61343d06777d5361dcdea729 Make coffee 2021-09-03 05:27:00 2021-09-03 05:32:00
3 61343d27ab05e02be2c8c266 Populate REA… 2021-09-03 05:45:00 2021-09-03 06:53:00
4 613448d7777d5361dcdead37 Add GET /wor… 2021-09-05 04:34:31 2021-09-05 04:46:30
5 61344bcad01d3b4a27a82310 Add GET /wor… 2021-09-05 04:47:06 2021-09-05 05:18:56
6 6134548f00dc8f48962bace7 Add GET /tic… 2021-09-05 05:24:30 2021-09-05 05:40:29
7 6134585a777d5361dcdebc5c Add GET /tic… 2021-09-05 05:40:42 2021-09-05 05:57:13
8 61345c45d01d3b4a27a833c7 Add GET /las… 2021-09-05 05:57:25 2021-09-05 06:29:01
Endpoints which have currently been implemented in this package.