atlas-backend
The official Python backend SDK for Atlas — a typed client over the sk_
Backend API (BAPI). It is the Python peer of the TypeScript @atlas/backend
SDK and mirrors it namespace-for-namespace.
- Typed (
py.typed), one namespace per BAPI area. - Sync
AtlasClientand asyncAsyncAtlasClient, built onhttpx. - The
{ errors: [{ code, message, param }] }envelope surfaces asAtlasError. - Cursor pagination helper,
Idempotency-Keyon creates.
Install
pip install atlas-backend
Quick start
from atlas_backend import AtlasClient, AtlasError, paginate
atlas = AtlasClient("sk_live_...", base_url="https://api.atlasauth.net")
# Create a user (idempotency key optional, forwarded as Idempotency-Key).
user = atlas.users.create(
{"email_address": "ada@example.com", "first_name": "Ada"},
idempotency_key="signup-ada-001",
)
print(user["id"])
# List organizations (a single cursor page).
page = atlas.organizations.list(limit=20)
print(page["data"], page["has_more"], page["next_cursor"])
# Auto-iterate every page.
for org in paginate(atlas.organizations.list):
print(org["name"])
# Errors carry the HTTP status and the stable BAPI error code.
try:
atlas.users.get("user_does_not_exist")
except AtlasError as err:
print(err.status) # e.g. 404
print(err.code) # e.g. "NOT_FOUND"
print(err.errors[0].get("param"))
if err.has_code("NOT_FOUND"):
...
Context manager
with AtlasClient("sk_live_...") as atlas:
atlas.users.list(limit=10)
# underlying httpx.Client is closed on exit
Async
import asyncio
from atlas_backend import AsyncAtlasClient, acollect
async def main() -> None:
async with AsyncAtlasClient("sk_live_...") as atlas:
user = await atlas.users.create({"email_address": "grace@example.com"})
orgs = await acollect(atlas.organizations.list)
print(user["id"], len(orgs))
asyncio.run(main())
Configuration
| Argument | Default | Notes |
|---|---|---|
secret_key |
— | sk_...; sent as Authorization: Bearer <key>. |
base_url |
https://api.atlasauth.net |
The instance's BAPI origin (BAPI_ORIGIN). |
timeout |
30.0 |
Per-request timeout, seconds. |
http_client |
a new httpx.Client |
Pass your own for pooling / proxies / retries. |
Namespaces
users, sessions, organizations (+ memberships, invitations,
domains, group_roles), roles, permissions, oauth_clients (+ grants),
resource_servers, sso_connections, scim_tokens, domains, waitlist,
allowlist, blocklist, attack_protection, actor_tokens, invitations,
webhooks (+ endpoints), sign_in_tokens, audit_logs, jwt_templates.
Pagination
paginate(list_fn, **params) and collect(list_fn, **params) walk every
cursor page of any list that returns { data, has_more, next_cursor }. Async
peers: aiterate / acollect.
Errors
Every non-2xx raises AtlasError, carrying:
status— the HTTP status code.errors— the full[{ code, message, param?, meta? }]envelope.code— the first error's stable code (what you branch on).has_code(code)— True if any error in the envelope has that code.
Development
pip install -e ".[dev]"
ruff check .
mypy .
pytest
Metadata
Release files for atlas-backend 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 | |
|---|---|---|---|
| atlas_backend-0.2.0.tar.gz | 39.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| atlas_backend-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 76.7 kB
Release files / atlas_backend-0.2.0.tar.gz
| Download URL | atlas_backend-0.2.0.tar.gz |
|---|---|
| Size | 39.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3db01da6733f807f0e8ad24403c7d43e954b79b8e1d0c6f067d44f87e4745bbc
|
|
BLAKE2b-256 checksum How to use checksums |
295a420d2f04caf9382b07a87b33f6cc6637d6467d1af7f00a448960a839c4d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / atlas_backend-0.2.0-py3-none-any.whl
| Download URL | atlas_backend-0.2.0-py3-none-any.whl |
|---|---|
| Size | 37.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83af15dc9ecd7ffb7725582880a22f8ca7092b71f9d4c6feb7c85b6a9b993c9c
|
|
BLAKE2b-256 checksum How to use checksums |
5e4250146276893c12617166fcfb97ecdda4eefc5317bb5d87e80b4dd69bea9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|