Toggl API Client

class toggl2pl.TogglAPIClient(api_token, user_agent)

Bases: object

Initialize a new instance of class object to communicate with Toggl.

Parameters
  • api_token (str) – The unique authentication token to use instead of username and password.

  • user_agent (str) – The required user agent identifier used to gather application usage statistic.

clients(wid)

Wrapper for list_clients() method to convert list of Toggl clients into machine-readable format.

Parameters

wid (int) – The unique Toggl workspace ID to list clients.

Returns

Dictionary object with detailed information about Toggl clients.

Return type

dict

create_client(name, wid)

Create a new client in the particular Toggl workspace.

Parameters
  • name (str) – The client name to create in Toggl workspace.

  • wid (int) – The unique Toggl workspace ID to create client.

Returns

Dictionary object with information about the newly created Toggl client.

Return type

dict

create_project(cid, name, wid)

Create a new client project in the particular Toggl workspace.

Parameters
  • cid (int) – The client ID to associate project with.

  • name (str) – The name to use for a new project.

  • wid (int) – The unique Toggl workspace ID to create project.

Returns

Dictionary object with information about the newly created Toggl project.

Return type

dict

get(endpoint, url='https://toggl.com/api/v8', **kwargs)

Send provided keyword arguments to the combination of Toggl API URL and endpoint using HTTP GET request.

Parameters
  • endpoint (str) – The Toggl API endpoint to send data using HTTP GET request.

  • url (str) – The Toggl API URL to send HTTP GET requests.

  • kwargs – Request parameters specific to each endpoint (please see the official Toggl API reference).

Returns

Dictionary object with Toggl API endpoint response content.

Return type

dict

list_clients(wid)

List clients corresponding to the particular Toggl workspace.

Parameters

wid (int) – The unique Toggl workspace ID to list clients.

Returns

List of dictionaries with clients descriptions.

Return type

list

post(endpoint, url='https://toggl.com/api/v8', **kwargs)

Send provided keyword arguments to the combination of Toggl API URL and endpoint using HTTP POST request.

Parameters
  • endpoint (str) – The Toggl API endpoint to send data using HTTP POST request.

  • url (str) – The Toggl API URL to send HTTP POST requests.

  • kwargs – Request payload specific to each endpoint (please see the official Toggl API reference).

Returns

Dictionary object with Toggl API endpoint response content.

Return type

dict

workspaces(name=None)

List workspaces available for specified API token with optional ability to query single workspace by its name.

Parameters

name (str) – The optional workspace name to filter results.

Returns

Dictionary object which represents single or all workspaces available for specified API token.

Return type

dict