Skip to main content

dhis2w-client

Pure async DHIS2 API client for Python. Pluggable auth (Basic / PAT / OAuth2-OIDC PKCE), pydantic-typed models from both /api/schemas and /api/openapi.json codegen, retry policy, period math, analytics helper. DHIS2 v41, v42, and v43.

Standalone — no profile system, no plugin runtime. Drop it in any async Python project that needs to talk to a DHIS2 instance.

Install

# Inside a uv-managed project
uv add dhis2w-client

Quickstart

from dhis2w_client import BasicAuth, Dhis2Client

async with Dhis2Client(
    base_url="https://play.im.dhis2.org/dev-2-43",
    auth=BasicAuth(username="admin", password="district"),
) as client:
    me = await client.system.me()
    print(me.username)

    elements = await client.resources.data_elements.list(fields="id,name", page_size=10)
    for de in elements:
        print(de.id, de.name)

PAT and OAuth2 (with token caching + refresh) work the same way:

from dhis2w_client import Dhis2Client, OAuth2Auth

auth = OAuth2Auth(
    base_url="https://dhis2.example.org",
    client_id="my-app",
    client_secret="...",
    scope="ALL",
    redirect_uri="http://localhost:8765",
    token_store=my_token_store,
    store_key="profile:prod",
)
async with Dhis2Client("https://dhis2.example.org", auth=auth) as client:
    ...

What's in the box

  • Async HTTP via httpx with a pluggable retry transport (429 / 502 / 503 / 504 with Retry-After honoring).
  • Typed metadata accessors for every resource DHIS2 exposes via /api/schemas — generated per DHIS2 version under dhis2w_client.generated.v{41,42,43}.
  • Tracker read + write helpers (client.tracker.register / enroll / event_create / outstanding).
  • Analyticsclient.analytics.aggregate(dx=..., pe=..., ou=...) -> Grid for parsed responses, stream_to(...) for very large pivots.
  • Period mathparse_period, next_period_id, previous_period_id, period_start_end across all six absolute period shapes.
  • Pluggable authBasicAuth, PatAuth, OAuth2Auth. Add your own by implementing the AuthProvider Protocol.
  • Bulk operationspatch_bulk, apply_sharing_bulk, with explicit concurrency cap (asyncio.Semaphore).

Documentation

Full docs at https://winterop-com.github.io/dhis2w-utils/.

The dhis2w-client package is one member of the dhis2w-utils workspace. The CLI (dhis2w-cli), MCP server (dhis2w-mcp), and Playwright helpers (dhis2w-browser) all build on this client.

Download files

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

Source Distribution

dhis2w_client-1.0.0.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

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

dhis2w_client-1.0.0-py3-none-any.whl (3.5 MB view details)

Uploaded Python 3

File details

Details for the file dhis2w_client-1.0.0.tar.gz.

File metadata

  • Download URL: dhis2w_client-1.0.0.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dhis2w_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c5e5f39e009c972e2134f76051237d238992bcc5b403506dee6bd333542e9e52
MD5 2bc81d0b51c6cd34683953e6dbcc5d5f
BLAKE2b-256 1ca7ad411a5d7b63c74be63e2d02637619bf4fc676e7a4310a5be744102d850d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dhis2w_client-1.0.0.tar.gz:

Publisher: pypi-publish.yml on winterop-com/dhis2w-utils

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

File details

Details for the file dhis2w_client-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dhis2w_client-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dhis2w_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97dd566334506aadcc5d857498b208635aadf49037a4b813f6ab5c8d2889048b
MD5 0834f26228b407fed9b34f96763d1aec
BLAKE2b-256 ec2bcb00307c1a2ba17ca7bff9333f3f04df581fd3efedff33522b1dca8f5079

See more details on using hashes here.

Provenance

The following attestation bundles were made for dhis2w_client-1.0.0-py3-none-any.whl:

Publisher: pypi-publish.yml on winterop-com/dhis2w-utils

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