var request = require('request'); var crypto = require('crypto'); var config = { api_url: 'https://api.huobi.com/api.php', access_key : '', secret_key: '' } var md5 = function (str) { var hash = crypto.createHash('md5'); hash.update(str); str = hash.digest('hex'); return str; }; var getAccountInfo = function(){ var time = parseInt((new Date()).getTime() / 1000); var data = {method: 'get_account_info', access_key: config.access_key, created: time}; data.sign = md5('access_key=' + config.access_key + '&created='+ data.created +'&method='+ data.method +'&secret_key=' + config.secret_key + ''); request.post(config.api_url, { form: data }, function (error, response, body) { if (!error && response.statusCode == 200) { var rval = JSON.parse(body); console.log(rval); } } ); } var getDelegations = function(){ var time = parseInt((new Date()).getTime() / 1000); var data = {method: 'get_delegations', access_key: config.access_key, created: time}; data.sign = md5('access_key=' + config.access_key + '&created='+ data.created +'&method='+ data.method +'&secret_key=' + config.secret_key + ''); request.post(config.api_url, { form: data }, function (error, response, body) { if (!error && response.statusCode == 200) { var rval = JSON.parse(body); console.log(rval); } } ); } getAccountInfo();