Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Added

- `AsyncClient` with identical API surface to sync `Client` (22 async methods across 3 resource namespaces)
- Retry with exponential backoff for transient errors (408, 429, 5xx) with `retry-after`/`retry-after-ms` header support, configurable `max_retries` (default 2)
- SSE streaming client for session channels (`ChannelClient`, `AsyncChannelClient`) with W3C-compliant inline parser, `Last-Event-ID` reconnection, and typed `Stream[T]`/`AsyncStream[T]` wrappers
- 3 streaming exception classes: `StreamingError`, `SessionClosedError`, `SessionExpiredError`
- Tier 2 Pydantic v2 models across 6 domains: sessions (8 types), batches (6 types), waitpoints (8 types), webhooks (26 types), bulk actions (14 types), errors (7 types), plus 2 shared types
- **Sessions** resource client: create, list, retrieve, update, close
- **Batches** resource client: retrieve, results
- **Waitpoints** resource client: create_token, list_tokens, complete_token_callback (unauthenticated), complete_token, retrieve_token
- **Webhooks** resource client: list/retrieve/enable/disable endpoints, rotate/set secrets, create/cancel waiters, list/retrieve/replay deliveries
- **Bulk Actions** resource client: list, create (discriminated union body), retrieve, abort
- **Errors** resource client: list, retrieve, resolve, ignore, unresolve
- `auth_required` parameter on `_request` for unauthenticated endpoint support (waitpoint callbacks)
- `scripts/ci-local.sh` for local CI parity with drift detection
- ADR-004: Streaming/SSE client design

## [0.1.0] - 2026-11-30

Initial release of the Trigger.dev Python SDK.
Expand All @@ -21,4 +40,5 @@ Initial release of the Trigger.dev Python SDK.
- 101 unit tests across client, exceptions, and all resource endpoints
- `py.typed` marker for PEP 561 compliance

[Unreleased]: https://github.com/mehmetkr/triggerdev-python/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/mehmetkr/triggerdev-python/releases/tag/v0.1.0
123 changes: 116 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/mehmetkr/triggerdev-python/blob/main/LICENSE)

The first fully typed Python SDK for the [Trigger.dev](https://trigger.dev) management API. Built with Pydantic models generated from the OpenAPI spec, covering tasks, runs, and schedules.
The first fully typed Python SDK for the [Trigger.dev](https://trigger.dev) management API. Built with Pydantic v2 models generated from the OpenAPI spec, covering 54 operations across 9 resource domains with both sync and async clients.

## Installation

Expand Down Expand Up @@ -45,6 +45,22 @@ You can also pass the API key explicitly:
client = Client(api_key="tr_dev_sk_...")
```

## Async support

Every method is available on both the sync `Client` and the `AsyncClient`:

```python
import asyncio
from triggerdev import AsyncClient

async def main():
async with AsyncClient() as client:
result = await client.tasks.trigger("my-task", payload={"user_id": 42})
print(result.id)

asyncio.run(main())
```

## Features

### Trigger tasks
Expand Down Expand Up @@ -85,24 +101,95 @@ with Client() as client:
from triggerdev import Client

with Client() as client:
# Create a recurring schedule
schedule = client.schedules.create(
task="daily-report",
cron="0 9 * * *",
deduplication_key="daily-report-prod",
timezone="America/New_York",
)
print(schedule.id)
```

### Sessions

```python
from triggerdev import Client
from triggerdev.types.sessions import CreateSessionRequestBody

with Client() as client:
# Create a session
session = client.sessions.create(
body=CreateSessionRequestBody(
task_identifier="my-task",
payload={"key": "value"},
),
)
print(session.run_id)

# List sessions with filters
result = client.sessions.list(status=["RUNNING"], page_size=10)
for s in result.data:
print(f"{s.id}: {s.type}")
```

# List all schedules
schedules = client.schedules.list()
for s in schedules.data:
print(f"{s.task}: {s.generator.expression}")
### Webhooks

```python
from triggerdev import Client

with Client() as client:
# List webhook endpoints
endpoints = client.webhooks.list_endpoints()
for ep in endpoints.data:
print(f"{ep.id}: {ep.status}")

# List deliveries with status filter
deliveries = client.webhooks.list_deliveries(status=["FAILED"])
for d in deliveries.data:
print(f"{d.id}: {d.status}")

# Replay a failed delivery
client.webhooks.replay_delivery(delivery_id="del_123")
```

### Errors

```python
from triggerdev import Client

with Client() as client:
# List errors for a task
result = client.errors.list(task_identifier=["my-task"])
for error in result.data:
print(f"{error.fingerprint}: {error.error_message} ({error.count}x)")

# Resolve an error
client.errors.resolve(error_id="err_123")
```

### Bulk actions

```python
from triggerdev import Client
from triggerdev.types.bulk_actions import BulkActionFilter, CancelByFilterBody

with Client() as client:
# Cancel runs matching a filter
action = client.bulk_actions.create(
body=CancelByFilterBody(
action="cancel",
filter=BulkActionFilter(
task_identifier="my-task",
status="QUEUED",
),
),
)
print(f"Bulk action created: {action.id}")
```

### Error handling

Every API error maps to a typed exception:
Every API error maps to a typed exception with automatic retries on transient failures:

```python
from triggerdev import Client, AuthenticationError, NotFoundError, RateLimitError
Expand All @@ -118,6 +205,28 @@ with Client() as client:
print("Rate limited, retry later")
```

Retries are automatic for transient errors (408, 429, 5xx) with exponential backoff and jitter. Configure with `max_retries`:

```python
client = Client(max_retries=5) # default is 2
```

## API coverage

| Resource | Operations | Methods |
|---|---|---|
| Tasks | 3 | trigger, batch_trigger, batch_trigger_multi |
| Runs | 11 | list, retrieve, result, replay, cancel, reschedule, update_metadata, add_tags, events, trace, trace_paged |
| Schedules | 8 | list, create, retrieve, update, delete, activate, deactivate, timezones |
| Sessions | 5 | create, list, retrieve, update, close |
| Batches | 2 | retrieve, results |
| Waitpoints | 5 | create_token, list_tokens, complete_token_callback, complete_token, retrieve_token |
| Webhooks | 11 | list/retrieve/enable/disable endpoints, rotate/set secrets, create/cancel waiters, list/retrieve/replay deliveries |
| Bulk Actions | 4 | list, create, retrieve, abort |
| Errors | 5 | list, retrieve, resolve, ignore, unresolve |

**Total: 54 operations** across 9 resource domains (Tiers 1 and 2 of the Trigger.dev management API).

## Requirements

- Python 3.10+
Expand Down