Skip to content

Instantly share code, notes, and snippets.

@icook
Created April 24, 2019 00:06
Show Gist options
  • Save icook/02a253e07c9d06d64566f9497e7b643e to your computer and use it in GitHub Desktop.
Save icook/02a253e07c9d06d64566f9497e7b643e to your computer and use it in GitHub Desktop.
Working node.js example for the qTrade API
var crypto = require('crypto');
var https = require('https');
var keyID = 170;
var secret = '';
var timestamp = Math.floor(Date.now() / 1000);
var hash, hmac;
var opt = {
host: 'api.qtrade.io',
path: '/v1/user/me',
method: 'GET',
};
var text = opt.method + "\n";
text += opt.path + "\n";
text += timestamp + "\n";
text += '' + "\n";
text += secret;
hash = crypto.createHash('sha256').update(text, 'utf8').digest().toString('base64')
opt.headers = {
'Authorization': 'HMAC-SHA256 ' + keyID + ':' + hash,
"HMAC-Timestamp": timestamp,
}
https.request(opt, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
}).end();
@huglester
Copy link

any example of PHP implematnation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment