Metadata-Version: 2.5
Name: pingloom
Version: 0.1.1
Summary: Python client for the PingLoom notification API (server-side only).
Project-URL: Homepage, https://pingloom.dev
Author: Srish Rachamalla
License: MIT
Keywords: alerts,notifications,on-call,pingloom,push,webhook
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.9
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# pingloom

Send an alert to your whole team's phones with one call. Python client for [PingLoom](https://pingloom.dev/?utm_source=pypi&utm_medium=readme).

Your server, cron job, CI or AI agent sends an event, every phone on the team gets a push notification, and one person taps **"I've got this"** so everyone sees who owns it.

- Standard library only, no dependencies. Python 3.9+.
- Safe retries: a retry never creates a duplicate alert.
- Server-side only: keep your API key out of browser and mobile code.

## Get an API key

Sign up at [pingloom.dev](https://pingloom.dev/?utm_source=pypi&utm_medium=readme), create a project and copy its API key (`pl_live_...`). The key is shown once. PingLoom is in early access: join the waitlist on the site if sign-up is not open for you yet.

## Install

```bash
pip install pingloom
```

## Send your first alert

```bash
export PINGLOOM_API_KEY=pl_live_...
```

```python
from pingloom import PingLoom

pl = PingLoom()  # reads PINGLOOM_API_KEY

pl.send("Nightly backup failed", body="db-main: disk full", channel="ops", priority="high")
```

That's it: the phones of everyone subscribed to `ops` buzz.

## Examples

```python
# at the end of a long job
try:
    render_video()
    pl.send("Render finished", priority="low")
except Exception as exc:
    pl.send("Render failed", body=str(exc)[:2000], priority="high")
    raise

# a cron job: one alert per day, even if the script runs twice
from datetime import date
pl.send("Daily report sent", channel="reports", idempotency_key=f"report-{date.today()}")
```

## Options

`send(title, body=None, channel=None, priority=None, data=None, action_url=None, idempotency_key=None)` returns the event ID.

| Argument | Notes |
| --- | --- |
| `title` | Up to 120 characters |
| `body` | Up to 2,000 characters |
| `channel` | Who gets it, for example `ops` or `deploys` |
| `priority` | `low`, `normal` (default) or `high` |
| `data` | Extra JSON-able dict, up to 8 KB, attached to the event |
| `action_url` | An https link opened from the alert |
| `idempotency_key` | Send the same key twice and only one alert goes out |

`status(event_id)` returns the event's state (needs a key with the `events:read` scope). `provider_accepted` means the push service accepted it, not that a phone has shown it.

Client options: `api_key`, `timeout`, `max_retries`, `backoff`, and `base_url` (only needed for a self-hosted or test server; also `PINGLOOM_BASE_URL`).

## Errors and retries

Rate limits (429), server errors (5xx) and network errors are retried up to 3 times with backoff, always with the same idempotency key, so a retry never creates a duplicate alert. Quota errors are not retried.

| Exception | When |
| --- | --- |
| `InvalidRequestError` | 400, 413, 415, 422 |
| `AuthenticationError` | 401, bad or revoked key |
| `PermissionDeniedError` | 403 |
| `NotFoundError` | 404 |
| `ConflictError` | 409 |
| `RateLimitError` | 429 after retries |
| `QuotaExceededError` | 429, monthly quota used up |
| `ServerError` | 5xx after retries |
| `NetworkError` | no response after retries |
| `ConfigurationError` | no API key |

Each has `status`, `code`, `message` and `request_id`. Your key is never printed: `repr(client)` and error text show it as `pl_live_****abcd`.

## Links

- Website: [pingloom.dev](https://pingloom.dev/?utm_source=pypi&utm_medium=readme)
- Node client and CLI: `npm install pingloom`
- License: MIT
