Skip to main content

The Definitive Python Library For The Toggl API

Project description

PyToggl

The definitive Toggl library for Python.

Currently this library supports all API calls via the self.query and the self.query_report methods. They return the JSON that is documented in the Toggl API documentation.

In addition to the query methods, this library contains quite a few helpful methods and classes for working with Toggl data.

How To Use / Examples

Initialize the Library

from PyToggl import PyToggl
pytoggl = PyToggl('YOUR-API-KEY-HERE')

# Wasn't that easy?

Now do something with it.

# Grab our workspace(s)
workspaces = pytoggl.get_workspaces()

# Now grab all our users for the first workspace
users = pytoggl.get_workspace_users(workspaces[0].id)

Code:

# PyToggl creates objects out of all your query results that use the
# helper methods (ie. get_workspaces and get_workspace_users)

print(users[0].name)

Output:

John Smith

Code:

# The repr is very useful for debugging.
print(users[0])

Output:

class instance>.wid = 12345
class instance>.uid = 543210
class instance>.admin = False
class instance>.avatar_file_name = https://secure.gravatar.com/avatar/87vh8r7h8er7ch8wd7ch9wd7cj9wr7h?d=404&s=200
class instance>.id = 987656789
class instance>.inactive = False
class instance>.at = 2014-09-26T17:54:54+00:00
class instance>.active = True
class instance>.group_ids = [345678]
class instance>.email = johnsmith@notarealdomain.com
class instance>.name = John Smith

Code:

# All objects have a dict property.
print(users[0].dict)

Output:

{'active': True,
'admin': False,
'at': u'2014-09-26T17:54:54+00:00',
'avatar_file_name': u'https://secure.gravatar.com/avatar/87vh8r7h8er7ch8wd7ch9wd7cj9wr7h?d=404&s=200',
'email': u'johnsmith@notarealdomain.com',
'group_ids': [345678],
'id': 987656789,
'inactive': False,
'name': u'John Smith',
'uid': 543210,
'wid': 12345}

Code:

# All objects also have a json property
print(users[0].json)

Output:

'{"wid": 12345, "uid": 543210, "avatar_file_name": "https://secure.gravatar.com/avatar/87vh8r7h8er7ch8wd7ch9wd7cj9wr7h?d=404&s=200", "inactive": false, "at": "2014-09-26T17:54:54+00:00", "active": true, "id": 987656789, "group_ids": [345678], "name": "John Smith", "admin": false, "email": "johnsmith@notarealdomain.com"}'

CHANGES

Version 0.1.0 - 02 October 2014

  • Alpha version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyToggl-0.2.6.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file PyToggl-0.2.6.tar.gz.

File metadata

  • Download URL: PyToggl-0.2.6.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyToggl-0.2.6.tar.gz
Algorithm Hash digest
SHA256 04018e565a9e04e339d98118d93974495be8a909f7899d87022f1c41f4254067
MD5 c4a6bcaa96bc8d54b922a90d2b0dba1a
BLAKE2b-256 e606fe743d00b5987c54ea2b20ad218d77afb2f664f0b1b95853b0c7736e3403

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page