Python

Install and use the adlass package.

pip install adlass

Requires Python 3.10 or newer. The package depends on httpx and pydantic.

Create a client

import os
from adlass import Adlass

client = Adlass(
    os.environ["ADLASS_API_KEY"],
    # base_url="https://dev.adlass.io/v1",  # development environment, adl_test_ keys
    # timeout=30.0, max_retries=3, max_retry_delay=60.0,
)

Use the client as a context manager or call client.close() when you are done.

Read

space = client.request("GET", "/spaces/123e4567-e89b-42d3-a456-426614174000")
print(space["name"])

request() returns the parsed JSON body. Failures raise AdlassError; error.problem holds the problem details and error.status the HTTP status.

from adlass import AdlassError

try:
    client.request("DELETE", "/spaces/123e4567-e89b-42d3-a456-426614174000")
except AdlassError as error:
    print(error.status, error.problem.code, error.problem.request_id)

Write

space = client.request(
    "POST",
    "/spaces",
    json={"name": "Customer documents"},
    idempotency_key=order_id,  # optional; a UUID is generated otherwise
)

Paginate

for document in client.paginate("/documents", params={"limit": 100}):
    print(document["file_name"])

paginate() yields items across pages until next_cursor is null.

Generated operations

client.generated exposes the fully typed client produced by openapi-python-client, one module per operation under adlass.generated.api. Use it when you want attrs models instead of dictionaries:

from adlass.generated.api.spaces import spaces_list

page = spaces_list.sync(client=client.generated, limit=10)

Retries

429 responses are retried up to max_retries times, waiting for Retry-After or an exponential backoff, never longer than max_retry_delay seconds. Redirects are not followed.

On this page