I have been doing more and more RESTful calls and I had a few questions on best practice.
I have a scripting module dedicated to the REST service and I am calling this from specific windows. I'm am getting stuck going down a rabbit hole in terms of where things should be stored and called from.
Right now, my windows upon startup send calls for status updates then there are buttons for the rest of the things were trying to do and displayed on that screen respectfully. I have custom fields on the root for the returned information.
Are there any best practice in terms of were you are calling the scripts, where you are storing the results, how you are using your timer scripts, etc....
Since you mention "Windows", I presume this is Vision. But much below would apply to Perspective, too.
Call all APIs from the gateway, not from clients, unless there's a very specific bandwidth advantage to the latter. This eliminates the need to have the client know any API tokens or other credentials, and allows you to cache results across clients.
Use gateway timer events to call APIs for live status data common to all clients. Publish via memory tags in the simplest (preprocessed) format practical. (Or, if using my Integration Toolkit, use expression tags with globalVarMap() to extract and propagate cached values without creating any gateway config DB churn.)
In Vision, use system.util.sendRequest() with a gateway message handler to perform updates or actions in the web API. This gives the gateway a chance to automatically update live status tags that might be affected.
All such code needs to be in project library scripts, where you can cache an instance of system.net.httpClient(), and where you can cache API results for sharing.