Get Device entities in an external script

Hi, I need to make a script that takes a device ID as argument and uses it to get a list of the entities related to that device in HA (and then i will do more things with that info but it is not relevant for this case). I have been searching on how to do this but it seems that it is not supported by HA. Is there any already implemented way to do this? If it is not, i guess i will have to make an integration myself but it doesn’t make sense to me that there is nothing.

I presume you mean using the HA api. You can use the template request to do this. Ie

POST to

/api/template

With

{
"template": "{{ device_entities('device id') }}"
}

And it will return a list of entities for that device id