Skip to main content

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 AtlasClient and async AsyncAtlasClient, built on httpx.
  • The { errors: [{ code, message, param }] } envelope surfaces as AtlasError.
  • Cursor pagination helper, Idempotency-Key on 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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for atlas-backend 0.1.0
File Size Uploaded
atlas_backend-0.1.0.tar.gz 23.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for atlas-backend 0.1.0
File Interpreter ABI Platform
atlas_backend-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.9 kB

Release files / atlas_backend-0.1.0.tar.gz

Download URL atlas_backend-0.1.0.tar.gz
Size 23.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e21b088a68d7849ba21dfa70f7b7b02752a0f66afd444417553ec8f6e6dd845c
BLAKE2b-256 checksum
How to use checksums
6221463df4a55a9202a2689b502fa5369908a62b451f6837534bfe7bcb9c8b0e
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.1.0-py3-none-any.whl

Download URL atlas_backend-0.1.0-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
723a9d0fc807f2ae2d01d5ff015c5202ac44e8cfad0fa103ee5530c877b35256
BLAKE2b-256 checksum
How to use checksums
5f75faa57f2d47a87baf303c2b3565f863dcc6fc2bb27b04a3b7b95e25e41f4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page