Hi all,
How can I download Data elements and their UIDs side by side from a specific data set through an API?
Thanks
Hi all,
How can I download Data elements and their UIDs side by side from a specific data set through an API?
Thanks
You can specify the DataSet in the API request and then append the elements you want to extract. This is a valid example (giving you name and id of the dataElements):
https://play.dhis2.org/2.39.1.1/api/dataSets/lyLU2wR22tC?fields=dataSetElements[dataElement[id,name]]
The dataSet comes in the API request, but you could also obtain it in the response if you want:
https://play.dhis2.org/2.39.1.1/api/dataSets/lyLU2wR22tC?fields=dataSetElements[dataSet[id],dataElement[id,name]]
@jaime.bosque s answer should get you exactly what you are asking for, but just to add, if you want the output as a flat file (CSV) you could access the dataElements resource, such as
https://play.dhis2.org/2.38.2.1/api/dataElements.csv?paging=false&fields=id,name&filter=dataSetElements.dataSet.id:eq:ce7DSxx5H2I
Where ce7DSxx5H2I
is the data set UID
See Metadata - DHIS2 Documentation
For more filters and examples