hevslib.toggl module¶
Toggl API Library
TogglPy is a non-cluttered, easily understood and implemented library for interacting with the Toggl API. https://github.com/matthewdowney/TogglPy
-
class
hevslib.toggl.
Endpoints
¶ Bases:
object
Class containing the endpoint URLs for Toggl
-
CLIENTS
= 'https://www.toggl.com/api/v8/clients'¶
-
CURRENT_RUNNING_TIME
= 'https://www.toggl.com/api/v8/time_entries/current'¶
-
PROJECTS
= 'https://www.toggl.com/api/v8/projects'¶
-
REPORT_DETAILED
= 'https://toggl.com/reports/api/v2/details'¶
-
REPORT_SUMMARY
= 'https://toggl.com/reports/api/v2/summary'¶
-
REPORT_WEEKLY
= 'https://toggl.com/reports/api/v2/weekly'¶
-
START_TIME
= 'https://www.toggl.com/api/v8/time_entries/start'¶
-
static
STOP_TIME
(pid)¶
-
TASKS
= 'https://www.toggl.com/api/v8/tasks'¶
-
TIME_ENTRIES
= 'https://www.toggl.com/api/v8/time_entries'¶
-
USER
= 'https://www.toggl.com/api/v8/me'¶
-
WORKSPACES
= 'https://www.toggl.com/api/v8/workspaces'¶
-
-
class
hevslib.toggl.
Toggl
¶ Bases:
object
Class containing the necessities for Toggl interaction
-
createTimeEntry
(hourduration, description=None, projectid=None, projectname=None, taskid=None, clientname=None, year=None, month=None, day=None, hour=None)¶ Creating a custom time entry, minimum must is hour duration and project param :param hourduration: :param description: Sets a descripton for the newly created time entry :param projectid: Not required if projectname given :param projectname: Not required if projectid was given :param taskid: Adds a task to the time entry (Requirement: Toggl Starter or higher) :param clientname: Can speed up project query process :param year: Taken from now() if not provided :param month: Taken from now() if not provided :param day: Taken from now() if not provided :param hour: Taken from now() if not provided :return: response object from post call
-
currentRunningTimeEntry
()¶ Gets the Current Time Entry
-
decodeJSON
(jsonString)¶
-
getClient
(name=None, id=None)¶ return the first workspace that matches a given name or id
-
getClientProject
(clientName, projectName)¶ Fast query given the Client’s name and Project’s name :param clientName: :param projectName: :return:
-
getClientProjects
(id)¶ - Parameters
id – Client ID by which to query
- Returns
Projects object returned from endpoint
-
getClients
()¶ return all clients that are visable to a user
-
getDetailedReport
(data)¶ return a detailed report for a user
-
getDetailedReportCSV
(data, filename=None)¶ save a detailed report as a pdf
-
getDetailedReportPDF
(data, filename)¶ save a detailed report as a pdf
-
getProject
(pid)¶ return all projects that are visable to a user
-
getProjectTasks
(pid, archived=False)¶ return all tasks of a given project :param pid: Project ID :param archived: choose wether to fetch archived tasks or not
-
getSummaryReport
(data)¶ return a summary report for a user
-
getSummaryReportPDF
(data, filename)¶ save a summary report as a pdf
-
getWeeklyReport
(data)¶ return a weekly report for a user
-
getWeeklyReportPDF
(data, filename)¶ save a weekly report as a PDF
-
getWorkspace
(name=None, id=None)¶ return the first workspace that matches a given name or id
-
getWorkspaces
()¶ return all the workspaces for a user
-
headers
= {'Accept': '*/*', 'Authorization': '', 'Content-Type': 'application/json', 'User-Agent': 'python/urllib'}¶
-
postRequest
(endpoint, parameters=None)¶ make a POST request to the toggle api at a certain endpoint and return the RAW page data (usually JSON)
-
putTimeEntry
(parameters)¶
-
request
(endpoint, parameters=None)¶ make a request to the toggle api at a certain endpoint and return the page data as a parsed JSON dict
-
requestRaw
(endpoint, parameters=None)¶ Make a request to the toggle api at a certain endpoint and return the RAW page data (usually JSON)
-
searchClientProject
(name)¶ Provide only a projects name for query and search through entire available names WARNING: Takes a long time!
If client name is known, ‘getClientProject’ would be advised
- Parameters
name – Desired Project’s name
- Returns
Project object
-
setAPIKey
(APIKey)¶ Set the API key in the request header
-
setAuthCredentials
(email, password)¶
-
setUserAgent
(agent)¶ set the User-Agent setting, by default it’s set to TogglPy
-
startTimeEntry
(description, pid)¶ starts a new Time Entry
-
stopTimeEntry
(entryid)¶ Stop the time entry
-
user_agent
= 'TogglPy'¶
-