-
Notifications
You must be signed in to change notification settings - Fork 3
WebSocket API
KeyChain contains a WebSocket API. This API can be used to stream information from a KeyChain instance to any client that implements WebSockets. Implementations in different languages:
- NodeJS
- Python
- JavaScript/HTML
- etc
Connect your WebSocket implementation to http://localhost:16384/
.
Here you will find the code of the demo page that connects to WebSocket. This page will be automatically installed together with the KeyChain.
On this demo page you can test the KeyChain commands.
Each WebSocket API message is a JSON serialized object containing a command with the corresponding parameters.
For full comprehensive descriptions of the commands, acceptable parameters and values, go to the Protocol.
The following will show the usage of websocket connections. We make use of the wscat
application available via npm:
$ npm install -g wscat
A simple call would take the form:
$ wscat -c ws://127.0.0.1:16384
> { "command": "list"}
The API will return a properly JSON formated response carrying the same id as the request to distinguish subsequent calls.
{"result": ..data..}
In case of an error, the resulting answer will carry an error attribute and a description in human-readable format:
{"error":"Error: keyfile could not found by keyname"}
Before you proceed with the integration, you need to download and install KeyChain.
After installing KeyChain, connect to http://localhost:16384/. When the connection is established, you will see the KeyChain page.
You can find the code for the demo page and the page itself up in the Demo page in JavaScript section.