How to poll for restful data in a script?

On a HA event I wish to trigger a script, passing an id.

In that script, amongst other things, I want to wait for a restful API to indicate completion. I’m happy to check every 3 seconds or so. The id is arbitrary so I don’t believe I can set up a sensor, although I have created a rest_command (which succeeds but doesn’t actually do anything when called, which is understandable given it uses GET).

How can I access arbitrary restful data in a script like this? I’m expecting to be passed some data like I do after a trigger condition for example.