Entity filter not working in SDK

Hi!!

I am trying filter entities data in SDK but no working, that`s my code:

  const openedDoors = await Resources.entities.getEntityData(env.entity_id, {
    filters: {
      opened: '1',
    },
  });

This code always return all the entity data.

I am doing something wrong?

Hi Julihirmes,

The issue you’re facing is due to a misnaming of the filter parameter in the SDK. Instead of filters, the correct parameter name is filter. Additionally, the index parameter is required when filtering by a specific field.

Here’s how you can adjust your code:

// Filtering by a specific field

const result = await Resources.entities.getEntityData(“entity-id-123”, {

filter: { temperature: “30” },

index: “temp_idx”,

amount: 9999,

});

console.log(result); // [ { id: ‘record-id-123’, created_at: 2025-01-22T13:45:30.913Z, … }, … ]

If you encounter an “Authorization Denied” error, please verify the Entity / Access policy in Access Management.

This issue was addressed in this PR, and the fix should be reviewed and released in the upcoming weeks.

Let me know if you need further assistance!

Hi, Mateus!

Works here! Thanks!

I am using TS and I put a @ts-expect-error to compile properly.

Nice to know that have a PR to this.

Thanks again!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.