Analytics responses¶
Typed shapes for /api/analytics (aggregated + raw) responses.
See also¶
- Analytics streaming —
AnalyticsAccessoronDhis2Client.analyticscovers the streaming/api/analytics*surface (pivots, events, enrollments, outliers) plus the simplequery(...)call over the standard aggregate endpoint. - Visualizations + dashboards — every saved
Visualizationis an analytics query with a chart type + axis placement attached. Start from an analytics query you've verified, then wrap it in aVisualizationSpecto persist. - Visualizations walkthrough — end-to-end guide showing how to go from a
client.analytics.query(...)result to a saved chart + a dashboard slot.
analytics
¶
Typed models for DHIS2 /api/analytics* query responses.
Re-exports the OAS-emitted Grid / GridHeader models as the canonical
types for every /api/analytics* response (standard / raw / events /
enrollments / outlier / tracked-entity — they all share the Grid
envelope). AnalyticsMetaData is a typed parser helper: DHIS2's
Grid.metaData is dict[str, Any] on the wire (dimension lookups + item
descriptors keyed by UID), and callers that want the structured
{items, dimensions} view use AnalyticsMetaData.model_validate(grid.metaData)
to lift the raw dict into a typed model.
Classes¶
Grid
¶
Bases: BaseModel
OpenAPI schema Grid.
Source code in packages/dhis2w-client/src/dhis2w_client/generated/v42/oas/grid.py
GridHeader
¶
Bases: BaseModel
OpenAPI schema GridHeader.
Source code in packages/dhis2w-client/src/dhis2w_client/generated/v42/oas/grid_header.py
AnalyticsMetaData
¶
Bases: BaseModel
Typed view over Grid.metaData — dimension lookups + item descriptors.
DHIS2 returns metaData as a bare JSON object with two stable sub-keys
(items and dimensions) plus freeform extras that vary by request.
This helper parses the raw dict into those typed fields; callers lift
a Grid.metaData dict via AnalyticsMetaData.model_validate(grid.metaData)
when they want to walk dimensions["dx"] / look up items[<uid>].name
/ etc. without writing their own dict-walking.