stormwateriq-api-client
Official Python client for the StormwaterIQ external API: a typed-ish client, the reference webhook-signature verifier, and automatic retries.
pip install stormwateriq-api-client
from stormwateriq_api_client import StormwaterIQClient, verify
with StormwaterIQClient("https://api.stormwateriq.com", access_token) as client:
site = client.get_site("site_123")
page = client.list_inspections(site_id="site_123", limit=50)
created = client.create_site(
{"name": "Lot 7", "longitude": -84.39, "latitude": 33.77, "bmp_type": "dumpster_enclosure"},
idempotency_key="install_42", # echoed as client_reference + in site.registered
)
# Verify an inbound webhook (constant-time, replay-protected):
ok = verify(raw_body, request.headers["X-StormwaterIQ-Signature"], signing_secret)
The client covers sites (get/list/create/update), inspections
(get/list/photos/report), webhooks (register/list/delete), sponsor
outcomes, and health.
Authentication (TokenSource)
Mint + cache client-credentials tokens (refreshed ahead of expiry) and hand the getter to the client so the bearer stays current:
import os
from stormwateriq_api_client import StormwaterIQClient, TokenSource
tokens = TokenSource(
os.environ["SWIQ_CLIENT_ID"],
os.environ["SWIQ_CLIENT_SECRET"],
scopes=["site:read:owned", "site:write:owned"],
)
client = StormwaterIQClient(token=tokens.get_token) # base_url defaults to production
Typed webhook events
After verifying, parse the body into a validated envelope and branch on type:
from stormwateriq_api_client import verify, parse_event
if not verify(raw_body, sig_header, signing_secret):
return 400
event = parse_event(raw_body) # {"id", "type", "created_at", "data"}
if event["type"] == "site.registered":
link(event["data"]["site_id"], event["data"]["client_reference"])
The delivered body is the signed envelope {id, type, created_at, data} — id
is the stable per-event dedup key; type mirrors the X-StormwaterIQ-Event header.
- Retries — requests retry 429 (honoring
Retry-After) and 5xx with exponential backoff (max_retries, default 3); other 4xx raiseApiError. - Webhook verifier —
verify(payload, signature, secret)is stdlib-only (hmac/hashlib) and byte-identical to the server and the TypeScript SDK, pinned tofixtures/webhook-signature-vectors.json. Importing the verifier (andparse_event) never requireshttpx(the client is lazily imported).
Generation
Models and methods are hand-authored to mirror the gateway's OpenAPI document
(https://api.stormwateriq.com/v1/openapi.json); keep models.py /
webhook_events.py in sync when the spec changes. Published independently of the
API (semver).
Release files for stormwateriq-api-client 0.2.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 | |
|---|---|---|---|
| stormwateriq_api_client-0.2.0.tar.gz | 23.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stormwateriq_api_client-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.8 kB
Release files / stormwateriq_api_client-0.2.0.tar.gz
| Download URL | stormwateriq_api_client-0.2.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04b750c13abe72bda9a3bbb0ce29e4dd147d7f65499d5f29bce99abdfa44ed9b
|
|
BLAKE2b-256 checksum How to use checksums |
0f937c2f78b2a9d69b91385098d205e63efa3745cce57ca5b38e14e7b7f716a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / stormwateriq_api_client-0.2.0-py3-none-any.whl
| Download URL | stormwateriq_api_client-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d214fe7595eae8e6f21d86d2b56d8490beaa47093d818ed74239c68ed61d1868
|
|
BLAKE2b-256 checksum How to use checksums |
b3bce6035898ecbf9cce7e4f5de6fec58066090b438a6a6da54c2a2afe7b42a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|