Metadata-Version: 2.5
Name: triggerdev
Version: 0.1.0
Summary: The first fully typed Python SDK for the Trigger.dev management API
Project-URL: Homepage, https://github.com/mehmetkr/triggerdev-python
Project-URL: Repository, https://github.com/mehmetkr/triggerdev-python
Project-URL: Issues, https://github.com/mehmetkr/triggerdev-python/issues
Project-URL: Changelog, https://github.com/mehmetkr/triggerdev-python/blob/main/CHANGELOG.md
Author-email: Mehmet Karaoglu <mehmetkaraoglu2022@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: api,background-jobs,sdk,trigger.dev,triggerdev
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx2<3,>=2.0.0
Requires-Dist: pydantic<3,>=2.7.0
Description-Content-Type: text/markdown

# triggerdev

[![PyPI](https://img.shields.io/pypi/v/triggerdev)](https://pypi.org/project/triggerdev/)
[![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)

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.

## Installation

Requires Python 3.10 or later.

```sh
uv add triggerdev
```

Or with pip:

```sh
pip install triggerdev
```

## 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+
- [httpx2](https://github.com/pydantic/httpx2) (installed automatically)
- [pydantic](https://docs.pydantic.dev/) v2 (installed automatically)

## Contributing

Contributions are welcome. See [CONTRIBUTING.md](https://github.com/mehmetkr/triggerdev-python/blob/main/CONTRIBUTING.md) for guidelines.

## License

[MIT](https://github.com/mehmetkr/triggerdev-python/blob/main/LICENSE)
