Class: TogglClient

TogglClient

new TogglClient(options)

Toggl API client

Name Type Description
options optional

Client options

Members

staticTogglClient.USER_AGENT

User agent string

authData

Result of authentication call

Methods

staticTogglClient.createUser(email, password, timezone, callback)

Create new user

Name Type Description
email string

User e-mail address

password string

User password

timezone string optional

Timezone. UTC by default.

callback function

Accepts arguments: (err, userData)

See:

staticTogglClient.defaultClient(){TogglClient}

Return default API client

staticTogglClient.setDefaults(newDefaults)

Set default settings for client

Name Type Description
newDefaults object

addProjectUser(projectId, userId, options, fields, callback)

Add user to project

Name Type Description
projectId number | string

Project ID

userId number | string

User ID

options object optional

Project user options

fields string[] optional

List of User fields to populate

callback function

Accepts arguments: (err, projectUser)

See:

addProjectUsers(projectId, userIds, options, fields, callback)

Add several users to project

Name Type Description
projectId number | string

Project ID

userIds Array.<number> | Array.<string>

User IDs

options object optional

Project user options

fields string[] optional

List of User fields to populate

callback function

Accepts arguments: (err, projectUsers)

See:

addTimeEntriesTags()

Add time entries tags

See:

authenticate(callback)

Make authentication call only if you use username & password

Name Type Description
callback function optional

Accepts arguments: (err, userData)

See:

changeUserPassword(currentPassword, password, callback)

Change user password

Name Type Description
currentPassword string optional

Current password

password string

New password

callback function

Accepts arguments: (err)

See:

createClient(data, callback)

Create a client

Name Type Description
data object

New client data

callback function

Accepts arguments: (err, clientData)

See:

createProject(data, callback)

Create a project

Name Type Description
data object

New project data

callback function

Accepts arguments: (err, projectData)

See:

createTag(name, workspaceId, callback)

Create tag

Name Type Description
name string

Tag name

workspaceId number | string

Workspace ID

callback function

Accepts arguments: (err, tag)

See:

createTask(name, projectId, data, callback)

Create task

Name Type Description
name string

Task name

projectId number | string

ID of project for what task is created

data object

Task options

callback function

Accepts arguments: (err, task)

See:

createTimeEntry(data, callback)

Create time entry

Name Type Description
data object

Time entry data

callback function

Accepts arguments: (err, timeEntry)

See:

deleteClient(clientId, callback)

Delete client

Name Type Description
clientId number | string

Client ID

callback function

Accepts arguments: (err)

See:

deleteProject(projectId, callback)

Delete project

Name Type Description
projectId number | string

Project ID

callback function

Accepts arguments: (err)

See:

deleteProjects(projectIds, callback)

Delete projects

Name Type Description
projectIds Array.<number> | Array.<string>

Project IDs

callback function

Accepts arguments: (err)

See:

deleteProjectUser(puID, callback)

Delete project user

Name Type Description
puID number | string

Project user ID

callback function

Accepts arguments: (err)

See:

deleteProjectUsers(puIDs, callback)

Delete project users

Name Type Description
puIDs Array.<number> | Array.<string>

Project user IDs

callback function

Accepts arguments: (err)

See:

deleteTag(tagId, callback)

Delete tag

Name Type Description
tagId number | string

Tag Id

callback function

Accepts arguments: (err)

See:

deleteTask(taskId, callback)

Delete task

Name Type Description
taskId number | string

Task ID

callback function

Accepts arguments: (err)

See:

deleteTasks(taskIds, callback)

Delete several tasks

Name Type Description
taskIds Array.<number> | Array.<string>

Task IDs

callback function

Accepts arguments: (err)

See:

deleteTimeEntry(teId, callback)

Delete time entry

Name Type Description
teId number | string

Time entry Id

callback function

Accepts arguments: (err)

See:

deleteWorkspaceUser(wuId, callback)

Delete workspace user

Name Type Description
wuId number | string

Workspace user Id

callback function

Accepts arguments: (err)

See:

destroy()

Call when client is no longer needed

detailedReport(opts, callback)

Get detailed report

Name Type Description
opts object

Request options

callback function

Accepts arguments: (err, report)

See:

getClientData(clientId, callback)

Get client details

Name Type Description
clientId number | string

Client ID

callback function

Accepts arguments: (err, clientData)

See:

getClientProjects(clientId, active, callback)

Get client projects

Name Type Description
clientId number | string

Client ID

active string | boolean

Filter projects: active (true), archived (false), both

callback function

Accepts arguments: (err, projects)

See:

getClients(callback)

Get list of clients

Name Type Description
callback function

Accepts arguments: (err, clients)

See:

getCurrentTimeEntry(callback)

Get current running time entry

Name Type Description
callback function

Accepts arguments: (err, timeEntry)

See:

getProjectData(projectId, callback)

Get project data

Name Type Description
projectId number | string

Project ID

callback function

Accepts arguments: (err, projectData)

See:

getProjectTasks(projectId, callback)

Get project tasks list

Name Type Description
projectId number | string

Project ID

callback function

Accepts arguments: (err, tasks)

See:

getProjectUsers(projectId, callback)

Get project users list

Name Type Description
projectId number | string

Project ID

callback function

Accepts arguments: (err, users)

See:

getTaskData(taskId, callback)

Get task details

Name Type Description
taskId number | string

Task ID

callback function

Accepts arguments: (err, task)

See:

getTimeEntries(startDate, endDate, callback)

Get time entries started in a specific time range

Name Type Description
startDate string | number | Date | moment optional

Date range start

endDate string | number | Date | moment optional

Date range end

callback function

Accepts arguments(err, timeEntries)

See:

getTimeEntryData(teId, callback)

Get time entry details

Name Type Description
teId number | string

Time entry Id

callback function

Accepts arguments: (err, timeEntry)

See:

getUserData(options, callback)

Get user data

Name Type Description
options object

Request options

callback function

Accepts arguments: (err, userData)

See:

getWorkspaceClients(wId, callback)

Get workspace users

Name Type Description
wId number | string

Workspace Id

callback function

Accepts arguments: (err, clients)

See:

getWorkspaceData(wId, callback)

Get workspace data

Name Type Description
wId number | string

Workspace Id

callback function

Accepts arguments: (err, workspace)

See:

getWorkspaceProjects(wId, options, callback)

Get workspace projects

Name Type Description
wId number | string

Workspace Id

options object optional

Request options

callback function

Accepts arguments: (err, projects)

See:

getWorkspaces(callback)

Get data about all workspaces

Name Type Description
callback function

Accepts arguments: (err, workspaces)

See:

getWorkspaceTags(wId, callback)

Get workspace tags

Name Type Description
wId number | string

Workspace Id

callback function

Accepts arguments: (err, tags)

See:

getWorkspaceTasks(wId, options, callback)

Get workspace tasks

Name Type Description
wId number | string

Workspace Id

options object optional

Request options

callback function

Accepts arguments: (err, tasks)

See:

getWorkspaceUsers(wId, actualUsers, callback)

Get workspace users

Name Type Default Description
wId number | string

Workspace Id

actualUsers boolean true optional

Return actual users or 'workspace user' objects

callback function

Accepts arguments: (err, users)

See:

inviteUsers(workspaceId, emails, callback)

Invite users to workspace

Name Type Description
workspaceId number | string

Workspace Id

emails string[]

E-mail addresses

callback function

Accepts arguments: (err, users, notifications)

See:

removeTimeEntriesTags()

Remove time entries tags

See:

resetApiToken(callback)

Reset API token

Name Type Description
callback function

Accepts arguments: (err)

See:

startTimeEntry(data, callback)

Create time entry and start it

Name Type Description
data object

Time entry data

callback function

Accepts arguments: (err, timeEntry)

See:

stopTimeEntry(teId, callback)

Stop time entry

Name Type Description
teId number | string

Time entry Id

callback function

Accepts arguments: (err, timeEntry)

See:

summaryReport(opts, callback)

Get summary report

Name Type Description
opts object

Request options

callback function

Accepts arguments: (err, report)

See:

updateClient(clientId, data, callback)

Update client details

Name Type Description
clientId number | string

Client ID

data object

Client data

callback function

Accepts arguments: (err, clientData)

See:

updateProject(projectId, data, callback)

Update project details

Name Type Description
projectId number | string

project ID

data object

Project data

callback function

Accepts arguments: (err, projectData)

See:

updateProjectUser(puID, options, fields, callback)

Update project user data

Name Type Description
puID number | string

Project user ID

options object

Project user options

fields string[] optional

List of User fields to populate

callback function

Accepts arguments: (err, projectUser)

See:

updateProjectUsers(puIDs, options, fields, callback)

Update data for several project users

Name Type Description
puIDs Array.<number> | Array.<string>

Project user IDs

options object

Project user options

fields string[] optional

List of User fields to populate

callback function

Accepts arguments: (err, projectUsers)

See:

updateTagName(tagId, name, callback)

Update tag name

Name Type Description
tagId number | string

Tag Id

name string

New tag name

callback function

Accepts arguments: (err, tag)

See:

updateTask(taskId, data, fields, callback)

Update task

Name Type Description
taskId number | string

Task ID

data object

Update data

fields string[] optional

Fields to include into output

callback function

Accepts arguments: (err, task)

See:

updateTasks(taskIds, data, fields, callback)

Update tasks

Name Type Description
taskIds Array.<number> | Array.<string>

Task IDs

data object

Update data

fields string[] optional

Fields to include into output

callback function

Accepts arguments: (err, task)

See:

updateTimeEntriesTags(teIds, tags, action, callback)

Update time entries tags

Name Type Description
teIds Array.<number> | Array.<string>

Time entries Ids

tags string[]

Tags to add/remove

action string

'add' or 'remove'

callback function

Accepts arguments: (err, timeEntries)

See:

updateTimeEntry(teId, data, callback)

Update time entry

Name Type Description
teId number | string

Time entry Id

data object

Update data

callback function

Accepts arguments: (err, timeEntry)

See:

updateUserData(data, callback)

Update user data

Name Type Description
data object

Update data

callback function
See:

updateWorkspace(wId, data, callback)

Update workspace data

Name Type Description
wId number | string

Workspace Id

data object

Update data

callback function

Accepts arguments: (err, workspace)

See:

updateWorkspaceUser(wuId, options, callback)

Update workspace user

Name Type Description
wuId number | string

Workspace user Id

options object

Update data

callback function

Accepts arguments: (err, workspaceUser)

See:

weeklyReport(opts, callback)

Get weekly report

Name Type Description
opts object

Request options

callback function

Accepts arguments: (err, report)

See: