API request wrapper for NXT crypto for Node.js and the browser. It just has all the currently public API methods for NXT along side with a dual API Promise/Callback based interface.
Plus it's created using Typescript, which should ensure the proper parameters for each API call.
For node.js
npm -g install typescript
npm install nxt-api
For the browser
bower install nxt-api
In Node.js:
var NXT = require('nxt-api');
// start your NRS client first
var API = new NXT.API('http://127.0.0.1:6876');
API.getNextBlockGenerators().then(function (answer) {
console.log(answer);
});
API.rsConvert({ account: 'x' }).then(function (answer) {
// should error
}, function (error) {
console.log(error);
});
In the browser (needs to have nxt.apiServerCORS=true
in your NXT config file, otherwise you need to access it from same port and hostname):
<script src="nxt-api.js"></script>
<script>
var instance = new NXT.API('http://127.0.0.1:7876');
instance.getNextBlockGenerators().then(function(answer){
console.log(answer);
});
</script>
Start the NRS in testNet mode, then run
npm run example
- Missing JSDocs for most of the functions
BTC: 1PskTzQjmzqB2boz67AXsv4C5YNWN4xmhu
NXT: NXT-7TJT-8NS2-8QBS-5Y89X