To coincide with our next release of MIDAS, v4.16, we’ll also be releasing an update to the optional MIDAS API.

If you’re not aware of our optional API access addon, it offers a programmatic and bi-directional interface to a MIDAS scheduling system.

The API can be used to extract data from a MIDAS system, which you can then format, process, and display within your own website and apps.

The API can also be used to make changes to settings/data within a MIDAS system, for example to automate the adding of new bookings.

Or, the API can be used to interface MIDAS with other 3rd party software apps…. the possibilities are near endless!

To further increase the power and usefulness of the MIDAS API, we’re adding a couple of significant features in the forthcoming API update:

NEW: Command Line Support

Until now, all calls to the API had to be made via HTTP transactions. With the next update, you’ll also be able to make API calls directly from the command line! (self hosted editions only). API calls made in this way have the added benefit of being significantly more efficient and faster (assuming the call is made from the command line on the same server as the MIDAS system), as they do not require an HTTP transaction to be conducted.

To make API calls from the command line, simply call “api.pl” (located within your server’s MIDAS directory) and pass API parameters and values via command line switches.

For example, to retrieve the currently installed version of MIDAS from the Windows command line (cmd):

A MIDAS API call made from the Windows Command line (cmd)

…or from Windows PowerShell:

A MIDAS API call made from Windows PowerShell

NEW: Optional JSONP Support

By default, the MIDAS API outputs in JSON format, however following feedback from API users, we’re also introducing optional JSONP support with the next update to the API.

If you don’t know what JSONP is, then you probably don’t need it!

JSONP is a method commonly used to bypass the cross-domain policies in web browsers. Typically, modern browsers won’t allow you to make AJAX (Asynchronous Javascript) requests from one domain to another domain perceived to be on a different server.

For example, if your MIDAS system is running on server A, and you wish to make client-side API calls through Javascript, you would typically only be able to make such AJAX requests from pages residing on server A itself. Attempting to initiate an AJAX request for server A from server B would be blocked by the user’s browser.

JSON and JSONP behave differently on the client and the server. JSONP requests are not dispatched using the XMLHTTPRequest and the associated browser methods. Instead, a <script> tag is created, the source of which is set to the target URL. This script tag is then added to the DOM (normally inside the element).

JSONP support in the MIDAS API (which is disabled by default) can be enabled via the API settings screen.

WARNING: Before enabling JSONP support, you should instead look to use CORS (Cross Origin Resource Sharing) wherever possible, as JSONP has inherent security risks as it injects Jasacript code directly into your web pages

With JSONP support enabled, you’d then be able to pass the name of a Javascript function in a “callback” parameter along with your API calls.

Consider a simple API call to retrieve the version number of MIDAS (passing the “action” parameter with a value of “get_setting“, and a “setting” parameter with a value of “version“). The typical JSON response would be:

{"version":"4.16"}

Now consider the same API call, with JSONP support enabled, and an additional “callback” parameter passed with a value of “myfunction“. The JSONP response would then be:

myfunction({"version":"4.16"})

The “callback” parameter must contain the name of an existing Javascript function on the calling page.

Upon receiving the JSONP response, the user’s browser will execute the “myfunction” Javascript function, passing the JSON data {"version":"4.16"} to it accordingly.