Build a control panel in Retool
Build your own control panel in Retool: buttons that put graphics on air, forms that change their data, and a live view of what's showing.
You need an output with a composition, and an API key that controls it. Owners and admins make keys in Organisation settings › API keys.
Add Airframe as a resource
A Retool resource stores the API key on Retool's servers. Your key never reaches the browsers of the people using the app.
- In Retool, open Resources and choose Create new › Resource, then REST API.
- Name it
Airframe. - Set Base URL to
https://api.airframe.tv/v1. - Under Headers, add
Authorizationwith the valueBearer afk_…, using your key. - Choose Create resource.
Send a command
Make a query that puts a lower third on air with the name typed into a form.
- In your app, add a Text Input named
nameInputand a Button labelledTake. - In the code panel, add a Resource query named
takeLowerThirdthat uses theAirframeresource. - Set the method to POST, the path to
outputs/OUTPUT_ID/commands, and the body type to JSON. - Set the body to the command, with the name from the input:
{
"commands": [
{ "command": "in", "component": "lower-third", "data": { "name": "{{ nameInput.value }}" } }
]
}- On the button, add an event handler: on Click, Control query
takeLowerThird.
Replace OUTPUT_ID with the output's id, the last part of its browser source URL, and lower-third with your component's id. The commands page lists every command you can send.
Clear the output
Make a second query, clearAll, the same way, with this body, and run it from a Clear button:
{ "commands": [{ "command": "out", "scope": "root" }] }Show what's on air
- Add a query named
outputStatethat sends GET tooutputs/OUTPUT_ID/state. - Set it to run when the app loads, and in its advanced settings, to run periodically, every 2 seconds or so.
- Show its data in components, for example a Table with data
{{ Object.entries(outputState.data.onAir) }}, or text reading{{ outputState.data.data.global.homeScore }}. - Add a success handler to
takeLowerThirdandclearAllthat triggersoutputState, so the view updates straight after a take.
Get the output's state describes everything it returns.
Tips
- Batch related changes. A score change and a goal animation can go in one request, so they land together: an
updatethen aninvoke. - Mind the rate limit. Keep polling to every second or two. Each key can send 200 command batches every 10 seconds; see Errors and rate limits.
- Show errors. A failed command answers
422with the reason and which command failed. Add a failure handler that shows a notification with{{ takeLowerThird.error }}so operators know when a take didn't happen.