https://github.com/reddcoin-project/reddcoin-node-api
ReddCoin Node.js Middle layer API For interfacing quickly and easily with reddcoind, ReddID & Electrumx.
https://github.com/reddcoin-project/reddcoin-node-api
api cryptocurrency-library cryptocurrency-wallet electrumx nodejs rdd reddcoin reddcoind reddid
Last synced: about 1 month ago
JSON representation
ReddCoin Node.js Middle layer API For interfacing quickly and easily with reddcoind, ReddID & Electrumx.
- Host: GitHub
- URL: https://github.com/reddcoin-project/reddcoin-node-api
- Owner: reddcoin-project
- Created: 2019-01-21T22:17:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-22T09:21:44.000Z (over 7 years ago)
- Last Synced: 2026-03-25T08:55:35.792Z (4 months ago)
- Topics: api, cryptocurrency-library, cryptocurrency-wallet, electrumx, nodejs, rdd, reddcoin, reddcoind, reddid
- Language: JavaScript
- Homepage: https://api.reddcoin.com
- Size: 14.6 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ReddCoin Node API
ReddCoin API LIB that exposes `reddcoind` JSON-RPC Methods through a simply structured URL driven API.
## Install
You can include the `reddcoin-node-api` easily in your node.js project.
```javascript
npm install reddcoin-node-api
```
## Example Use
You can use `reddcoin-node-api' to expose the reddcoind JSON-RPC through a easy to work with URL Structure/
### Node (API Instances)
```javascript
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);
```
### Using the API Instance
You can call methods from the `reddcoind` JSON-RPC API using a simple URL Structure.
```
http://localhost:5000/PATH/METHOD
```
### Calling the API Without Parameters
```
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": ""
}
```
#### Calling the API With Parameters
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
```
### Access Control
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');
```