Additional HTTP Endpoints
Overview
In addition to the API functions described in Controller API Reference and External API Reference, we also have a number of simple HTTP endpoints that will allow you to get certain forms of data quickly and easily.
Finding the Base URL
Every time Captivate launches, it attempts to start a web server on port 9022. If that port is in use already, it will try other ports. You can see this port by adding any web-based controller to your project (like the JSON Command Tester). Right click in the controller window and choose “Copy URL” from the popup menu. The HTTP port will be specified in a query parameter named “port.”
Note: this HTTP port will always be different from the WebSocket port used for the Javascript API.
/temp/FOLDER
/FILE.EXT
FOLDER
/FILE.EXT
Captivate stores all files including images downloaded from the Internet using the downloadImage
command in a temporary folder assigned by the operating system. The Captivate API can access these local files directly through the file system, but controllers can get them through regular HTTP calls to this endpoint.
Example:
let url = 'https://newbluefx.com/wp-content/uploads/2019/07/nb_logo.png';
ServiceHandler.scheduler.scheduleCommand('downloadImage', { url }, {}, (e) => {
/*
{
"command": "downloadImage",
"path": "/var/folders/gj/8bp694f15qb2zhl4q3l5ns700000gn/T/CaptivateLive/54a2c74c-a72e-44af-b6e4-e49f28ad9d8f/4af4695f-835a-44cc-bb1a-5ef796e6b42e.jpg",
"reply": "downloadImage",
"success": true,
"url": "https://newbluefx.com/wp-content/uploads/2019/07/nb_logo.png"
}
*/
console.log(e);
/**
* Keep only the last two segments of the returned path, and you can access the image anywhere on the network:
*
* http://localhost:9022/temp/54a2c74c-a72e-44af-b6e4-e49f28ad9d8f/4af4695f-835a-44cc-bb1a-5ef796e6b42e.jpg
*/
});
/api/title/TITLE_ID
TITLE_ID
Captivate allows you to get the XML definition file for any title using this HTTP call. Just remember to include the curly braces as part of the TITLE_ID
and urlencode them.
# Get XML for title {b960a28b-e583-4f3f-b54b-851ef481314d}
curl 'http://localhost:9022/api/title/%7Bb960a28b-e583-4f3f-b54b-851ef481314d%7D'
/api/tunnel
Captivate allows you to get the information on the current websocket tunnel by making a GET request to this endpoint.
curl 'http://localhost:9022/api/tunnel'
Additional NodeJS-basedased Endpoints
When Captivate runs, it launches a small nodejs-based server behind the scenes. That server also provides a few API endpoints you can access. Many of these endpoints are used by our own controllers, but they are documented here for your use too.
Using the /discover/:name
endpoint
/discover/:name
endpointSince Captivate uses MDNS to broadcast itself on the network and to find services it knows about, it maintains a database of discovered services and allows you to browse them easily using the API.
curl 'http://localhost:9024/discover/_googlecast._tcp.local'
Last updated