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, plus v44 as a preview against a pinned 2.44 development build.

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.dhis2.org/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,44}.
  • Tracker read + write helpers (client.tracker.register / enroll / event_create / outstanding).
  • Analytics — client.analytics.aggregate(dx=..., pe=..., ou=...) -> Grid for parsed responses, stream_to(...) for very large pivots.
  • Period math — parse_period, next_period_id, previous_period_id, period_start_end across all six absolute period shapes.
  • Pluggable auth — BasicAuth, PatAuth, OAuth2Auth. Add your own by implementing the AuthProvider Protocol.
  • Bulk operations — patch_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) builds on this client, and so do the plugin packs in their own repositories: the MCP server (dhis2w-mcp) and the Playwright helpers (dhis2w-browser).

Metadata

Release files for dhis2w-client 1.38.2

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.38.2
File Size Uploaded Provenance Actions
dhis2w_client-1.38.2.tar.gz 3.0 MB With provenance Details for dhis2w_client-1.38.2.tar.gz

Built distribution (wheel)

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

Total release size: 7.6 MB

Release files / dhis2w_client-1.38.2.tar.gz

Download URL dhis2w_client-1.38.2.tar.gz
Size 3.0 MB
Tags Source
SHA-256 checksum
How to use checksums
6a81f02935d33ba0fce266ac1a0f567c47808e134c83badf7adb764de2c86c25
BLAKE2b-256 checksum
How to use checksums
3b34498ae349e8b75d9a91f524fed618854bc654b67bdcf1dcde097e03fa80ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

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

Download URL dhis2w_client-1.38.2-py3-none-any.whl
Size 4.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a3ec120dbab147cf51c597512cad33f69a62b8a3207aebd846fbe2a484f488bd
BLAKE2b-256 checksum
How to use checksums
8c3f4f78775f1f09a893609cfc0cd0b857baf5f0886f93039903f5344cf2b2d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

Security for dhis2w-client 1.38.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dhis2w_client-1.38.2.tar.gz

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 Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.38.2 This release

2 release files Full provenance

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