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
133 changes: 124 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,136 @@
# triggerdev

The first fully typed async Python SDK for the [Trigger.dev](https://trigger.dev) management API.
[![CI](https://github.com/mehmetkr/triggerdev-python/actions/workflows/ci.yml/badge.svg)](https://github.com/mehmetkr/triggerdev-python/actions/workflows/ci.yml)
[![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)

> **Status:** Under development. Not yet published to PyPI.
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 22 Tier 1 endpoints across tasks, runs, and schedules.

## Features (planned)
> **Status:** Under active development. Not yet published to PyPI.

- Fully typed with Pydantic models generated from the OpenAPI spec
- Sync and async clients via httpx
- SSE streaming with reconnection for session channels
- AI agent tool definitions (LangChain/LangGraph compatible)
- Passes mypy --strict and pyright strict mode
## Installation

Requires Python 3.10 or later.

The package is not yet on PyPI. Install directly from GitHub:

```sh
uv add git+https://github.com/mehmetkr/triggerdev-python.git
```

Or with pip:

```sh
pip install git+https://github.com/mehmetkr/triggerdev-python.git
```

## Getting started

Set your Trigger.dev secret key as an environment variable:

```sh
export TRIGGER_SECRET_KEY="tr_dev_sk_..."
```

Then trigger your first task:

```python
from triggerdev import Client

with Client() as client:
result = client.tasks.trigger("my-task", payload={"user_id": 42})
print(result.id)
```

You can also pass the API key explicitly:

```python
client = Client(api_key="tr_dev_sk_...")
```

## Features

### Trigger tasks

```python
from triggerdev import Client

with Client() as client:
# Trigger a single task
result = client.tasks.trigger("send-welcome-email", payload={"user_id": 42})

# Batch trigger the same task with multiple payloads
result = client.tasks.batch_trigger("send-welcome-email", items=[
{"payload": {"user_id": 1}},
{"payload": {"user_id": 2}},
])
```

### List and filter runs

```python
from triggerdev import Client

with Client() as client:
# List runs with status filter
runs = client.runs.list(status=["QUEUED", "EXECUTING"])
for run in runs.data:
print(f"{run.id}: {run.status}")

# Retrieve a specific run
run = client.runs.retrieve("run_1234")
print(run.task_identifier)
```

### Manage schedules

```python
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)

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

### Error handling

Every API error maps to a typed exception:

```python
from triggerdev import Client, AuthenticationError, NotFoundError, RateLimitError

with Client() as client:
try:
run = client.runs.retrieve("run_nonexistent")
except NotFoundError as e:
print(f"Not found: {e}")
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limited, retry later")
```

## Requirements

- Python 3.10+
- [httpx](https://www.python-httpx.org/) (installed automatically)
- [pydantic](https://docs.pydantic.dev/) v2 (installed automatically)

## Contributing

Contributions are welcome. A contributing guide will be added before the first release.

## License

MIT
[MIT](LICENSE)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "triggerdev"
version = "0.0.0"
description = "The first fully typed async Python SDK for the Trigger.dev management API"
description = "The first fully typed Python SDK for the Trigger.dev management API"
readme = "README.md"
license = "MIT"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion src/triggerdev/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""The first fully typed async Python SDK for the Trigger.dev management API."""
"""The first fully typed Python SDK for the Trigger.dev management API."""

from triggerdev._client import Client
from triggerdev._exceptions import (
Expand Down