Trigv Python SDK
Official Python client for the Trigv workspace ingest API. Send push notification events from scripts, cron jobs, CI pipelines, and backend services.
Installation
pip install trigv
Requires Python 3.10 or newer. No runtime dependencies beyond the standard library.
Quick start
from trigv import Trigv
trigv = Trigv()
result = trigv.send_event(
{
"channel": "general",
"title": "Hello from Python",
}
)
print(result.event.public_id)
Authentication
Create a workspace ingest API key in the Trigv dashboard. Keys look like trgv_a1b2c3d4_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Pass the key when constructing the client, or set the TRIGV_API_KEY environment variable:
from trigv import Trigv
trigv = Trigv(api_key="trgv_your_api_key")
Never commit API keys to source control. The SDK does not include your key in error messages or logs.
Sending an event
result = trigv.send_event(
{
"channel": "deploys",
"title": "Production deploy complete",
"description": "Build #42 succeeded in 38s (commit abc1234)",
"level": "success",
"event_type": "deploy.completed",
}
)
print(result.event.public_id, result.event.status)
send_event() returns a SendEventResult with:
event— server metadata (public_id,status,target_device_count, etc.)duplicate—Truewhen the sameidempotency_keywas already accepted (HTTP 200)
Title, description, and image URL are delivered to devices but are not stored server-side.
Event options
| Field | Required | Description |
|---|---|---|
channel |
Yes | Channel slug (e.g. general, deploys) |
title |
Yes | Notification title |
description |
No | Body text (max 1000 characters) |
image_url |
No | HTTPS image URL (max 2048 characters) |
url |
No | Destination URL for the notification (max 2048 characters; not stored server-side) |
level |
No | info, success, warning, or error (default: info) |
delivery_urgency |
No | standard or time_sensitive (default: standard) |
event_type |
No | Free-form label (e.g. deploy.completed) |
idempotency_key |
No | Dedup key per workspace (max 190 characters) |
Prohibited fields: api_key (use the Authorization header), icon.
Levels
| Level | Use case |
|---|---|
info |
General updates (default) |
success |
Completed jobs, successful deploys |
warning |
Degraded service, retries |
error |
Failures requiring attention |
Delivery urgency
| Value | Behaviour |
|---|---|
standard |
Normal delivery (default) |
time_sensitive |
iOS time-sensitive interruption level |
Idempotency
Set idempotency_key to safely retry delivery without creating duplicate events or billing twice:
result = trigv.send_event(
{
"channel": "deploys",
"title": "Production deploy complete",
"idempotency_key": "deploy-prod-42",
}
)
if result.duplicate:
print("Already sent:", result.event.public_id)
- First request with a key → HTTP 202,
duplicate=False, usage billed - Retry with the same key → HTTP 200,
duplicate=True, no additional usage
Without an idempotency_key, the SDK does not auto-retry send_event() on ambiguous failures.
Error handling
from trigv import (
AuthenticationError,
AuthorizationError,
NotFoundError,
RateLimitError,
Trigv,
ValidationError,
)
trigv = Trigv()
try:
trigv.send_event({"channel": "general", "title": "Hello"})
except ValidationError as exc:
print(exc.errors)
except AuthenticationError:
print("Check your API key")
except NotFoundError:
print("Channel does not exist")
except RateLimitError as exc:
if exc.retryable:
print("Per-minute limit — retry shortly")
else:
print("Monthly workspace cap reached")
| Exception | When |
|---|---|
ValidationError |
Client-side validation or HTTP 422 |
AuthenticationError |
HTTP 401 |
AuthorizationError |
HTTP 403 |
NotFoundError |
HTTP 404 (e.g. unknown channel) |
RateLimitError |
HTTP 429 (retryable distinguishes burst vs monthly cap) |
ApiError |
Other HTTP errors |
NetworkError |
Connection failure |
TimeoutError |
Request timeout |
Configuration
trigv = Trigv(
api_key="trgv_your_api_key",
base_url="https://api.trigv.com/api", # default
timeout=30.0, # seconds
max_retries=2, # retryable errors only
)
For local development with Laravel Herd:
trigv = Trigv(base_url="http://trigv-platform.test/api")
Verify connection
Check that your API key is valid without sending an event or consuming usage:
connection = trigv.verify_connection()
print(connection.workspace.name)
print(connection.api_key.prefix)
Examples
See the examples/ directory:
basic.py— minimal eventdeploy-completed.py— canonical deploy notificationcron-failed.py— scheduled job failureidempotency.py— safe retries with idempotency keys
Development
git clone https://github.com/Trigv/trigv-python.git
cd trigv-python
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Or with PEP 735 dependency groups:
pip install pytest ruff black hatchling
pip install -e .
Testing
pytest
ruff check src tests examples
black --check src tests examples
Tests use a mocked HTTP transport — no live API key required.
Contributing
Contributions are welcome. Please open an issue or pull request on GitHub.
Licence
MIT — see LICENSE.
Metadata
Release files for trigv 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| trigv-1.0.0.tar.gz | 9.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trigv-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / trigv-1.0.0.tar.gz
| Download URL | trigv-1.0.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
947cfbf3b7f5b7277dd63ea500e838a4ae1557d3b820a8e933a10ea33224321e
|
|
BLAKE2b-256 checksum How to use checksums |
be5c3f19af67a62d167774a3a045e992de272e2d61cb843741077deeb922df06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / trigv-1.0.0-py3-none-any.whl
| Download URL | trigv-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
841a9ea6f0009e44b5913164d93d4d27e721785f7334c26cb1e3ecc73ec0ab75
|
|
BLAKE2b-256 checksum How to use checksums |
01b4f8792e3abdc6fd0ae5aaf25bb95bd15ee72fbd09bbdaf68b0912ac47a9fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for trigv 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.