API to retreiving TEIs from multiple programs

Dear community,
@Gassim is there an API call I can use to retrieve TEIs from multiple programs?
api/33/trackedEntityInstances.json?ou=yo0lKXKCRuf&ouMode=DESCENDANTS&Program=FqRBREuA6wL&pageSize=300&fields=*
as you can see here only one program is specified, how can add another program in a single call

Thank you

Pachat

2 Likes

Dear @Pacifique_Hategekima

Thank you for your question! Yes, it’s possible! The trackedEntityInstances requires either the program name to be specified or the tracked entity type so if you want to retrieve all TEIs from multiple programs you could use the trackedEntityType parameter. You’d need to either specifiy a specific ou (and it’s children or decendants if required) or you could use ouMode=ALL to retrieve all TEIs from all OUs.

Here’s an example, https://play.dhis2.org/2.39.0/api/trackedEntityInstances?trackedEntityType=nEenWmSyUEp&ouMode=ALL&fields=*&pageSize=2&totalPages=true note that I added pageSize=1 because I used fields=* which is not recommended but I did that so you could choose which fields you want returned then you can remove (pageSize & totalPages)

I like these API questions. I will add your inquiry to the API wiki and tag you there, thanks! Hope this helps! If it solves the question please mark as solved.