Skip to main content

A Python SDK for interacting with the Clockify API

Project description

Clockify SDK

A Python SDK for interacting with the Clockify API. This SDK provides a simple and intuitive interface to manage your Clockify workspace, including time entries, projects, tasks, and reports.

Features

  • 🔑 Simple authentication with API key
  • 📊 Manage time entries
  • 📁 Handle projects and tasks
  • 👥 Manage clients and users
  • 🔄 Workspace management
  • ✨ Type hints for better IDE support

Installation

pip install clockify-sdk

Quick Start

First, create a .env file in your project root:

CLOCKIFY_API_KEY=your-api-key
CLOCKIFY_WORKSPACE_ID=your-workspace-id  # Optional, defaults to first workspace

Then use the SDK:

from dotenv import load_dotenv
import os
from clockify_sdk import Clockify
from datetime import datetime

# Load environment variables from .env file
load_dotenv()

# Initialize the client
client = Clockify(
    api_key=os.getenv("CLOCKIFY_API_KEY"),
    workspace_id=os.getenv("CLOCKIFY_WORKSPACE_ID")  # Optional
)

# Get all your workspaces
workspaces = client.get_workspaces()

# Create a new time entry
start_time = datetime.now(timezone.utc)
end_time = datetime.fromisoformat("2024-03-17T11:00:00+00:00")
time_entry = client.time_entries.add_time_entry(
    start=start_time,
    end=end_time,
    description="Working on feature X",
    project_id="project-id"
)

# Get all projects
projects = client.projects.get_all()

# Create a new project
project = client.projects.create({
    "name": "New Project",
    "clientId": "client-id",
    "isPublic": True
})

# Get time entries for a specific date range
time_entries = client.time_entries.get_all(
    user_id=client.user_id,
    start_date="2024-03-01",
    end_date="2024-03-17"
)

# Generate a detailed report
report = client.reports.generate(
    start_date="2024-03-01",
    end_date="2024-03-17",
    project_ids=["project-id-1", "project-id-2"]
)

Advanced Usage

Working with Tasks

# Create a new task
task = client.tasks.create({
    "name": "Implement new feature",
    "assigneeId": "user-id"
}, project_id="project-id")

# Get all tasks for a project
tasks = client.tasks.get_all(project_id="project-id")

Managing Clients

# Create a new client
new_client = client.clients.create({
    "name": "New Client",
    "note": "Important client"
})

# Get all clients
clients = client.clients.get_all()

User Management

# Get current user information
current_user = client.users.get_current_user()

# Get all users in workspace
users = client.users.get_all()

Error Handling

The SDK provides clear error messages and exceptions:

from clockify_sdk.exceptions import ClockifyError

try:
    client.time_entries.create({
        "projectId": "invalid-id",
        "description": "Test entry"
    })
except ClockifyError as e:
    print(f"Error: {e.message}")

Development

  1. Clone the repository:
git clone https://github.com/fraqtory/clockify-sdk.git
cd clockify-sdk
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows, use `.venv\Scripts\activate`
  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest
  1. Run type checking:
mypy clockify_sdk
  1. Run linting:
ruff check .
black .
isort .

Documentation

For detailed documentation, visit https://clockify-sdk.readthedocs.io

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

clockify_sdk-0.2.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clockify_sdk-0.2.2-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file clockify_sdk-0.2.2.tar.gz.

File metadata

  • Download URL: clockify_sdk-0.2.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for clockify_sdk-0.2.2.tar.gz
Algorithm Hash digest
SHA256 aa7058c7ad47be219998197ed13dfff27e04a495c465e0bd59b13fc8736188fc
MD5 52dd6ff5ae8eeadf65d239dab60d8e55
BLAKE2b-256 0599dce30c93e036a5c260132f5888fa63fa7e6355060c25a9e6c6fb6790fa05

See more details on using hashes here.

Provenance

The following attestation bundles were made for clockify_sdk-0.2.2.tar.gz:

Publisher: publish.yml on Fraqtory/clockify-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clockify_sdk-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: clockify_sdk-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for clockify_sdk-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45aa4ac51002ba7150d40231b8027c02c8077c3baeb8059592d8385cf8dcc84b
MD5 5aca302bde4a9f6032581cc65b361539
BLAKE2b-256 2d7ce87f61ed6759a4f7f86197c5183c0d99b7ef0b5aa148a3ca267cb902b715

See more details on using hashes here.

Provenance

The following attestation bundles were made for clockify_sdk-0.2.2-py3-none-any.whl:

Publisher: publish.yml on Fraqtory/clockify-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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