Toggl API Client¶
-
class
toggl2pl.TogglAPIClient(api_token, user_agent)¶ Bases:
objectInitialize 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(workspace)¶ Wrapper for list_clients method to convert list of Toggl clients into machine-readable format.
- Parameters
workspace (dict) – Dictionary object which represents Toggl workspace.
- Returns
Dictionary object with detailed information about Toggl clients.
- Return type
dict
-
create_client(name, workspace)¶ Create new client entity in corresponding Toggl workspace.
- Parameters
name (str) – The name of new Toggl client to create.
workspace (dict) – Dictionary object which represents Toggl workspace.
- 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 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(workspace)¶ List clients corresponding to the particular Toggl workspace.
- Parameters
workspace (dict) – Dictionary object which represents Toggl workspace.
- 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='')¶ 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