# Additional HTTP Endpoints

## Overview <a href="#overview" id="overview"></a>

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/Changing the HTTP Port <a href="#finding-the-base-url" id="finding-the-base-url"></a>

Every time Captivate launches, it attempts to start a web server on port `9022`. If that port is in use already, Captivate will fail to start properly. If something on your system needs to use that port, you can choose a different port by setting the value for `Generic HTML.httpPort` in the Windows Registry or in the Mac user preferences.

Mac example:

```bash
defaults write com.NewBlue.Captivate `Generic HTML.httpPort` 9099
defaults read com.NewBlue.Captivate `Generic HTML.httpPort`
```

> Note: the WebSocket port is usually `9023`, but can be specified in the same way with the registry setting `Generic HTML.webSocketPort`.

### /temp/`FOLDER`/`FILE.EXT` <a href="#tempfolderfileext" id="tempfolderfileext"></a>

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:**

```javascript
const url = 'https://newbluefx.com/wp-content/uploads/2019/07/nb_logo.png';
const data = await ServiceHandler.scheduler.scheduleCommand('downloadImage', { url }, {});
/*
{
	"command": "downloadImage",
	"mime": "image/png",
	"path": "/private/var/folders/gj/8bp694f15qb2zhl4q3l5ns700000gn/T/TitlerLive/f94ffb6f-5c98-4f46-a711-36e35f53a1c2/43ab9e0e-7c69-49cf-8530-e0f54dc9bd0e.png",
	"reply": "downloadImage",
	"size": "2601",
	"success": true,
	"tempUrl": "http://192.168.10.50:9022/temp/f94ffb6f-5c98-4f46-a711-36e35f53a1c2/43ab9e0e-7c69-49cf-8530-e0f54dc9bd0e.png",
	"url": "https://newbluefx.com/wp-content/uploads/2019/07/nb_logo.png"
}
*/
console.log(data);
```

### /api/title/`TITLE_ID` <a href="#apititletitle_id" id="apititletitle_id"></a>

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.

```sh
# 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.

```sh
curl 'http://localhost:9022/api/tunnel'
```

## Additional NodeJS-basedased Endpoints <a href="#additional-http-endpoints" id="additional-http-endpoints"></a>

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 <a href="#using-the-discovername-endpoint" id="using-the-discovername-endpoint"></a>

Since 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.

```sh
curl 'http://localhost:9024/discover/_googlecast._tcp.local'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.newbluefx.com/captivate-api/advanced-api-reference/additional-http-endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
