HomeAssistant new endpoints

Hi everyone, I am trying to create my custom endpoints for example I would like rest endpoint where I can get the temperature from my device which I would get calling some url.
To be more cleare here is some flow:
I call rest endpoint from my frontend application in react → home assistant rest endpoint receives request and after that sends new http request to the device → device responds with his current temperature → home assistant receives temperature from device and then responds to the first request (from frontend in react) with temperature from device.

So please if anyone could send me some example of that in code or tell me what should I do (Ieverything is still unclear because I just started with home assistant)