Skip to main content

Library that will give you the opportunity to manipulate your ClickUp data easier.

Project description

PyClickup

PyClickup - little Python library that gives you the opportunity to wrap your ClickUp lists into Python classes. It will give an ability to manipulate (get/create/update) list's data easily.

The greatest benefit of using this library is that you do not need to think about parsing ClickUp's custom fields on your own. All you need to do is to initialize your custom class with all the required fields (see example below).

Initialization

All you need to do is to install the library with your package manager

pip install python-clickup

Getting Started

1. ClickUp auth

First, you must provide a CLICKUP_AUTH_TOKEN environmental variable. You can get your token in yours ClickUp space settings (ClickUp > Settings > My Apps) api-token

After setting CLICKUP_AUTH_TOKEN, you are ready to create your wrappers.

2. ClickUp Space example

Let's create a little ClickUp space with following hierarchy
space-hierarchy

Here is the structure of Employees task
employees-list

and here is Units task
units-list

3. Create List wrappers

To create wrappers for your lists, you need to do the following steps:

  1. Create your list class as subclass of ClickUpList class
  2. Add LIST_ID class variable to your class. (How to get LIST_ID?)
  3. Add required custom fields. Notice, that it is not required to set all the fields from your ClickUp list. You are free to add only useful custom fields.

Here is the example of wrappers that we can create for example space hierarchy

from pyclickup import ClickUpList
from pyclickup.custom_fields import *


class Employees(ClickUpList):
    LIST_ID = <employees list id as int>

    first_name = ShortTextField(field_name="First Name")
    last_name = ShortTextField(field_name="Last Name")
    address = LocationField(field_name="Address")
    salary = CurrencyField(field_name="Current Salary")
    birth_date = DateField(field_name="Date of Birth")
    need_raise = CheckboxField(field_name="Need a raise?")

    # Relations
    units = RelationField("Units", field_name="Units")

class Units(ClickUpList):
    LIST_ID = <units list id as int>    
    
    address = LocationField(field_name="Address")

    # Relations
    employees = RelationField("Employees", field_name="Employees")

As you can see from the example, we have defined 2 classes that represents the structure of our ClickUp Lists. Let's have a closer look at how we define the custom fields for the lists. All the custom fields required field_name field that represents the name of the field in your list. Besides, RelationField requires additional field that stays for name of custom list that you like to relate with.

4. Usage

# Get employee
employee = Employees() # Empty employee
employee = Employees.get_by_id("2hravjh") 
employee = Employees.get_by_name("Sherlock Holmes")

# Get default attributes
employee.id  # 2hravjh
employee.name  # "Sherlock Holmes"
employee.description  # "Great detective"
employee.url  # "https://app.clickup.com/t/2hravjh"

# Set new data
from datetime import datetime 

employee.first_name = "Marry"
employee.last_name = "Sue"
employee.address = "Some new valid address"
employee.salary = 1000
employee.birth_date = datetime(1, 1, 2022)
employee.need_raise = False

employee.update() # To update existed employee (employee.id MUST be provided)
employee.create() # To create new employee

# Adding relations
unit = Units.get_by_name("Unit 1")

employee.units = unit # `unit` MUST be type `Units` as we defined in Employees.units field
employee.update()

# OR

unit.employees = employee
unit.update()

This example does not include all the CustomFields. You can get the list of all the valid fields in pyclickup.custom_fields folder.

FAQ

How to get LIST_ID?

Click on menu button on your list and click Copy link
list-id-steps

Paste link somewhere and extract the LIST_ID
list-id-link

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

python-clickup-1.0.3.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

python_clickup-1.0.3-py3-none-any.whl (26.5 kB view hashes)

Uploaded Python 3

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