How to get only certain attributes from api/tracker/trackedEntities

Hi there,

Can anyone help me to get a list of certain attributes from the API point api/tracker/trackedEntities.
I have tried /api/tracker/trackedEntities.json?program=vXMY3ACeWzL&orgUnit=IriQd2CiCRk&ouMode=ALL&attributes=kmzHA3cJtLx&filter=kmzHA3cJtLx:IN:ABC221;XXX291
But still got full list of attributes, which I really don’t needed :frowning:

Thanks

1 Like

Hi @Ulanbek

I am not able to filter out the specific attributes but it’s getting the same result as you are but I also noticed that the Line Listing app as well as the Capture app are retrieving all the attributes and then use their own logic to filter/display the attributes.

Do you think it’d be possible in your use case to do the same?

Hi @Gassim,

as long as I couldn’t get desired attribute list, I have decided to apply different strategy. Instead of getting the list of elements by multiple API request, I have retrieved only the TEI where the attribute value in the list of values
/api/trackedEntityInstances/query.json?program=vXMY3ACeWzL&ouMode=ALL&paging=false&attribute=kmzHA3cJtLx:IN:value1;value2;value3… It gave me 2 things in one go:

  1. I have got less API requests, as I can check in one go about 300 values
  2. the result will be short and easy to process

So basically I changed the program logic

SO maybe one day we will be able to get only the list of TEAs and DEs we want to retrieve from TEIs and EVENTs.
Let’s wait for it :slight_smile:

1 Like

Hi @Ulanbek

Thank you for sharing the new logic that solved the first problem.

Please note that this endpoint is a deprecated one and will be removed in version 42. See deprecation warning in docs, Tracker - DHIS2 Documentation