The first fully typed Python SDK for the Trigger.dev management API. Built with Pydantic models generated from the OpenAPI spec, covering tasks, runs, and schedules.
Requires Python 3.10 or later.
uv add triggerdevOr with pip:
pip install triggerdevSet your Trigger.dev secret key as an environment variable:
export TRIGGER_SECRET_KEY="tr_dev_sk_..."Then trigger your first task:
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:
client = Client(api_key="tr_dev_sk_...")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}},
])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)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}")Every API error maps to a typed exception:
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")Contributions are welcome. See CONTRIBUTING.md for guidelines.