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, fanned out over a pool of concurrency workers that pull records one at a time, so memory stays flat however long the input list is.

Documentation

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

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

Release files for dhis2w-client 1.23.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 dhis2w-client 1.23.0
File Size Uploaded
dhis2w_client-1.23.0.tar.gz 2.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dhis2w-client 1.23.0
File Interpreter ABI Platform
dhis2w_client-1.23.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.7 MB

Release files / dhis2w_client-1.23.0.tar.gz

Download URL dhis2w_client-1.23.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
2cec609c72619b8ba6649f9c654ce38f8dd403bf0a34b24c90e0db240f04ab7c
BLAKE2b-256 checksum
How to use checksums
31c7885ac6cee36f870e6794b8fe213c66fb317fba92eae0e8089e5f1048271a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / dhis2w_client-1.23.0-py3-none-any.whl

Download URL dhis2w_client-1.23.0-py3-none-any.whl
Size 3.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
70ad3af64a66b4d08505ec4ca46d64b9854daca1f0eb34a4b827752dc8b4354a
BLAKE2b-256 checksum
How to use checksums
a564f0df5685ff2b4c6686d809e9ed1038b097e5e480a2c46c74cc1b9bcb9629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

1.24.0

2 release files

This release

1.23.0 This release

2 release files

1.22.0

2 release files

1.21.0

2 release files

1.20.0

2 release files

1.19.0

2 release files

1.18.0

2 release files

1.17.0

2 release files

1.16.0

2 release files

1.15.0

2 release files

1.14.0

2 release files

1.9.0

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.99.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

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