Official Python client for Apier — Norwegian compliance infrastructure API.
- Zero runtime dependencies. Pure Python stdlib (
urllib,ssl,json). - HTTPS-only, with defence-in-depth against open redirects.
- Typed (
py.typed),mypy --strictclean. - Python 3.11+.
pip install apier-nofrom apier import Client, ApierError
# Zero-auth — works against every Category-A endpoint
# (/api/v1/tools/*, /api/v1/public/*, /api/v1/capabilities).
client = Client()
data = client.get("/api/v1/tools/altinn-migration")
print(data["data"]["mappings"][0])For Category-B endpoints (company data, accounting filings, etc.) pass an API key:
client = Client(api_key="apier_test_...") # explicit
client = Client() # or APIER_API_KEY envErrors normalise to a structured ApierError:
try:
client.get("/api/v1/company/999999999/context")
except ApierError as e:
print(e.error_code) # e.g. "VALIDATION_FAILED"
print(e.explanation) # short summary
print(e.raw_explanation) # full {summary, why, fix_steps, legal_basis}
print(e.status) # HTTP status (None on network errors)| Argument | Default | Notes |
|---|---|---|
api_key |
APIER_API_KEY env or None |
Empty string treated as no key. |
base_url |
https://www.apier.no |
Must be https://. Non-https raises ValueError. |
timeout |
30.0 (seconds) |
Per-call override: client.get(path, timeout=2.5). |
This library is intentionally conservative:
- HTTPS only. Non-https
base_urlis rejected at construction time. Non-https redirects are refused by the client's redirect handler. - The system default SSL context (
ssl.create_default_context()) is used unmodified. The library does not expose, accept, or expose a way to disable certificate verification or pass a custom CA bundle. - The API key never appears in
repr(),str(), exception text, or any other surface the library emits. The repr masks it as***. - Errors never leak raw response bodies, headers, or request URLs.
For the full threat model and disclosure process see SECURITY.md.
The Apier discovery surface points at this package:
https://www.apier.no/llms.txthttps://www.apier.no/llms-full.txthttps://www.apier.no/docs/sdks
- Semantic versioning.
- The version lives in
src/apier/_version.py. Every release CI step verifies the git tag matches. - Published via PEP 740 Trusted Publishing from this repo — no long-lived PyPI token is configured anywhere.
MIT — see LICENSE.