Code Monkey home page Code Monkey logo

reddcoin-node-api's Introduction

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.

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)

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');

reddcoin-node-api's People

Contributors

matwaller avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

patrickus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.