Metadata-Version: 2.5
Name: pingloom
Version: 0.1.0
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 (Python)

Python client for the [PingLoom](https://pingloom.dev) notification API. Standard library only, Python 3.9+.

Server-side only: the API key (`pl_live_...` or `pl_test_...`) must never go into browser or mobile code.

```bash
pip install pingloom
export PINGLOOM_API_KEY=pl_test_...
```

```python
from pingloom import PingLoom

pl = PingLoom()  # reads PINGLOOM_API_KEY; talks to https://api.pingloom.dev (override with PINGLOOM_BASE_URL)
event_id = pl.send(
    "Backup finished", body="42 GB in 3 min", channel="ops", priority="high", idempotency_key="backup-2026-10-30"
)
print(pl.status(event_id)["status"])  # provider_accepted means FCM accepted it, not that a phone got it
```

`send(title, body=None, channel=None, priority=None, data=None, action_url=None, idempotency_key=None)` returns the event ID. `status(event_id)` needs the `events:read` scope.

## Errors and retries

Every API error is a typed exception carrying `status`, `code`, `message`, `request_id` and `details`:

| Exception | When |
| --- | --- |
| `InvalidRequestError` | 400, 413, 415, 422 |
| `AuthenticationError` | 401 |
| `PermissionDeniedError` | 403 |
| `NotFoundError` | 404 |
| `ConflictError` | 409 (`IDEMPOTENCY_CONFLICT`, `PROJECT_ARCHIVED`) |
| `RateLimitError` | 429 `RATE_LIMITED`, after retries |
| `QuotaExceededError` | 429 `QUOTA_EXCEEDED`, never retried |
| `ServerError` | 5xx, after retries |
| `NetworkError` | no response, after retries |
| `ConfigurationError` | missing key or base URL |

`429 RATE_LIMITED`, `5xx` and network errors are retried (default 3 times) with exponential backoff, or `Retry-After` when sent. Retries reuse the same `Idempotency-Key`, so they cannot create duplicates. When you do not pass `idempotency_key`, a random one is generated per call. Pass your own, derived from the business event, to make repeated calls of your own safe too.

The key is never logged: `repr(client)` and error text show `pl_live_****abcd`.

## Develop

```bash
pip install pytest
python -m pytest
```
