Create the cui.js object

The cui.api() call creates the cui.js object, which is then used to make all subsequent calls.

 // Declare a globally-scoped object in your App
 // to hold the reference to your cui.js object.
 var myCuiJs = {};

 // Create the cui.js object...
 cui.api({
    // ... setting the following properties.
    defs: ['https://cuijs.run.covisintrnd.com/defs/iot.json'],
    serviceUrl: 'PRD'
 }).then(function (returnedObj) {
    // ... copy the returned obj to your globally-scoped object.
    myCuiJs = returnedObj;
 });

The options parameter

The cui.api() call takes an options object as its only parameter. A detailed list of all options properties is available, but at a minimum, an App specifies the defs and serviceUrl properties.

options.defs

  • An array, whose objects define the API calls to expose to the App. If the object is a string (as in the example above), it is presumed to be a URL to remotely defined definitions.
    • Most Apps will simply use these pre-defined call definitions, which are loaded asynchronously, from the cui.js server.
    • Remotely loaded calls are evergreen. They will always resolve to the latest available version of the APIs.
  • It is also possible to load calls synchronously when they are locally defined.
    • Locally loaded calls are static. They will only resolve to the specified version of the APIs.

options.serviceUrl

  • The server to which the App will send its API calls.
  • The value can be a recognized API platform abbreviation or an explicit URL.