A Python client for CalDAV task servers, with a CLI.
Project description
(Full documentation available at caldavtasksapi.readthedocs.io)
CalDAV-Tasks-API
A Python library and command-line interface (CLI) for interacting with CalDAV task lists (VTODOs). This project provides tools to connect to a CalDAV server, fetch task lists and tasks, create new tasks, and delete existing ones.
Table of Contents
Motivation and Purpose
This library was developed as a foundational component for integrating CalDAV task management with more advanced systems. The primary goal is to serve as a backbone for:
- Synchronizing tasks from applications like the excellent Tasks.org Android app.
- Enabling features such as smart task prioritization using ELO ranking, envisioned to work with a Litoy-like setup.
- Making useful python objects with handy methods to manipulate caldav's tasks.
- Making a CLI interface to manipulate tasks (secondary goal).
By providing a robust Python interface to CalDAV tasks, this project aims to bridge the gap between standard task management and custom, intelligent task processing workflows. The library is intentionally designed to be minimal, with few external dependencies, to ensure it is lightweight and easy to integrate.
Compatibility
The API has been primarily tested with Nextcloud Tasks. However, it is designed to be compatible with any CalDAV server that supports VTODO components.
Testers and feedback for other CalDAV server implementations (e.g., Baïkal, Radicale, Synology Calendar) are highly welcome!
Features
- Connect to CalDAV servers with optional Nextcloud-specific URL adjustments.
- Load task lists (calendars supporting VTODOs).
- Load tasks from specified lists, parsing standard iCalendar properties.
- Preserve and provide access to custom
X-properties. - Create, update, and delete tasks (VTODOs) on the server.
- Access parent and child task relationships (
TaskData.parent_taskandTaskData.child_tasks). - Read-only mode for applications that need to prevent modifications.
- CLI with multiple commands: show summaries, list tasks, add tasks, and list available task lists.
- JSON output support for integration with other tools.
- Environment variable support for credentials and default settings.
Installation
The CalDAV Tasks API can be installed directly from PyPI:
uv pip install caldav-tasks-api
Alternatively, you can install from source:
- Clone the repository:
git clone <repository_url> cd caldav-tasks-api
- Install dependencies (ensure you have
python>=3.8):# Install the package and all dependencies: uv pip install . # For development with editable install: uv pip install -e . # For development with additional dev dependencies: uv pip install -e ".[dev]"
Configuration
The library supports configuration via environment variables:
CALDAV_TASKS_API_URL: CalDAV server URLCALDAV_TASKS_API_USERNAME: CalDAV usernameCALDAV_TASKS_API_PASSWORD: CalDAV passwordCALDAV_TASKS_API_DEFAULT_LIST_UID: Default task list UID for operationsCALDAV_TASKS_API_DEFAULT_PRIORITY: Default priority to use when creating tasksCALDAV_TASKS_API_LOG_LEVEL: Default log level, by defaultWARNING
Usage
Command Line Interface
The package provides several CLI commands:
# Show summary of all task lists and tasks
python -m caldav_tasks_api show-summary
# Show summary with JSON output
python -m caldav_tasks_api show-summary --json
# List available task lists
python -m caldav_tasks_api list-lists
# List latest tasks from a specific list (JSON output)
python -m caldav_tasks_api list-latest-tasks --list-uid <list-uid>
# List latest tasks as human-readable summaries, ordered as in tasks.org
python -m caldav_tasks_api list-latest-tasks --list-uid <list-uid> --simple
# Dump all the tasks of a list as VTODO format
python -m caldav_tasks_api dump-all-tasks --list-uid <list-uid>
# Add a new task
python -m caldav_tasks_api add-task --list-uid <list-uid> --summary "My new task"
# Add a task with additional properties
python -m caldav_tasks_api add-task \
--list-uid <list-uid> \
--summary "Important task" \
--description "Task description" \
--priority 5 \
--due-date 20240315 \
--tag urgent --tag work
All commands support --help for detailed options.
Python API
from caldav_tasks_api import TasksAPI
from caldav_tasks_api.utils.data import TaskData
# Initialize API (credentials from environment or parameters)
api = TasksAPI(
url="https://your-server.com/remote.php/dav/",
username="your-username",
password="your-password",
# include_completed=False, # True by default but loading ALL tasks can be slow
# target_lists=["my frequent list"], # set this to load only a subset of your calendars, faster
)
# Load all task lists and tasks
api.load_remote_data()
# Access task lists
for task_list in api.task_lists:
print(f"List: {task_list.name} ({len(task_list.tasks)} tasks)")
for task in task_list.tasks:
print(f" - {task.summary}")
# Create a new task
new_task = TaskData(
summary="My new task",
list_uid="your-list-uid",
description="Task description",
priority=5
)
created_task = api.add_task(new_task)
# Update a task
task = api.get_task_by_global_uid("task-uid")
if task:
task.summary = "Updated task title"
api.update_task(task)
Contributing
Contributions are welcome! If you'd like to contribute, please feel free to:
- Open an issue to discuss a bug, feature request, or an idea.
- Fork the repository and submit a pull request with your changes.
Please ensure your code follows the existing style and includes tests where appropriate.
Acknowledgements
This project was developed with the assistance of aider.chat, an AI pair programmer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file caldav_tasks_api-1.8.0.tar.gz.
File metadata
- Download URL: caldav_tasks_api-1.8.0.tar.gz
- Upload date:
- Size: 47.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf424c86d9fdf639ac6249c6d1879177a4d12145d8d876d24f1d9d71ebe38d7e
|
|
| MD5 |
152746ca7ee9d4121b08f080a7015524
|
|
| BLAKE2b-256 |
eca52bb2efa6307af16444c50ec8b9bf85690746826d581ae583f1739e5bc036
|
File details
Details for the file caldav_tasks_api-1.8.0-py3-none-any.whl.
File metadata
- Download URL: caldav_tasks_api-1.8.0-py3-none-any.whl
- Upload date:
- Size: 40.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f877d120ecb0910f9ed14a02218323c044191103d619f3358a6af972ca688a64
|
|
| MD5 |
1a85845bc08914e24a1361694ab20194
|
|
| BLAKE2b-256 |
4bab02039b4245c9d91ff529b4ca863fd781c5cc2aac85dc1a6753deb044a58a
|