| Title: | Client for the 'Toggl Track' API |
|---|---|
| Description: | Read and write time entries, projects and clients of the 'Toggl Track' time tracker <https://toggl.com> from R, and download its reports. Reads never return silently truncated or empty results: HTTP errors are raised, the hourly quota and rate limits are respected, and paginated reports are checked for completeness. |
| Authors: | Vincent Guyader [aut, cre], ThinkR [cph, fnd] |
| Maintainer: | Vincent Guyader <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.0.9000 |
| Built: | 2026-10-14 22:58:13 UTC |
| Source: | https://github.com/ThinkR-open/togglr |
Track time spent in R with the toggl.com timesheet: read and write time entries, projects and clients, and download reports.
vincent <[email protected]>
Useful links:
ask for the toggle api token
ask_toggl_api_token(msg = "toggl api token")ask_toggl_api_token(msg = "toggl api token")
msg |
the message |
Removes the periods stored by 'get_detailled_report(cache = TRUE)'.
clean_cache(cache_dir = toggl_cache_dir())clean_cache(cache_dir = toggl_cache_dir())
cache_dir |
folder of the cache |
## Not run: clean_cache() ## End(Not run)## Not run: clean_cache() ## End(Not run)
Deprecated: togglr no longer memoises. Removes the cache folder of togglr 0.2.x (and the reports cache it contains). Use [clean_cache()].
clean_memoise_cache( memoise_cache_dir = getOption("togglr_memoise_dir", default = rappdirs::user_cache_dir("togglr")) )clean_memoise_cache( memoise_cache_dir = getOption("togglr_memoise_dir", default = rappdirs::user_cache_dir("togglr")) )
memoise_cache_dir |
folder to remove |
## Not run: clean_memoise_cache() ## End(Not run)## Not run: clean_memoise_cache() ## End(Not run)
return client name from client id
client_id_to_name( id, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )client_id_to_name( id, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
id |
client id |
api_token |
the toggl api token |
workspace_id |
workspace id |
the client name
return client id from client name
client_name_to_id( name, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )client_name_to_id( name, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
name |
client name |
api_token |
the toggl api token |
workspace_id |
workspace id |
the client id
tricks to obtain iso 8601
correct_date(time)correct_date(time)
time |
a POSIXt |
time in iso 8601
create a client
create_client( name = "wihtout client", api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )create_client( name = "wihtout client", api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
name |
client name |
api_token |
the toggl api token |
workspace_id |
workspace id |
the created client, as returned by the API (a list with its 'id')
## Not run: get_toggl_api_token()# set your api token here create_client("new client") ## End(Not run)## Not run: get_toggl_api_token()# set your api token here create_client("new client") ## End(Not run)
delete the toggle api token
delete_toggl_api_token()delete_toggl_api_token()
get_all_client_info
get_all_client_info( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )get_all_client_info( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
api_token |
the toggl api token |
workspace_id |
workspace_id |
a data.frame
## Not run: get_all_client_info() ## End(Not run)## Not run: get_all_client_info() ## End(Not run)
get all client's name
get_all_client_names( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )get_all_client_names( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
a date |
until |
a date |
Get all project's names
get_all_project_names( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )get_all_project_names( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
a date |
until |
a date |
get_client_project
get_client_project( id, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )get_client_project( id, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
id |
client id |
api_token |
the toggl api token |
workspace_id |
workspace_id |
the client name
retrieve Rstudio projet if possible
get_context_project()get_context_project()
retrieve current projet id
get_current(api_token = get_toggl_api_token())get_current(api_token = get_toggl_api_token())
api_token |
the toggl api token |
get current duration
get_current_duration(api_token = get_toggl_api_token())get_current_duration(api_token = get_toggl_api_token())
api_token |
the Token API |
a difftime
## Not run: get_current_duration() ## End(Not run)## Not run: get_current_duration() ## End(Not run)
get all task from a project
get_current_project_task_detail( project_name = get_context_project(), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), humain = TRUE )get_current_project_task_detail( project_name = get_context_project(), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), humain = TRUE )
project_name |
project name |
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
a date |
until |
a date |
humain |
boolean humain readable time |
get all data from <https://toggl.com>
get_dashboard( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )get_dashboard( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
begin date |
until |
stop date |
Downloads the time entries of the workspace between 'since' and 'until' (both included) from the reports API v2, all pages included.
get_detailled_report( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), user_agent = toggl_user_agent(), max_page = NULL, cache = FALSE, cache_dir = toggl_cache_dir(), memoise_cache_dir = NULL )get_detailled_report( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), user_agent = toggl_user_agent(), max_page = NULL, cache = FALSE, cache_dir = toggl_cache_dir(), memoise_cache_dir = NULL )
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
begin date (included): a 'Date', a date-time or a text "AAAA-MM-JJ"; one year ago by default |
until |
end date (included), same formats; today by default |
user_agent |
user agent sent to the reports API |
max_page |
deprecated, ignored: the number of pages is now computed from the 'total_count' returned by the API. |
cache |
logical. If 'TRUE', a period fully fetched and checked is stored on disk and returned as is by later calls with the same 'since' / 'until'. Only use it for closed periods: entries created or edited later in Toggl will not be seen. Failures are never cached. Default 'FALSE'. |
cache_dir |
folder of the cache used when 'cache = TRUE': by default 'options("togglr.cache_dir")', or the 'reports' sub-folder of 'rappdirs::user_cache_dir("togglr")' |
memoise_cache_dir |
deprecated, use 'cache_dir' |
Columns: 'id', 'pid', 'tid', 'uid', 'description', 'start', 'end', 'updated' (text, ISO 8601), 'dur' (milliseconds), 'user', 'use_stop', 'client', 'project', 'project_color', 'project_hex_color', 'task', 'billable', 'is_billable', 'cur', 'tags' (list), then any column added by the API.
All the pages of the period are fetched, then the number of distinct entries is checked against the 'total_count' announced by the API. If entries are added, removed or edited while paginating (detected by a change of 'total_count' or of the total duration 'total_grand' returned with each page), the period is fetched again, up to 'options(togglr.report_attempts)' reads in all (3 by default); if the result is still incomplete, an error is raised. An HTTP error (quota, server error, authentication) raises an error too: the function never returns a silently truncated period.
Periods longer than a year (365 days or more between 'since' and 'until', across a new year) are split by calendar year.
a tibble, one row per time entry, with fixed column types (see Details); 0 rows for an empty period
retrieve project id
get_project_id( project_name = get_context_project(), api_token = get_toggl_api_token(), create = FALSE, client = NULL, workspace_id = get_workspace_id(api_token), color = NULL )get_project_id( project_name = get_context_project(), api_token = get_toggl_api_token(), create = FALSE, client = NULL, workspace_id = get_workspace_id(api_token), color = NULL )
project_name |
the project name |
api_token |
the toggl api token |
create |
boolean do you want to create the project if it doesnt exist ? |
client |
client name |
workspace_id |
workspace id |
color |
id of the color selected for the project |
retrieve project id and name
get_project_id_and_name( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )get_project_id_and_name( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
api_token |
the toggl api token |
workspace_id |
workspace id |
get project total time
get_project_total( project_name = get_context_project(), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )get_project_total( project_name = get_context_project(), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today() )
project_name |
project name |
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
a date |
until |
a date |
by user then projet
get_summary_report( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), user_agent = toggl_user_agent(), users = get_workspace_users(api_token = api_token, workspace_id = workspace_id) )get_summary_report( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), user_agent = toggl_user_agent(), users = get_workspace_users(api_token = api_token, workspace_id = workspace_id) )
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
begin date |
until |
stop date |
user_agent |
user_agent |
users |
users |
Get all time entries between 2 dates
get_time_entries( api_token = get_toggl_api_token(), since = Sys.time() - lubridate::weeks(1), until = Sys.time(), workspace_id = get_workspace_id(api_token) )get_time_entries( api_token = get_toggl_api_token(), since = Sys.time() - lubridate::weeks(1), until = Sys.time(), workspace_id = get_workspace_id(api_token) )
api_token |
the toggl api token |
since |
begin date (One week ago by default) |
until |
stop date (Now by defaut) |
workspace_id |
the workspace id (to name the projects) |
a data.frame containing all time entries
## Not run: get_time_entries() ## End(Not run)## Not run: get_time_entries() ## End(Not run)
return the toggle api token
get_toggl_api_token(ask = TRUE)get_toggl_api_token(ask = TRUE)
ask |
booleen do we have to ask if missing |
get weekly report
get_weekly_report( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), user_agent = toggl_user_agent() )get_weekly_report( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), since = toggl_today() %m-% lubridate::years(1), until = toggl_today(), user_agent = toggl_user_agent() )
api_token |
the toggl api token |
workspace_id |
the workspace id |
since |
begin date |
until |
stop date |
user_agent |
user_agent |
Return the workspace id
get_workspace_id(api_token = get_toggl_api_token())get_workspace_id(api_token = get_toggl_api_token())
api_token |
the toggl api token |
Title
get_workspace_users( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )get_workspace_users( api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
api_token |
the toggl api token |
workspace_id |
the workspace id |
show notification using message
notification(title, msg)notification(title, msg)
title |
title of the notificatin |
msg |
content of the notification |
open toggle.com website on timesheet page
open_toggl_website_app()open_toggl_website_app()
open toggle.com website on profile page
open_toggl_website_profile()open_toggl_website_profile()
set the toggle api token
set_toggl_api_token(token)set_toggl_api_token(token)
token |
toggl api token |
Same result as 'jsonlite::fromJSON(simplifyVector = TRUE)' on a list already parsed with 'simplifyVector = FALSE' (what 'httr::content()' returns), using only the public API of jsonlite: the list is serialised back to JSON at full precision, then read with simplification.
simplify(x, ...)simplify(x, ...)
x |
a list, as returned by 'httr::content()' |
... |
passed to 'jsonlite::fromJSON()' (e.g. 'simplifyDataFrame') |
the simplified object
transforme time column into humain readable column
to_humain(df)to_humain(df)
df |
a data.frame |
create a time entry
toggl_create( description = get_context(), start = now(), pid = get_project_id(api_token = api_token, workspace_id = workspace_id), stop, duration, tags = NULL, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )toggl_create( description = get_context(), start = now(), pid = get_project_id(api_token = api_token, workspace_id = workspace_id), stop, duration, tags = NULL, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
description |
the task you did |
start |
time in POSIXt |
pid |
pid |
stop |
time in POSIXt |
duration |
in seconds |
tags |
tags |
api_token |
the toggl api token |
workspace_id |
workspace id |
## Not run: options(toggl_api_token = "XXXXXXXX")# set your toggl api token here toggl_create(duration=1200) toggl_create( description="description", start=now(), pid = get_project_id(project_name = "projectname", create=TRUE,client = "client"), duration=1000, api_token=get_toggl_api_token()) ## End(Not run)## Not run: options(toggl_api_token = "XXXXXXXX")# set your toggl api token here toggl_create(duration=1200) toggl_create( description="description", start=now(), pid = get_project_id(project_name = "projectname", create=TRUE,client = "client"), duration=1000, api_token=get_toggl_api_token()) ## End(Not run)
create a project
toggl_create_project( project_name = get_context_project(), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), client = NULL, private = FALSE, color = NULL, active = TRUE )toggl_create_project( project_name = get_context_project(), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token), client = NULL, private = FALSE, color = NULL, active = TRUE )
project_name |
project name |
api_token |
the toggl api token |
workspace_id |
workspace_id |
client |
client name: an existing client is reused, an unknown one is created; 'NULL' or '""' for no client |
private |
whether project is accessible for only project users or for all workspace users (boolean, default false) |
color |
color of the project, as a hex code (e.g. "#06aaf5") |
active |
boolean set project as active, TRUE by default |
the id of the project (created, or already existing)
## Not run: toggl_create_project() ## End(Not run)## Not run: toggl_create_project() ## End(Not run)
start a task
toggl_start( description = get_context(), client = "without client", project_name = get_context_project(), start = now(), api_token = get_toggl_api_token(), tags = "", workspace_id = get_workspace_id(api_token) )toggl_start( description = get_context(), client = "without client", project_name = get_context_project(), start = now(), api_token = get_toggl_api_token(), tags = "", workspace_id = get_workspace_id(api_token) )
description |
the task you are doing |
client |
client name |
project_name |
nom du projet |
start |
start time in POSIXt |
api_token |
the toggl api token |
tags |
tags |
workspace_id |
workspace id |
## Not run: get_toggl_api_token()# set your api token here toggl_start() ## End(Not run)## Not run: get_toggl_api_token()# set your api token here toggl_start() ## End(Not run)
stop the active task
toggl_stop( current = get_current(api_token = api_token), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )toggl_stop( current = get_current(api_token = api_token), api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
current |
list task id and start time |
api_token |
the toggl api token |
workspace_id |
workspace id |
## Not run: options(toggl_api_token = "XXXXXXXX")# set your api token here toggl_start() toggl_stop() ## End(Not run)## Not run: options(toggl_api_token = "XXXXXXXX")# set your api token here toggl_start() toggl_stop() ## End(Not run)
update time entries
toggl_update_entries( time_entry_ids, description = NULL, start = NULL, pid = NULL, stop = NULL, duration = NULL, tags = NULL, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )toggl_update_entries( time_entry_ids, description = NULL, start = NULL, pid = NULL, stop = NULL, duration = NULL, tags = NULL, api_token = get_toggl_api_token(), workspace_id = get_workspace_id(api_token) )
time_entry_ids |
id(s) of time entries to update: one PUT request is sent per entry |
description |
the task you did |
start |
time in POSIXt |
pid |
project id |
stop |
time in POSIXt |
duration |
in seconds |
tags |
tags |
api_token |
the toggl api token |
workspace_id |
workspace id |
the updated entry, as returned by the API, or a list of them when several ids are given
## Not run: options(toggl_api_token = "XXXXXXXX")# set your toggl api token here time_entry_id <- toggl_create(duration=1200) toggl_update_entries( time_entry_id, description = "new description", duration = 100, tags = c("tag1", "tag2"), api_token=get_toggl_api_token()) ## End(Not run)## Not run: options(toggl_api_token = "XXXXXXXX")# set your toggl api token here time_entry_id <- toggl_create(duration=1200) toggl_update_entries( time_entry_id, description = "new description", duration = 100, tags = c("tag1", "tag2"), api_token=get_toggl_api_token()) ## End(Not run)
update the toggle api token
update_toggl_api_token()update_toggl_api_token()