Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Clockify/Clockify_Get_all_projects_on_workspace.ipynb
2973 views
Kernel: Python 3

Clockify.png

Clockify - Get all projects on workspace

Give Feedback | Bug report

Tags: #clockify #api #projects #workspace #get #python

Last update: 2023-05-17 (Created: 2023-04-05)

Description: This notebook will show how to get all projects on a workspace using the Clockify API and return a dict.

Input

Import libraries

import requests import naas from pprint import pprint

Setup Variables

api_key = naas.secret.get("CLOCKIFY_API_KEY") or "YOUR_API_KEY" workspace_id = "626f9e3b36c2670314c0386e" #"<WORKSPACE_ID>"

Model

Get all projects on workspace

This function will get all projects on a workspace using the Clockify API.

def get_projects(api_key, workspace_id): url = f"https://api.clockify.me/api/v1/workspaces/{workspace_id}/projects" headers = {"X-Api-Key": api_key} response = requests.get(url, headers=headers) return response.json() projects = get_projects(api_key, workspace_id)

Output

Display result

print("Projects found:", len(projects), "\n") for project in projects: print("-", project["name"], f'(id: {project["id"]})') if len(projects) > 0: print() pprint(projects[0])