◇ /LANDING/SDK/PYTHON

Async first.
Pydantic types.

Native asyncio, Pydantic v2 models for every response, httpx under the hood. Works with FastAPI, Django, Flask, or plain scripts.

Python 3.10+asyncio nativePydantic v2httpxpy.typed
01 · INSTALL

pip, uv, or poetry.
Your call.

Zero native dependencies. Pure Python with httpx for HTTP and Pydantic v2 for model validation. Ships with py.typed for mypy and pyright.

pip
$ pip install relays-sdk
uv
$ uv add relays-sdk
poetry
$ poetry add relays-sdk
02 · CLIENT

async with.
Context managed.

The async client uses httpx under the hood with connection pooling, automatic retries, and proper resource cleanup via async context manager.

client.py
03 · RECORDS

Keyword arguments.
Pythonic.

Every method uses keyword arguments with sensible defaults. Return types are Pydantic models with full autocomplete in PyCharm and VS Code.

records.py
04 · BULK

Bulk ops.
Atomic.

Create, update, and delete multiple records in a single atomic transaction. All succeed or all roll back. Progress callback included.

bulk.py
from relays import BulkOp

result = await client.records.bulk(
    zone="example.com",
    operations=[
        BulkOp.create(type="A", name="app1",
                       content="10.0.0.1", ttl=300),
        BulkOp.create(type="A", name="app2",
                       content="10.0.0.2", ttl=300),
        BulkOp.create(type="AAAA", name="app1",
                       content="2001:db8::1", ttl=300),
        BulkOp.delete(record_id="rec_old"),
    ],
)

print(f"Created: {result.created}")
print(f"Deleted: {result.deleted}")
print(f"Errors:  {result.errors}")
05 · TYPES

Pydantic v2.
Not dicts.

Every response is a Pydantic BaseModel. Validated, serializable, and fully typed. Use model_dump() for JSON, or access fields directly.

models.py
from relays.models import DnsRecord, Zone

# Every field is typed and validated
record: DnsRecord = await client.records.get(
    zone="example.com",
    record_id="rec_8f3c",
)

record.type       # Literal["A","AAAA","CNAME",...]
record.name       # str
record.content    # str
record.ttl        # int
record.created_at # datetime
record.dnssec     # DnssecStatus

# Serialize to dict / JSON
data = record.model_dump()
json = record.model_dump_json()

# Works with FastAPI response models
@app.get("/record/{id}", response_model=DnsRecord)
async def get_record(id: str) -> DnsRecord:
    return await client.records.get("example.com", id)

pip install.
async with.