Toggl is a time tracking web site & service. It provides simple one click time tracking and is supported on most OS platforms and devices. More details here.
Powerbits decided it could make use of the Toggl API and so put together the following sample script on how to access the Toggl API using Powershell.
$user = "01234567890123abcdef012345678912" # <-- enter your token here $pass = "api_token" $pair = "$($user):$($pass)" $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $headers = @{ Authorization = $basicAuthValue } $contentType = "application/json" #Authorisation ############## Invoke-RestMethod -Uri https://www.toggl.com/api/v8/me -Headers $headers -ContentType $contentType #Get Workspaces ############### Invoke-RestMethod -Uri "https://www.toggl.com/api/v8/workspaces" -Headers $headers -ContentType $contentType #Get Users ########## Invoke-RestMethod -Uri "https://www.toggl.com/api/v8/workspaces/123456/users" -Headers $headers -ContentType $contentType # <-- enter your workspace here #Reports Request Parameters ########################### # user_agent: string, required, the name of your application or your email address so we can get in touch in case you're doing something wrong. # workspace_id: integer, required. The workspace whose data you want to access. # since: string, ISO 8601 date (YYYY-MM-DD), by default until - 6 days. # until: string, ISO 8601 date (YYYY-MM-DD), by default today # billable: possible values: yes/no/both, default both # client_ids: client ids separated by a comma, 0 if you want to filter out time entries without a client # project_ids: project ids separated by a comma, 0 if you want to filter out time entries without a project # user_ids: user ids separated by a comma # tag_ids: tag ids separated by a comma, 0 if you want to filter out time entries without a tag # task_ids: task ids separated by a comma, 0 if you want to filter out time entries without a task # time_entry_ids: time entry ids separated by a comma # description: string, time entry description # without_description: true/false, filters out the time entries which do not have a description ('(no description)') # order_field: # - date/description/duration/user in detailed reports # - title/duration/amount in summary reports # - title/day1/day2/day3/day4/day5/day6/day7/week_total in weekly report # order_desc: on/off, on for descending and off for ascending order # distinct_rates: on/off, default off # rounding: on/off, default off, rounds time according to workspace settings # display_hours: decimal/minutes, display hours with minutes or as a decimal number, default minutes #Detail Report #Last 6 days ############## $uriReport = "https://toggl.com/reports/api/v2/[email protected]&workspace_id=123456" # <-- enter your email & workspace here $TogglResponse = Invoke-RestMethod -Uri $uriReport -Headers $headers -ContentType $contentType $responseTotal = $TogglResponse.total_count $pageNum = 1 $DetailReport = @() while ($responseTotal -gt 0) { $TogglResponse = Invoke-RestMethod -Uri $uriReport+"&page="+$pageNum -Headers $headers -ContentType $contentType $TogglResponseData = $TogglResponse.data $DetailReport += $TogglResponseData $responseTotal = $responseTotal - $TogglResponse.per_page $pageNum++ } $DetailReport
Download Powershell Script