Python SDK
What this is: taskadence, a typed client generated from the same contract as this site.
When you need it: any Python that talks to TasKadence — scripts, services, notebooks.
Install
Section titled “Install”pip install taskadence # the Python clientpip install "taskadence[cli]" # the client plus the `tm` command lineYour first call
Section titled “Your first call”The Quickstart creates a token and makes the first call, in Python or any other language.
Lists and pagination
Section titled “Lists and pagination”A list can be long, so the API sends it in pages; looping over the result fetches every page for you.
from taskadence import Taskadence
tm = Taskadence()org_id = tm.me().organizations[0].org_id
page = tm.tasks.list(org_id=org_id, filter={"status": ["in_progress", "blocked"]}, sort_by="due_date", limit=100)print(len(page.data), "on the first page; more follow:", page.next_cursor is not None)for task in page: # every matching task, page after page print(task.task_id, task.title)for p in page.pages(): # or page by page print(len(p.data))filter={key: value} narrows the list (a list of values means "any of these"); an unknown key raises ValueError
naming the allowed ones. A page may be short, or even empty, while more follow; the loop handles it. page.envelope
is the full answer, for the lists that carry totals beside data.
Errors
Section titled “Errors”When the API says no, you get an exception that says why, with the request_id support needs to find it.
from taskadence import InsufficientScopeError, NotFoundError, Taskadence, TaskadenceError
tm = Taskadence()
try: tm.tasks.get("T000000") # an id that does not existexcept NotFoundError as exc: print("not found:", exc.detail)except InsufficientScopeError as exc: print("this token needs", exc.required_scope) # for example tasks:readexcept TaskadenceError as exc: # every other API error print(exc.status, exc.detail, "request_id:", exc.request_id)Every error is a subclass of taskadence.TaskadenceError with .status, .type, .title, .detail, .request_id
and .errors:
| Status | Exceptions |
|---|---|
| 400 | BadRequestError · InvalidParameterError · IdempotencyKeyInvalidError |
| 401 | AuthenticationError · TokenInvalidError · TokenExpiredError · TokenRevokedError |
| 403 | ForbiddenError · InsufficientScopeError · TestTokenReadOnlyError · TokenPolicyError (also 422) |
| 404 · 409 · 410 · 412 | NotFoundError · ConflictError (IdempotencyKeyInFlightError, SprintProjectMismatchError, BillingOwnerMustHandOverError) · GoneError (RemovedInRelease10Error, RemovedInRelease11Error: .successor, .changelog) · PreconditionFailedError |
| 402 | PaymentRequiredError · StorageLimitReachedError (.bytes_used, .included_bytes, .manage_url) |
| 423 | OrganizationSuspendedError · OrganizationRestrictedError · OrganizationReadOnlyError · OrganizationLockedError (all with .state, .since; locked adds .archive_on, .delete_on) |
| 422 | UnprocessableEntityError · ValidationError (InvalidValueError) · IdempotencyKeyReusedError · UrlRefusedError |
| 429 · 5xx | RateLimitedError (.retry_after) · InternalError |
| none | APIConnectionError / APITimeoutError (no answer from the server) · ResponseValidationError (an answer this SDK version cannot read: upgrade) |
The API sends every error as application/problem+json; see
Errors for each type.
pandas
Section titled “pandas”Turn any list into a pandas DataFrame, one row per item, for analysis or a CSV. Needs pip install "taskadence[pandas]".
from taskadence import Taskadence
tm = Taskadence()org_id = tm.me().organizations[0].org_id
frame = tm.tasks.list(org_id=org_id).to_dataframe() # every page; to_dataframe(all_pages=False) for oneprint(frame[["task_id", "title", "status"]].head())Columns keep the API's field names: a nested object becomes dotted columns (type_data.severity), a list becomes one
comma-separated string, *_at columns are timezone-aware datetimes and *_date columns are dates. A saved view
works the same way: tm.views.rows("V123456").to_dataframe(). Without the extra installed you get an ImportError
saying so.
Webhooks
Section titled “Webhooks”A webhook is TasKadence calling your server when something changes (a task is created, a comment is added). These two functions check that a call really came from TasKadence and read it.
from taskadence import webhooks
SECRET = "whsec_your_webhook_secret" # shown when you create the webhook
def receive(headers, raw_body: bytes) -> int: """Call this from your web framework's handler with the request's headers and its raw body.""" if not webhooks.verify(SECRET, headers, raw_body): # the RAW body, not re-serialized JSON return 400 event = webhooks.parse(raw_body) # .id .type_ .org_id .data.resource_id … print(event.type_, event.data.resource_id) # deliveries can repeat: skip an event.id you have seen return 200verify checks the signature (HMAC-SHA256 over id.timestamp.body, the Standard Webhooks scheme), refuses a call
older than 5 minutes (tolerance, in seconds), and accepts two secrets during the 24 hours after you rotate one
(verify([new, old], ...)). raise_on_failure=True raises WebhookVerificationError with the reason instead of
returning False. Events and payloads: Webhooks.
Every method, generated per resource: the API reference shows each operation’s Python call.