API call to get all identities of a type?

Is there a (REST) API call to get all identities of a certain type (domain)? For example get all persons or all lights or all sensors. What I can see from the documentation is that it is possible to get all identities (or rather states) across all domains, but then I have to filter the response myself in my code.

Thanks

There is nothing wrong with filtering imho.
How about this?

Apologies, I should have given more context. I’m writing a single page (web) app as a custom frontend using JavaScript. So I’m using the REST API.

does that mean that you access everything using REST API?
Unfortunately, I’ve no practical experience in this…

I don’t think there is call for all lights, for example, but I think you can just use “api/states” then filter the entity_Id for desired domain.

This will work since entity I’d will be like “light.twenty” or “binary_sensor.motion”.

Yes that was my understanding. Thanks for confirming.


Hi, @tmjpugh, I try this with Postman and not work fine. The API calls returns the same response.

CALL1: baseURLforYourHA/api/states

CALL2: baseURLforYourHA/api/states?entity_id=binary_sensor.my_sensor

Both returns all states.

How can i filter with query params?`

1 Like