Download data elements along with their respective Category Option

Dear DHIS2 family,
What is the best way to download data elements along with their respective Category Option Combinations (COCs)? I am working on DHIS2 integration and need to know all the data elements and their respective COCs for data mapping.

Hi @Shapr0019

Have you tried downloading the metadata and metadata dependency using the Import / Export app?

SQL Queries could do it but it’s a long undocumented process that probably the API covers probably better, so maybe another option would be the API?

I’d use the data elements API endpoint and select the necessary fields, here’s a quick example, but for actual use, you’d need to make sure that all the required fields are included: DHIS 2 Demo - Sierra Leone]

Please note that downloading the request above will only give the first level and not the nested level. For example, if you add .csv after dataElements, the downloaded file will only show the columns: displayName aggregationType valueType which are not the nested ones, so maybe use an external converter to convert the JSON result to CSV or created an API request for each endpoint (dataElements, categoryCombos, categoryOptionCombos)

You could also make use of the ‘filter’ option too…

I hope this helps.

Thank you very much for API field DHIS 2 Demo - Sierra Leone. I have managed to create python script and downloaded using API

1 Like