1.0.3 • Published 6 years ago
faucethub-api v1.0.3
Unofficial faucethub.io API
Library for faucet on faucethub.io
Install
npm install faucethub-api
Using
For all methods check official docs: faucethub.io/api ###Interface
/**
* @param api_key {String} - api key
* @param currency {String} - currency for faucet (BTC, LTC, DOGE, ...)
* @constructor
*/
const FaucethubAPI = require('faucethub-api');
/**
* get-request without body
* @param callback {Function.<Object>}
* */
FaucethubAPI.getBalance(callback);
/**
* @param address {String} currency address
* @param callback {Function.<Object>}
* */
FaucethubAPI.checkAddress(address, callback);
/**
* put-request with header "Content-Type: application/x-www-form-urlencoded" and body
* @param address {String} currency address
* @param amount {Number} amount of currency in satoshi
* @param callback {Function.<Object>}
* */
FaucethubAPI.send(address, amount, callback);
/**
* @param count {Number} count of last rewards
* @param callback {Function.<Object>}
* */
FaucethubAPI.payouts(count, callback);
###example
const FaucethubAPI = require('faucethub-api');
const api_key = "abcdefghijklmnopqrstuvwxyz";
const currency = "DOGE";
const faucethubApi = new FaucethubAPI(api_key,currency);
faucethubApi.getBalance(res => {
console.log(res);
});
/**
{
"status": 200,
"message": "OK",
"currency": "DOGE",
"balance": 1000000000000,
"balance_bitcoin": 10000
}
*/
faucethubApi.payouts(10, res => {
console.log(res);
});
/**
{
"status": 200,
"message": "OK",
"rewards": [
{
"to": "CURRENCY_ADDRESS_HERE",
"amount": 1,
"date": "17-11-16 10:38:48 GMT"
},
{
"to": "CURRENCY_ADDRESS_HERE",
"amount": 1,
"date": "17-11-16 10:38:33 GMT"
}
]
}
*/
faucethubApi.checkAddress("DMtLpJF8a2GHFZNFD6wLf4ZprdorAC4a5r", res => {
console.log(res);
});
/**
{
"status": 200,
"message": "OK",
"payout_user_hash": "SOME_HASH"
}
*/
faucethubApi.send("DMtLpJF8a2GHFZNFD6wLf4ZprdorAC4a5r", 100000000 /* 1 DOGE */, res => {
console.log(res);
});
/**
{
"status": 200,
"message": "OK",
"rate_limit_remaining": 1.24004514,
"currency": "DOGE",
"balance": 29000000,
"balance_bitcoin": 0.290000,
"payout_id": 1234,
"payout_user_hash": "SOME_HASH"
}
*/