question

Upvotes
Accepted
68 3 4 8

Organization of objects

Hello everybody,

In most examples of code, objects (InstrumentList, ReportTemplate, Schedule ...) are created, used, and then deleted.

Considering that they can be called either by the API or by the web interface, in what extent would it be a good idea to avoid to suppress the objects systematically, and to rather initiate them with get() methods rather than create them each time ?

That way we can imagine a way to allow users to add some data in a list, the code would create the object again with default values when the expected object is not found on the server.

For this reason I imagine it would then be a better idea to designate an object by its description than its id.

Did I miss a main restriction against this conception ?

tick-history-rest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
13.7k 26 8 12

@Hubert CANEVET, the samples related to scheduled requests systematically delete the objects (instrument list, report template, schedule) for one simple reason: because they are demo code, and we do not want to clutter up your environment with demo objects !

Deleting or re-using those objects depends on the workflow you want to create. But be aware that both are possible, and there is no absolute answer.

The situation is different for samples related to On Demand requests, because On Demand requests do not create any permanent objects on the server, everything is done on the fly.

Selecting between scheduled and On Demand queries also depends on the workflow you want to create, and again, there is no "one size fits all" answer. More on the difference between these 2 basic workflows is described in the Tutorials Introduction, here.

Note that an On Demand request can also use an instrument list defined and saved on the server (like that used by a scheduled request). More on that in REST API Tutorial 11.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
68 3 4 8

Oh quite clear, thank you.

So as I understand the answer is to be discussed with the business.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@Hubert CANEVET, you need to understand what the use case is, and then you can determine what workflow suits it best. Note that you can also request some data using schedules (that would typically be data you request through a regular night batch), and other data using On Demand requests (for adhoc queries). So it is really up to you.

The API Explanation video also describes these workflows, starting at 04:45, you might find this useful as well.

Click below to post an Idea Post Idea