Skip to main content

DNA — Official Python client for the DNA REST read-API (spec-parity twin of the TypeScript dna-client)

Project description

dna-client (Python)

The official Python client for the DNA REST API (dna api serve). Spec-parity twin of the TypeScript dna-client: both cover the same surface, derived from the same OpenAPI document (docs/openapi.json, dumped from the FastAPI app) — so consumers stop hand-rolling HTTP.

  • Typed inputs, httpx-based, sync, context-manageable.
  • Complete — a named method for EVERY operation in the spec, reads and writes alike. client.request(...) remains as a low-level escape hatch, but no route depends on it.
  • Guarded — a drift test re-dumps the live schema and fails CI if the committed spec is stale, and fails if any operation (of any HTTP method) has no named method. Adding a write route cannot pass silently.

Install

pip install dna-client        # or: uv add dna-client

Only runtime dep is httpx. Python >= 3.12.

Usage

from dna_client import DnaClient

with DnaClient(
    "http://127.0.0.1:8080",
    token="…",                 # optional — for --auth token/config
    scope="dna-development",    # optional default applied to every call
) as dna:
    agents = dna.list_agents()
    prompt = dna.agent_prompt("jarvis")
    hits = dna.search_memories("tenancy invariant", k=3)
    board = dna.get_board("dna-development", recent=6)

    # Writes are named methods too — no escape hatch needed.
    dna.remember_memory("a lesson worth keeping", area="ops")
    dna.delete_memory("s-foo")
    dna.set_insight_state("i-42", "actioned")

    # Workspace routes are identity-scoped: the boundary comes from the caller's
    # verified claims, so they never take the client's default scope/tenant.
    ws = dna.create_workspace("Acme")           # id is minted server-side
    dna.create_invite(ws["workspace_id"], "teammate@acme.com", role="member")

Routes with security semantics say so in their docstring — e.g. create_project() is 403 without an active workspace membership, and revoke_workspace_member() is 409 on the last remaining owner.

A non-2xx response raises DnaApiError (carrying .status and the API's {"detail": ...} payload).

Note on return types

Every DNA REST handler returns an untyped JSON object (dict[str, Any]), so the OpenAPI response schemas are opaque. Request inputs (query/path params) are typed; response bodies are dict[str, Any]. Tighten the API's response models to tighten these.

Parity

This client and the TypeScript twin are generated from the SAME docs/openapi.json — spec-parity, not byte-parity. See Using the DNA client.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dna_client-0.25.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dna_client-0.25.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file dna_client-0.25.1.tar.gz.

File metadata

  • Download URL: dna_client-0.25.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dna_client-0.25.1.tar.gz
Algorithm Hash digest
SHA256 00b4a4e14ac4cc43e34a4175c8a267b83ca9f1440be946f40b4d8a26a6dbcfad
MD5 e71a81ee3e15b991631c498eba5afed3
BLAKE2b-256 2a3be82038c20dcf3cdd558520c5d3576a211e59ff5df0f41f3efd14e63a4839

See more details on using hashes here.

Provenance

The following attestation bundles were made for dna_client-0.25.1.tar.gz:

Publisher: release-client.yml on ruinosus/dna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dna_client-0.25.1-py3-none-any.whl.

File metadata

  • Download URL: dna_client-0.25.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dna_client-0.25.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75f4c4d71362aa669c837e26893bb1d546f3c5a23eace2f6d096f61d251095bc
MD5 3c4f90860910317a685c7146e958a659
BLAKE2b-256 d22e4aca83beb338ce6711d2a800bc8b4cfd8f009d55701548be0ce74dae1a19

See more details on using hashes here.

Provenance

The following attestation bundles were made for dna_client-0.25.1-py3-none-any.whl:

Publisher: release-client.yml on ruinosus/dna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page