DHIS 2 API for pulling Period Based on Data Set Name selected

Do we have an API for dynamically pulling the Period based on the Data Set selected?

Currently am using the following API for pulling the DataSets

For pulling the Data Element Names based on the DataSet

Do we have something like below for pulling Periods?

Hi @mountain, thanks for the question!

I think what you are looking for is either the periodType or dataInputPeriods fields of the dataSet, is that correct? It’s these two fields in the Maintenance app.

Screen Shot 2020-06-26 at 3.16.23 PM

If so, those are stored as fields on the dataSet object, which you can access by adding a fields parameter to the dataSets.json API call:

Instead of using multiple network requests and filters, it is more efficient to use the field expansion capabilities of the DHIS2 api within a single request.

This will select the dataSet ID, period type, dataInputPeriods, and the name and id of each affiliated dataElement within a single API call:


You can do the same with the dataSets.json collection endpoint as well, so that you can retrieve this for multiple dataSets, if you want:


1 Like

Hello @austin, Thank you for that solution.
I’m developing an App using javascript and once I select a data set, I want to be able to dynamically pull the DataSet Period for data entry as below:

Hope this clarifies my problem.
Remember if one selects a Period that is not mapped according to how it was set, the Data Elements will not be pulled.

Hi @mountain - sorry for the delayed response.

I get what you are trying to do here, it’s a good question. The current Data Entry app does not fetch these periods from the API, so I am not sure they are exposed in the API itself. @jan or @Lars might be able to confirm that.

Hello @austin,
Thank you for the feedback. I will wait on @jan and @Lars to confirm on how this can be achieved.