exequiel-sosa
alal
← Back to blog
[react]May 24, 2026· 3 min read

Demystifying Roku's ECP API

Building an in-browser Roku TV remote with TypeScript and exploring the External Control Protocol

Roku TV remote control
#typescript#roku#ecp

Introduction to Roku's ECP API

As a front-end developer, you might be surprised to learn that Roku devices come with a built-in HTTP API, known as the External Control Protocol (ECP). This API allows for remote control of the device, and it's surprisingly simple to use. In this post, we'll explore how to build an in-browser Roku TV remote using TypeScript and the ECP API.

Discovery and Connection

One of the first challenges you'll face when building a Roku remote is discovering the device on the network. While many tutorials suggest using SSDP multicast, I found that having the user enter the IP address manually is a more reliable approach. You can use the fetch API to send a request to the device and verify that it's responding.

const response = await fetch('http://'+ ipAddress + ':8060/query/device-info');
   if (response.ok) {
       console.log('Roku device found!');
   } else {
       console.error('Roku device not found');
   }
   

Sending Commands

Once you've connected to the device, you can start sending commands using the ECP API. The API uses a simple HTTP POST request to send commands, and the command itself is specified in the request body. For example, to send the 'play' command, you would use the following code:

const response = await fetch('http://'+ ipAddress + ':8060/keypress/Play', { method: 'POST' });
   

Building the Remote

With the basics of the ECP API covered, you can start building the remote control interface. You'll need to create buttons for each command and attach event listeners to send the corresponding command to the device. You can use a library like React to render the interface and handle events.

Here's an example of how you might render a play button:

function PlayButton() {
       const handleClick = async () => {
           const response = await fetch('http://'+ ipAddress + ':8060/keypress/Play', { method: 'POST' });
       };
       return (
           <button onClick={handleClick}>Play</button>
       );
   }
   

Conclusion

Building an in-browser Roku TV remote using the ECP API is a relatively simple task, and it can be a useful tool for developers and users alike. By understanding how the ECP API works and how to send commands to the device, you can create custom remote control interfaces and integrate them into your own applications.

While the ECP API is powerful and easy to use, it's worth noting that it's not officially documented by Roku. This means that the API may change or break at any time, so be sure to test your implementation thoroughly and be prepared for potential issues.

// related

find me in:
linkedin
X
facebook