Python wrapper for the API Alerts service
Project description
API Alerts • Python Client
PyPI • GitHub • API Alerts
Effortless project notifications. Send once, deliver everywhere.
Installation
pip install apialerts
Quick Start
from apialerts import ApiAlerts, Event
ApiAlerts.configure('your-api-key')
ApiAlerts.send(Event(message='Deploy complete'))
Usage
Global singleton
Call configure once at startup, then use send / send_async anywhere.
from apialerts import ApiAlerts, Event
ApiAlerts.configure('your-api-key')
# Fire-and-forget. Never raises, silently drops errors.
# Pass debug=True to configure() to log them via stdlib logging.
ApiAlerts.send(Event(message='Deploy complete'))
# Or get the result back. Never raises, check result.success.
result = await ApiAlerts.send_async(Event(message='Deploy complete'))
if result.success:
print(f'Sent to {result.workspace} ({result.channel})')
else:
print(f'Error: {result.error}')
Enable debug logging
ApiAlerts.configure('your-api-key', debug=True)
The SDK uses Python's stdlib logging module under the logger name 'apialerts'. Critical errors (missing API key, not yet configured) always log via logger.error(...). Debug success/warning messages log via logger.info(...) and only fire when debug=True. Configure the apialerts logger to route output anywhere you like:
import logging
logging.getLogger('apialerts').setLevel(logging.INFO)
logging.basicConfig()
Event fields
Only message is required. All other fields are optional and omitted from the request body when not set.
from apialerts import Event
event = Event(
message='Deploy complete',
channel='releases',
event='ci.deploy',
title='Deployed',
tags=['CI/CD', 'Python'],
link='https://github.com/apialerts/apialerts-python/actions',
data={'version': '1.2.0'},
)
result = await ApiAlerts.send_async(event)
| Field | Type | Required | Description |
|---|---|---|---|
message |
str |
Yes | Human-readable notification text. This is what appears on the push notification lock screen. |
channel |
str |
No | Workspace channel the push notification fires on. Defaults to the workspace default channel when omitted. |
event |
str |
No | Identifies what kind of thing happened. Optional but recommended. Use dotted notation (e.g. ci.deploy.success, payment.failed, user.signup) so routing rules can match glob patterns like ci.* or *.failed. |
title |
str |
No | Short headline some destinations render separately from the message body. |
tags |
list[str] |
No | Categorisation tags for filtering and search. |
link |
str |
No | URL associated with the event. Available as a deeplink for push notifications and as a call-to-action for routed destinations. |
data |
dict[str, Any] |
No | Arbitrary key-value metadata. Available to non-push destinations for templating (Slack message bodies, email templates, webhook payloads). |
Send to multiple workspaces
Pass an api_key as the optional second argument to override the configured key for one call.
ApiAlerts.send(Event(message='Deploy complete'), api_key='other-workspace-api-key')
result = await ApiAlerts.send_async(
Event(message='Deploy complete'),
api_key='other-workspace-api-key',
)
API
| Method | Description |
|---|---|
ApiAlerts.configure(api_key, debug=False) |
Initialise the singleton. First call wins; subsequent calls are no-ops. |
ApiAlerts.send(event, api_key=None) |
Fire-and-forget. Never raises, drops errors silently unless debug is on. |
ApiAlerts.send_async(event, api_key=None) |
Awaitable, returns SendResult. Never raises; check result.success. |
SendResult fields
| Field | Type | Description |
|---|---|---|
success |
bool |
True if the alert was delivered |
workspace |
str or None |
Workspace name (present on success) |
channel |
str or None |
Channel name (present on success) |
warnings |
list[str] |
Non-fatal warnings from the server |
error |
str or None |
Error message (present on failure) |
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apialerts-1.2.0.tar.gz.
File metadata
- Download URL: apialerts-1.2.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcd7e13c942bc41d9b91e45d7ba48eabac7a4302d5fcc6b655e9185ce91ab190
|
|
| MD5 |
20a8f63194c0d78cabb52980d4fab43a
|
|
| BLAKE2b-256 |
3e14b02044df465dd705d15f6e77acca85c6ebf6282507f39cb0942501a3e44b
|
Provenance
The following attestation bundles were made for apialerts-1.2.0.tar.gz:
Publisher:
publish-pypi.yml on apialerts/apialerts-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apialerts-1.2.0.tar.gz -
Subject digest:
bcd7e13c942bc41d9b91e45d7ba48eabac7a4302d5fcc6b655e9185ce91ab190 - Sigstore transparency entry: 1694736397
- Sigstore integration time:
-
Permalink:
apialerts/apialerts-python@25a036c58fab38fb97f522f54d7a77c283d3c6e5 -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/apialerts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@25a036c58fab38fb97f522f54d7a77c283d3c6e5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file apialerts-1.2.0-py3-none-any.whl.
File metadata
- Download URL: apialerts-1.2.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c942863f8833b413d606d79c76f08f962804215da2bff4fc8fff3212643ec35a
|
|
| MD5 |
5082c2587d35d1fb55a07bbae4b38423
|
|
| BLAKE2b-256 |
acdf5e9a9840617e52203e5e9c39ce75b2631b91418e1f63e1c021fec70506a3
|
Provenance
The following attestation bundles were made for apialerts-1.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on apialerts/apialerts-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apialerts-1.2.0-py3-none-any.whl -
Subject digest:
c942863f8833b413d606d79c76f08f962804215da2bff4fc8fff3212643ec35a - Sigstore transparency entry: 1694736519
- Sigstore integration time:
-
Permalink:
apialerts/apialerts-python@25a036c58fab38fb97f522f54d7a77c283d3c6e5 -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/apialerts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@25a036c58fab38fb97f522f54d7a77c283d3c6e5 -
Trigger Event:
release
-
Statement type: