Web API example
Starting point to programm playbacks using the Web API. Inspired by a project where the customer shall be able to program simple cues. Also this might be the starting point for more sophisticated applications.
Also this solves the mystery about the 'separate programmer'.
author, date | Sebastian Beutel, February 2022 |
---|---|
published | here, Youtube |
prog. lang./ framework | simple text editor (I used the Web API Demo to play with the requests) |
description | collection of http requests used to program simple cues. |
other requirements | This is essentially just a collection of requests. You can send them with a web browser or with other tools. |
By default the Web API is available on network port 4430 (hence the requests start with something like 'http://localhost:4430/…'. Also, actions on the user interface, e.g. changing pages or selecting fixtures, do not reflect in the Web API. In turn anything done in the API doesn't reflect in the normal user interface, e.g. if you select fixtures or set a level you won't see it in Titan. This is pretty much like the blind mode or another user. Unfortunately this makes it really hard to debug any API requests as you see the outcome only when everything is correct and you did succeed programming something.
However there is a solution: you can tell Titan to also listen on another port, with the user and interface you see directly in Titan. In order to do this you need to set specific parameters:
C:\Program Files\Avolites\Titan Mobile\Mobile.exe.config
)<appSettings>
part<add key="webapi.enabled" value="true" /> <add key="webapi.port" value="4431" />
false
to true
In order to make it easier to work with these settings the WebAPI test page now also features a port toggle button where you can switch between port 4430 and 4431:
The intention of this example is to make it possible to program simple playbacks using the API. Hence the actions and requests are as follows:
Of course this can be extended to some degree, e.g. set another attribute (if the fixtures have more than just a dimmer channel), record-merge or record-replace if the handle is already in use, delete the playback etc. Please also note the different ways of spedifying a certain item (i.e. the location): some commands refer to the current page of playbacks or of another window while others can work on any page, some commands use the userNumber while others use the location, some indexes are 0-based while others are 1-based… I strongly suggest reading the macro article on identifiers as this is closely related.
You can download the API demo config here and load it into the Web API Demo Site: api_demo_programming_playbacks.txt