Bitcoin Forum
May 14, 2024, 03:58:25 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [ANN] Bitcoin Node API - Automatically map rpc commands to urls in Node.js  (Read 1269 times)
NielDLR (OP)
Member
**
Offline Offline

Activity: 95
Merit: 10



View Profile WWW
July 15, 2013, 01:40:41 AM
 #1

Hey guys,

I'm the lead Bitcoin and front-end developer for Min.io.

I'm a big fan of Node.js. I use the Bitcoin-Node module to interface with bitcoind. However, often I would do testing and needed to run a command quickly without having to code the command and then run the server again. By using the browser I wanted to just run any command directly with no fuss.

So, I created Bitcoin Node Api. This an Express JS middleware plugin that opens a chosen url to interface with your chosen Bitcoin wallet.

An example Node.js Express server. As easy as that!
Code:
var bitcoinapi = require('bitcoin-node-api');
var express = require('express');
var app = express();

//Username and password relate to those set in the bitcoin.conf file

var wallet = {
  host: 'localhost',
  port: 8332,
  user: 'username',
  pass: 'password'
};

bitcoinapi.setWalletDetails(wallet);
bitcoinapi.setAccess('default-safe'); //Access control
app.use('/bitcoin/api', bitcoinapi.app); //Bind the middleware to any chosen url

app.listen(3000);

Just add the method name after the binded url.

Code:
http://localhost:5000/URL/METHOD

For example:

Code:
http://localhost:5000/bitcoin/api/getinfo

Returns this:

Code:
{
  "version": 80300,
  "protocolversion": 70001,
  "walletversion": 60000,
  "balance": 4.3222,
  "blocks": 245645,
  "timeoffset": -2,
  "connections": 8,
  "proxy": "",
  "difficulty": 21335329.113983,
  "testnet": false,
  "keypoololdest": 1368414896,
  "keypoolsize": 101,
  "paytxfee": 0.0001,
  "unlocked_until": 0,
  "errors": ""
}

It's in its infancy. Some commands do not work out of the box, specifically the more complex commands.

If you like this project, star/watch it and/or contribute code. You can read more about the project by checking out the repo. I'll be adding support for more commands as time goes on.

The Cypherfunks - A decentralized band and cryptocurrency. The first cryptocollective.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!