Understanding The KeepKey REST API

Highlander
KeepKeyDevs
Published in
3 min readJan 23, 2023

TL:DR build on keepkey today with our new SDK: https://www.npmjs.com/package/@keepkey/keepkey-sdk

Fixing the largest point of friction in the KeepKey Ecosystem.

Terms:

  • WebUSB: the web protocol in which your host machine is communicating to your KeepKey Device
  • HID: the native USB protocol in which your host machine is communicating to your KeepKey Device
  • Browser: A web Browser for example chrome/brave browser
  • Electron: A native application framework that runs outside of a web-browser on your host machine.

TL:DR Now we can do this

Here I am demonstrating some simple things that you have never been able to do with a KeepKey until now.

In this screenshot I have open

  1. Firefox open and paired a KeepKey with app.shapeshift.com
  2. a chrome tab and the same KeepKey paired as well
  3. KeepKey Desktop’s built in browser with ShapeShift Open

All three of these applications are connected simultaneously, functional, and can be interacted with seamlessly.

Why was something so simple not possible before?

WebUSB vr REST

WebUSB was the primary interface for KeepKey prior to our acquisition. The architectural decision to build on this protocol severely limited applications and potential integration partners.

WebUSB has a limitation of claimInterface, which allows only one application to access the device at a time.

Friction and pain

This limitation, that only 1 interface is able to claim an interface, has plagued KeepKey users for years. Not only that, but the first application that claims a device can lock onto that device, and prevent a new application from ever connecting. For instance if you have a tab of app.shapeshift.com open in the background, no new windows may connect to your KeepKey.

And firefox and safari users just plain have not been able to use their KeepKey because those browsers do not support WebUSB.

The Solution: The New KeepKey Desktop

KeepKey desktop is now the primary interface for anyone wishing to build on KeepKey. This application provides native HID USB drivers for firmware updating, manages advanced features like PIN management in BIP39 mnemonics so integrators don’t need to account for them, and most importantly, provides the new KeepKey REST interface hosted on the user’s localhost.

Introducing the KeepKey REST interface.

(you can view this developer documentation on http://localhost:1645/docs or by going to settings/Open API developer documentation)

KeepKey-SDK the new developer KIT

All applications wishing to integrate KeepKey now have a new developer toolkit.

KeepKey-SDK:

This npm package provides full access to the KeepKey’s rest API and provides typescript typing for coding assistance.

Case study:

Integrating this REST interface into shapeshift.com

HDwallet-REST

At the core of app.shapeshift.com is its HDwallet package.

You can view a live preview of this feature coded here:

https://github.com/shapeshift/web/pull/3678

And thats it! this new KeepKey REST api is a building block for future amazing applications to integrate and allow their users to leverage self custody.

Interested in building multi-chain dapp’s for KeepKey?

check out this tutorial.

--

--