-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICObenchAPI.js
36 lines (29 loc) · 970 Bytes
/
ICObenchAPI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require('dotenv').config();
const request = require('request');
const CryptoJS = require('crypto-js');
class ICObench {
constructor(){
this.publicKey = "";
this.privateKey = "";
this.apiUrl = 'https://icobench.com/api/v1/';
}
get(action, callback, data = {}) {
let dataJSON = JSON.stringify(data);
let sign = CryptoJS.HmacSHA384(dataJSON, this.privateKey);
sign = CryptoJS.enc.Base64.stringify(sign);
request.post(this.apiUrl + action, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-ICObench-Key': this.publicKey,
'X-ICObench-Sig': sign,
},
forever: true,
json: data
}, function (error, response, body){
console.log(body);
});
}
}
let test = new ICObench();
test.get("icos/trending", (data) => {console.log(data)});