Skip to content

Instantly share code, notes, and snippets.

@nicc777
Created May 11, 2020 14:46
Show Gist options
  • Save nicc777/1c62bd0d9b4535bd3b85bb21876af7ff to your computer and use it in GitHub Desktop.
Save nicc777/1c62bd0d9b4535bd3b85bb21876af7ff to your computer and use it in GitHub Desktop.
Notes around Clockfy API and Python requests

The Clockify API is well documented and uses a straight forward REST API

Here is a quick proof of concept run:

$ export API_KEY="<your-key>"
$ python3
Python 3.7.7 (default, Mar 10 2020, 15:43:33) 
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import requests
>>> import json
>>> url_base = 'https://api.clockify.me/api/v1'
>>> headers = {'X-Api-Key': os.getenv('API_KEY', 'none-set')}
>>> workspaces = requests.get('{}/workspaces'.format(url_base), headers=headers)
>>> workspaces_data = json.loads(workspaces.content.decode('utf-8'))
>>> workspaces_data[0].keys()
dict_keys(['id', 'name', 'hourlyRate', 'memberships', 'workspaceSettings', 'imageUrl', 'featureSubscriptionType'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment