node-sia
v1.0.2
Published
node-sia is a Node.js module that's made to interact with the Sia API.
Downloads
6
Readme
Sia Client for Node.js
node-sia
is a Node.js module that's made to interact with the Sia API.
See the Sia API documentation for an overview of endpoints.
Documentation
Constructor([data])
data
- Optional. An object containing zero or more of the following properties:options
url
- URL to your Sia API endpoint. Defaults tohttp://127.0.0.1:9980
password
- Password you have to set to authenticate with the Sia API. Should be used if you have started siad with the--authenticate-api
flag.
request
- An instance ofrequest
which will be used for HTTP requests.node-sia
will create its own if omitted.
Constructs a new instance of SiaClient.
sendRequest(method, endpoint, parameters)
method
- HTTP method (GET, POST)endpoint
- Sia API endpoint you want to reach.parameters
- Optional. An object containing your query strings.
Example:
var SiaClient = require('node-sia');
var client = new SiaClient();
client.sendRequest('GET', '/daemon/version')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.error(err);
});
client.sendRequest('POST', '/wallet/init', {
encryptionpassword: 'my super secure password'
}).then(function (data) {
console.log(data);
}).catch(function (err) {
console.error(err);
});