Best way to request data from outside API on demand

I’m giving the fairly-new Obihai component a try. I’m replacing a pretty janky perl script that I currently have polling the Obi’s admin page.

One of the things I like about my perl script is that I have the caller’s name looked up via OpenCNAM. They have a nice, inexpensive API to turn phone numbers into CID names.

I’d like to strip the phone number part out of the Obi data and get the name from OpenCNAM. It doesn’t look like RESTFul comands keep the response.

Is my best bet to use a shell_comand, make the OpenCNAM call, then use HA’s API to put the returned value into an input_text or similar? Or is there a better way?

Revisiting this because I haven’t found a good solution.

I want to set up an automation that watches the state of the Obihai component’s last caller sensor, then use the phone number to do a call to OpenCNAM.

I can figure out the regex to isolate the caller’s number in the sensor. I know how to make a call to HA’s API to make a service call with the data from OpenCNAM.

But I’m not familiar with Python enough to correctly modify the Obihai component without assistance.

And I looked at the python_script component, but it doesn’t allow imports or include the python requests/get library.

I looked at Appdaemon, but that seems like overkill.

I need something like a RESTful sensor that doesn’t keep checking on an interval, but allows me to update it when needed.

Any suggestions?