Official Python SDK for the Delega API
Project description
Delega Python SDK
Official Python SDK for the Delega API.
Installation
pip install delega
For async support:
pip install 'delega[async]'
Quick Start
from delega import Delega
client = Delega(api_key="dlg_...")
# List tasks
tasks = client.tasks.list()
# Create a task
task = client.tasks.create("Deploy to production", priority=1, labels=["ops"])
# Complete a task
client.tasks.complete(task.id)
Authentication
Pass your API key directly or set the DELEGA_API_KEY environment variable:
# Explicit
client = Delega(api_key="dlg_...")
# From environment
# export DELEGA_API_KEY=dlg_...
client = Delega()
For self-hosted instances:
client = Delega(api_key="dlg_...", base_url="https://delega.yourcompany.com")
Tasks
# List with filters
tasks = client.tasks.list(priority=1, completed=False)
tasks = client.tasks.list(labels=["urgent"], due_before="2026-12-31")
# Search
tasks = client.tasks.search("deploy")
# CRUD
task = client.tasks.create("Fix bug", description="Crash on login", priority=1)
task = client.tasks.get("task_id")
task = client.tasks.update("task_id", content="Updated title", priority=3)
client.tasks.delete("task_id")
# Completion
client.tasks.complete("task_id")
client.tasks.uncomplete("task_id")
# Delegation
subtask = client.tasks.delegate("parent_task_id", "Research options", priority=2)
# Comments
client.tasks.add_comment("task_id", "Looks good, shipping it")
comments = client.tasks.list_comments("task_id")
Agents
agents = client.agents.list()
agent = client.agents.create("deploy-bot", display_name="Deploy Bot")
print(agent.api_key) # Only available at creation time
client.agents.update(agent.id, description="Handles deployments")
result = client.agents.rotate_key(agent.id)
print(result["api_key"])
client.agents.delete(agent.id)
Projects
projects = client.projects.list()
project = client.projects.create("Backend", emoji="⚙️", color="#3498db")
Webhooks
webhooks = client.webhooks.list()
webhook = client.webhooks.create(
"https://example.com/webhook",
events=["task.created", "task.completed"],
secret="whsec_...",
)
Account
me = client.me() # Get authenticated agent info
usage = client.usage() # Get API usage stats
Async Client
from delega import AsyncDelega
async with AsyncDelega(api_key="dlg_...") as client:
tasks = await client.tasks.list()
task = await client.tasks.create("Async task")
await client.tasks.complete(task.id)
The async client has the same interface as the sync client, but all methods are coroutines. Requires httpx (pip install 'delega[async]').
Error Handling
from delega import DelegaError, DelegaAPIError, DelegaAuthError, DelegaNotFoundError, DelegaRateLimitError
try:
task = client.tasks.get("nonexistent")
except DelegaNotFoundError:
print("Task not found")
except DelegaAuthError:
print("Invalid API key")
except DelegaRateLimitError:
print("Too many requests")
except DelegaAPIError as e:
print(f"API error {e.status_code}: {e.error_message}")
except DelegaError as e:
print(f"SDK error: {e}")
Models
All resource methods return typed dataclasses:
Task- id, content, description, priority, labels, due_date, completed, project_id, parent_id, created_at, updated_atComment- id, task_id, content, created_atAgent- id, name, display_name, description, api_key, created_at, updated_atProject- id, name, emoji, color, created_at, updated_at
License
MIT
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
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 delega-0.1.0.tar.gz.
File metadata
- Download URL: delega-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29f9de1e0c097f009ac9494c2c5f38d3e579b739f82d606792a7eeafbe44e0ac
|
|
| MD5 |
d167984f49906a096068856312e16fed
|
|
| BLAKE2b-256 |
9c9984bcb884441b77b3cfbb2df983c038f3a9248f01245f882598b321b3b325
|
Provenance
The following attestation bundles were made for delega-0.1.0.tar.gz:
Publisher:
publish.yml on delega-dev/delega-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
delega-0.1.0.tar.gz -
Subject digest:
29f9de1e0c097f009ac9494c2c5f38d3e579b739f82d606792a7eeafbe44e0ac - Sigstore transparency entry: 1097149017
- Sigstore integration time:
-
Permalink:
delega-dev/delega-python@be535d0efd0a0e0b06ad739e7d6a0f9d0c781414 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/delega-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@be535d0efd0a0e0b06ad739e7d6a0f9d0c781414 -
Trigger Event:
push
-
Statement type:
File details
Details for the file delega-0.1.0-py3-none-any.whl.
File metadata
- Download URL: delega-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc0540c942de483f595d8c0989cd208d6f5e75619b5f2fae2fb8067e36501326
|
|
| MD5 |
623deedf814d0b69d3ebacfe0482083d
|
|
| BLAKE2b-256 |
969c45471d1c26cd2614ab0f8974532fc66af7d5c6459886b88bd94516eb0a5c
|
Provenance
The following attestation bundles were made for delega-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on delega-dev/delega-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
delega-0.1.0-py3-none-any.whl -
Subject digest:
fc0540c942de483f595d8c0989cd208d6f5e75619b5f2fae2fb8067e36501326 - Sigstore transparency entry: 1097149021
- Sigstore integration time:
-
Permalink:
delega-dev/delega-python@be535d0efd0a0e0b06ad739e7d6a0f9d0c781414 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/delega-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@be535d0efd0a0e0b06ad739e7d6a0f9d0c781414 -
Trigger Event:
push
-
Statement type: