# API to retreiving TEIs from multiple programs

**URL:** <https://community.dhis2.org/t/api-to-retreiving-teis-from-multiple-programs/50314>\
**Category:** Support - Assistance technique\
**Created:** [27 October 2022 09:44 UTC](https://community.dhis2.org/t/api-to-retreiving-teis-from-multiple-programs/50314 "2022-10-27T09:44:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pacifique\_Hategekima](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/pacifique_hategekima/32/33413_2.png) [@Pacifique\_Hategekima](https://community.dhis2.org/u/Pacifique_Hategekima)\
**Post date:** [27 October 2022 09:44 UTC](https://community.dhis2.org/t/api-to-retreiving-teis-from-multiple-programs/50314/1 "2022-10-27T09:44:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gassim](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/gassim/32/35347_2.png) [@Gassim](https://community.dhis2.org/u/Gassim)\
**Post date:** [28 October 2022 16:17 UTC](https://community.dhis2.org/t/api-to-retreiving-teis-from-multiple-programs/50314/2 "2022-10-28T16:17:00Z")

</div>

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](https://play.dhis2.org/2.39.0/api/trackedEntityInstances?trackedEntityType=nEenWmSyUEp&ouMode=ALL&fields=*&pageSize=1&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](https://community.dhis2.org/t/api-wiki-post-developers-collaborate-here-with-api-q-as-tips-you-find-helpful-for-other-developers/46011) and tag you there, thanks! Hope this helps! If it solves the question please mark as solved.
