0.1.3 • Published 9 years ago

satoshi-tv v0.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Satoshi TV

Build Status Coverage Status

Install

To install using the Node.js package manager NPM:

npm install satoshi-tv -g

a Node.js JSON API daemon that serves a React JavaScript browser app.

First step is to download and install Bitcoin Core. Satoshi TV needs access to both the remote procedure call (RPC) and peer-to-peer (P2P) interfaces of bitcoind, the Bitcoin Core "daemon". Create a file named bitcoin.conf in the Bitcoin Core data directory (by default "~/Library/Application Support/Bitcoin" on Mac OS X or "~/.bitcoin" on Linux) with contents:

rpcuser=username
rpcpassword=password
txindex=1
port=8333
rpcport=8332

The "rpc" properties activate the remote procedure call (RPC) interface. The "txindex=1" property tells it to maintain an index of all transactions by address.

Now start Bitcoin Core by either running the desktop UI "Bitcoin-QT", or by firing up the headless daemon bitcoind.

Satoshi TV is powered by Node.js and its package manager npm. To install Satoshi TV and its dependencies, in a terminal shell do:

git clone https://github.com/carnesen/satoshi-tv
cd satoshi-tv
npm install

Satoshi TV reads its configuration from YAML files in the "config" directory. To override the defaults, create a file "local.yml" in that directory.

Now to start Satoshi TV, do:

npm start

First that browserify's the Satoshi TV React app into the public directory. Then it starts up the Node.js back end, which serves the public static assets as well as the JSON API. If everything went according to plan, you should now be able to connect to Satoshi TV at http://localhost:20832.

HTTP API

The Satoshi TV API is served under the URI /api. A GET request to any of the endpoints returns a JSON list of timestamped data points of the form:

{
  key: <timestamp>,
  value: <value>
}

where <timestamp> is the number of milliseconds since January 1 1970 that the data point was captured and <value> is the data value payload. You can limit the date range of data returned in the list using query parameters gt and lt. For example:

curl localhost:20832/api/bitcoin/transactions?gt=1434305100025

returns transactions relayed to Satoshi TV by its Bitcoin Core peer after June 14th 2015 at 12:17PM.

API documentation is in progress. For now you can see which endpoints are available by looking at the Javascript files in the /lib subdirectories bitcoin, bitcoind, satoshi-tv, and system.

WebSocket API

Each of the HTTP endpoints is also exposed as a WebSocket "namespace" that on connection emits the latest data point all updates then thereafter.