npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

roku-api

v1.1.0

Published

A simple, yet functional implementation of the Roku External Control Protocol for roku-enabled devices

Downloads

12

Readme

roku-api

roku-api is a complete Typescript implementation of the Roku "External Control Protocol" API. Built using ECMAScript modules, this package is compatible in the browser out-of-the-box!

Features

  • Full control of Roku devices, as if using the remote
  • Volume and TV power control
  • Simple discovery of Roku devices on network (Not possible on frontend)
  • Switch TV inputs instantly
  • Content deep linking using launch method see Deep Linking
  • Access to Roku app icons for interface building

Installation

to install:

npm install roku-api

to import (ESM-only):

import { Roku, discover } from "roku-api"

Usage

Roku Class:

Instantiation

import { Roku } from "roku-api"

const ip = "0.0.0.0"
const roku = new Roku(ip)

Methods

  • roku.keypress(key: string) keypresses key
  • roku.keydown(key: string) begins holding down key
  • roku.keyup(key: string) releases key
  • roku.keypressLetter(letter: string) keypresses ASCII letter. Useful for keyboard input fields
  • roku.holdKey(key: string, time: number) holds key for time milliseconds
  • roku.info() returns object containing the devices properties, state, and configuration
  • roku.player() return object with current media state and playback service
  • roku.icon(appid: string) returns promise of BLOB containing app icon photo
  • roku.apps() returns Map with appids as key and object containing name and version as value
  • roku.launch(appid: string, contentID?: string, mediaType?: string) launches app by id with optional contentID and mediaType for deep linking

Self explanatory keypress aliases

  • roku.home()
  • roku.reverse()
  • roku.forward()
  • roku.play()
  • roku.up()
  • roku.down()
  • roku.left()
  • roku.right()
  • roku.instantReplay()
  • roku.options()
  • roku.search()
  • roku.backspace()
  • roku.enter()

Roku-enabled TV controls

  • roku.volumeUp()
  • roku.volumeDown()
  • roku.volumeMute()
  • roku.powerOn()
  • roku.powerOff()
  • roku.powerToggle()
  • roku.switchToInput(input: string) Supported Inputs: ["Tuner", "HDMI1", "HDMI2", "HDMI3", "HDMI4", "AV1"]

Discovery function

Usage:

import { discover } from "roku-api"

async function foundRoku(roku) {
    console.log(await roku.info())
}
discover(foundRoku)

function discover(callback: (device: Roku) => void) uses Roku SSDP api to discover local network roku devices. runs callback with a Roku instance argument when found. function self-destructs after five seconds of discovery.

Deep Linking

Deep linking is a key feature of the ECP API because it allows you to open specific resources on applications. This can be used for playing certain movies or videos on streaming services. Deep linking is implemented using the launch method and providing a contentID parameter; the contentID value is dependent on the app's own logic Example:

import { Roku } from "roku-api"

const ip = "0.0.0.0" // Example IP
const roku = new Roku(ip)

// Launch YouTube Video (YouTube Appid: 837)
const contentID = "dQw4w9WgXcQ" // Extracted from YouTube share link
roku.launch("837", contentID)

Contributing

Any suggestions, issues, pull requests, or help is appreciated. This was intended to be an open and shut API implementation, but I will modify it if necessary or wanted.