Skip to content

Latest commit

 

History

History
303 lines (205 loc) · 10.3 KB

api.md

File metadata and controls

303 lines (205 loc) · 10.3 KB

Roku Class API

Relevant resources

Methods

activeApp() ⇒ Promise<RokuApp>

Retrieves information about the current application

activeChannel() ⇒ Promise<RokuActiveChannel>

Retrieves information about the currently tuned TV channel. Restricted to Roku TV devices that support live TV

app(appInfo) ⇒ App

Creates a new instance of the App class

Param Type Description
appInfo RokuAppInfo App information (id required)
const apps = await myRoku.apps();
const firstApp = myRoku.app(apps[0]);
const neflix = myRoku.app({ id: 12 });

apps() ⇒ Promise<RokuApp[]>

Retrieves information about the device's applications

channels() ⇒ Promise<RokuChannel[]>

Retrieves information about the TV channel / line-up available for viewing in the TV tuner UI. Restricted to Roku TV devices that support live TV

static discover(timeout?) ⇒ Promise<SSDPDevice[]>

Discovers local devices using SSDP. This is a static method

Param Type Description
timeout number Timeout duration in milliseconds
const devices: SSDPDevice[] = await Roku.discover(5000);
console.log(devices);

get(path, params?) ⇒ Promise<Response>

Sends a GET request, with optional parameters

Param Type Description
path string Request path URL
params Object Request parameters

icon(id) ⇒ Promise<Response>

Returns an icon corresponding to the identified application

Param Type Description
id number The id of the app
const ws = createWriteStream(__dirname + "/out.png");
myRoku.icon(837).then((res) => res.body.pipe(ws)); // YouTube app icon

info() ⇒ Promise<RokuDevice>

Retrieves information about the device

input(options) ⇒ Promise<Response>

Sends custom events to the current application

Param Type Description
options InputOptions Input parameters

install(id) ⇒ Promise<Response>

Exits the current channel, and launches the Channel Store details screen of the identified app.

Param Type Description
id id The app ID

keyDown(key) ⇒ Promise<Response>

Equivalent to pressing the identified remote control key

Param Type Description
key Keys The key to be pressed

keyUp(key) ⇒ Promise<Response>

Equivalent to releasing the identified remote control key

Param Type Description
key Keys The key to be released

launch(id, options?) ⇒ Promise<Response>

Launches the identified app. Can accept launch parameters for deep linking

Param Type Description
id number|"dev" The id of the app
options LaunchOptions Launch parameters (for deep linking)
// launch the dev channel:
myRoku.launch("dev");
// launch Netflix, loading a specific show:
myRoku.launch(12, { contentId: "70206978", mediaType: "series" });

launchChannel(id) ⇒ Promise<Response>

Launches the identified channel. Restricted to Roku TV devices that support live TV

Param Type Description
id number The channel number

mediaPlayer() ⇒ Promise<MediaPlayerInfo>

Retrieves information about the current stream segment and position of the content being played, the running time of the content, audio format, and buffering

post(path, params?) ⇒ Promise<Response>

Sends a POST request with no body, and optional parameters

Param Type Description
path string Request path URL
params Object Request parameters

press(...keys) ⇒ void

Equivalent to pressing down and releasing the identified remote control key. Can accept keyboard alphanumeric characters when a keyboard screen is active

Param Type Description
keys (string|Keys)[] An array of keys to press, or characters to type
const sequence: Keys[] = [Keys.DOWN, Keys.DOWN, Keys.RIGHT];
myRoku.press(...sequence);

search(options) ⇒ Promise<Response>

Enables an external client to drive the Roku Search UI to find and (optionally) launch content from an available provider

Param Type Description
options SearchOptions Search options
myRoku.search({ keyword: "Game of Thrones" });

secretScreen(screen) ⇒ void

Equivalent to pressing the ten-to-twelve key pattern to launch a secret screen on the Roku screen. Only two screens are supported by the ECP (HDMI Info Screen and Channel Info Screen)

Param Type Description
screen Screen The secret screen code
myRoku.secretScreen(Screens.CHANNEL_INFO);
myRoku.secretScreen(Screens.HDMI_INFO);

sensor(input, values) ⇒ Promise<Response>

Sends custom sensor events to the device

Param Type Description
input SensorType The sensor type
values Dim3Values The sensor input values

touch(values, op?) ⇒ Promise<Response>

Sends custom touch or multi-touch events to the device

Param Type Description
values Dim2Values The touch input values
op TouchOp The touch operation

type(input) ⇒ void

Types alphanumeric characters, provided a keyboard screen is active

Param Type Description
input string Text to be typed
myRoku.type("Phoebe Bridgers");

wait(ms) ⇒ Promise<boolean>

Wait between key presses

Param Type Description
ms number Delay time in milliseconds
// hold the down button for two seconds:
myRoku.keyDown(Keys.DOWN);
myRoku.wait(2000);
myRoku.keyUp(Keys.DOWN);