knitr::opts_chunk$set(comment = NA)

library(dplyr)

clockify

CRAN status Codecov test coverage Lifecycle: experimental

An R wrapper around the Clockify API.

The documentation for {clockify} is hosted at https://datawookie.github.io/clockify/.

API Key

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.

Get Started

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(INFO)
log_appender(appender_stdout)
log_layout(layout_glue_generator(format = "{time} — {msg}"))

Workspaces

Retrieve a list of available workspaces.

workspaces()

Select a specific workspace.

workspace("630c61ba9c3a3c3112812332")

Users

Retrieve information on your user profile.

user()

Get a list of users.

users()

Clients

Get a list of clients.

clients()

Projects

Get a list of projects.

projects()

Time Entries

Retrieve Time Entries

Retrieve the time entries for the authenticated user.

time_entries()

Retrieve time entries for another user specified by their user ID.

time_entries(user_id = "630f15d3b59c366b0e3ae2e6")

Insert Time Entry

prepare_cran_entry <- time_entry_create(
  project_id = "630ce53290cfd8789366fd49",
  start = "2021-08-30 08:00:00",
  end = "2021-08-30 10:30:00",
  description = "Prepare for CRAN submission"
)

Check on the ID for this new time entry.

prepare_cran_entry$time_entry_id

Confirm that it has been inserted.

time_entries(concise = FALSE) %>%
  select(time_entry_id, description, time_start, time_end)

Delete Time Entry

time_entry_delete(prepare_cran_entry$time_entry_id)

Confirm that it has been deleted.

time_entries(concise = FALSE) %>%
  select(time_entry_id, description, time_start, time_end)

Endpoints

Endpoints which have currently been implemented in this package. Endpoints which are only available on a paid plan are indicated with a 💰.



datawookie/clockify documentation built on June 6, 2024, 4:39 p.m.