ReddCoin API LIB that exposes reddcoind JSON-RPC Methods through a simply structured URL driven API.
You can include the reddcoin-node-api easily in your node.js project.
npm install reddcoin-node-apiYou can use `reddcoin-node-api' to expose the reddcoind JSON-RPC through a easy to work with URL Structure/
var rddapi = require('reddcoin-node-api'),
express = require('express'),
app = express();
// Username and Password can be set in `~/.reddcoin/reddcoin.conf`
var rddacc = {
host: 'localhost',
port: 45443,
user: 'reddcoinrpc',
pass: 'rddcoinpass'
};
var path = '/api';
rddapi.setWalletDetails(rddacc);
rddapi.setAccess('default-safe');
app.use(path, rddapi.app);
app.listen(5000);You can call methods from the reddcoind JSON-RPC API using a simple URL Structure.
http://localhost:5000/PATH/METHOD
http://localhost:5000/api/getinfo
Would result in a response exactly the same as if were called by the JSON-RPC its self.
{
"version": 1,
"protocolversion": 1,
"walletversion": 1,
"balance": 1,
"blocks": 112345,
"timeoffset": -2,
"connections": 8,
"proxy": "",
"testnet": false,
"keypoololdest": 1368414896,
"keypoolsize": 101,
"paytxfee": 0.0001,
"unlocked_until": 0,
"errors": ""
}
Sometimes you may need to send parameters with your request this can be done in the query string like in the following example call to getRawTransaction The parameters match up with those of the reddcoind JSON-RPC documentation.
http://localhost:5000/api/getrawtransaction?txid=TXID
The only type restricts method calls to only those in the methods object.
rddapi.setAccess('only', ['getinfo']);
Restricting access to certian methods can be done using the restrict type.
rddapi.setAccess('restrict', ['dumpprivkey', 'sendmany']);
Restrict reddcoin-node-api to only call read-only methods.
rddapi.setAccess('read-only');