Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bitgetlimited
GitHub Repository: bitgetlimited/v3-bitget-api-sdk
Path: blob/master/bitget-node-sdk-api/__test__/api.spec.ts
518 views
1
import BitgetResetApi from '../src';
2
import Console from 'console';
3
import {describe, test} from '@jest/globals'
4
import {toJsonString} from '../src/lib/util';
5
import {MixOrderApi} from '../src/lib/v2/MixOrderApi';
6
7
const apiKey = '';
8
const secretKey = "";
9
const passphrase = '';
10
describe('ApiTest', () => {
11
const mixOrderApi = new BitgetResetApi.MixOrderApi(apiKey, secretKey, passphrase);
12
const mixOrderV2Api = new MixOrderApi(apiKey, secretKey, passphrase);
13
const bitgetApi = new BitgetResetApi.BitgetApi(apiKey, secretKey, passphrase);
14
15
test('place order', () => {
16
const qsOrBody = {
17
'symbol': 'BTCUSDT_UMCBL',
18
'marginCoin': 'USDT',
19
'side': 'open_long',
20
'orderType': 'limit',
21
'price': '27012',
22
'size': '0.01',
23
'timInForceValue': 'normal'
24
};
25
return mixOrderApi.placeOrder(qsOrBody).then((data) => {
26
Console.info(toJsonString(data));
27
});
28
})
29
30
test('send post request directly If the interface is not defined in the sdk', () => {
31
const qsOrBody = {
32
'symbol': 'BTCUSDT_UMCBL',
33
'marginCoin': 'USDT',
34
'side': 'open_long',
35
'orderType': 'limit',
36
'price': '27012',
37
'size': '0.01',
38
'timInForceValue': 'normal'
39
};
40
return bitgetApi.post("/api/mix/v1/order/placeOrder", qsOrBody).then((data) => {
41
Console.info(toJsonString(data));
42
});
43
})
44
45
test('send get request directly If the interface is not defined in the sdk', () => {
46
const qsOrBody = {'symbol': 'btcusdt_spbl','b':'b','a':'a'};
47
return bitgetApi.get("/api/spot/v1/market/depth", qsOrBody).then((data) => {
48
Console.info(toJsonString(data));
49
});
50
})
51
52
test('send get request directly If the interface is not defined in the sdk need auth', () => {
53
const qsOrBody = {'productType': 'umcbl','b':'b','a':'a'};
54
return bitgetApi.get("/api/mix/v1/account/accounts", qsOrBody).then((data) => {
55
Console.info(toJsonString(data));
56
});
57
})
58
59
test('send get request directly If the interface is not defined in the sdk need auth spot', () => {
60
const qsOrBody = {};
61
return bitgetApi.get("/api/spot/v1/account/getInfo", qsOrBody).then((data) => {
62
Console.info(toJsonString(data));
63
});
64
})
65
66
test('send get request directly with encode params', () => {
67
const qsOrBody = {'symbol': '$AIUSDT','businessType':'spot'};
68
return bitgetApi.get("/api/v2/common/trade-rate", qsOrBody).then((data) => {
69
Console.info(toJsonString(data));
70
});
71
})
72
});
73
74
75