FTX API

Authentication

只要是需要認證的API,都必須要帶有以下Header: FTX-KEY, FTX-SIGN, FTX-TS

GET /account

1
const crypto = require("crypto");
2
const https = require("https");
3
const FTX_API_KEY = process.env.ftx_api_key;
4
const FTX_API_SECRET = process.env.ftx_api_secret;
5
6
const hostname = "ftx.com";
7
const endpoint = "/api/account";
8
const method = "GET";
9
const nonce = Date.now();
10
11
const hmac = crypto.createHmac("sha256", FTX_API_SECRET);
12
const signature_payload = `${nonce}${method}${endpoint}`;
13
hmac.update(signature_payload);
14
const digestHex = hmac.digest("hex");
15
16
const options = {
17
host: hostname,
18
port: 443,
19
path: endpoint,
20
method,
21
headers: {
22
"FTX-KEY": FTX_API_KEY,
23
"FTX-SIGN": digestHex,
24
"FTX-TS": nonce.toString()
25
}
26
};
27
28
var req = https.request(options, function(res) {
29
res.on("data", function(data) {
30
console.log(data.toString());
31
});
32
});
33
34
req.end();
Copied!

POST /orders

Last modified 1yr ago